Am 26.05.2021 um 23:15 hat Vladimir Sementsov-Ogievskiy geschrieben:
Instead of keeping additional boolean field, let's store the
information in BDRV_O_RDWR bit of BlockBackendRootState::open_flags.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
diff --git a/blockdev.c b/blockdev.c
index 834c2304a1..c36884c691 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -576,6 +576,9 @@ static BlockBackend *blockdev_init(const char *file, QDict
*bs_opts,
}
read_only = qemu_opt_get_bool(opts, BDRV_OPT_READ_ONLY, false);
+ if (!read_only) {
+ bdrv_flags |= BDRV_O_RDWR;
+ }
/* init */
if ((!file || !*file) && !qdict_size(bs_opts)) {
@@ -584,7 +587,6 @@ static BlockBackend *blockdev_init(const char *file, QDict
*bs_opts,
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
blk_rs = blk_get_root_state(blk);
blk_rs->open_flags = bdrv_flags;
- blk_rs->read_only = read_only;
blk_rs->detect_zeroes = detect_zeroes;
qobject_unref(bs_opts);
That we're now using different flags for blk_new_open() looked a bit
suspicious, though the new state intuitively makes more sense than the
old one.
Anyway, this patch breaks ahci-test:
# starting QEMU: exec build/x86_64-softmmu/qemu-system-x86_64 -qtest
unix:/tmp/qtest-54104.sock -qtest-log /dev/null -chardev
socket,path=/tmp/qtest-54104.qmp,id=char0 -mon chardev=char0,mode=control
-display none -drive
file=/tmp/qtest.mGtxeg,if=none,id=drive0,cache=writeback,rerror=stop,werror=stop,format=raw
-M q35 -device ide-hd,drive=drive0 -incoming unix:/tmp/qtest-migration.XVRZZi
-accel qtest
qemu-system-x86_64: -drive
file=/tmp/qtest.mGtxeg,if=none,id=drive0,cache=writeback,rerror=stop,werror=stop,format=raw:
Block node is read-only