From be47c2e932f18cb366e9bc49636b5f9a2a75fda1 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Sat, 11 Apr 2026 17:02:41 +0800 Subject: [PATCH] runtime-rs: Avoid share-rw on readonly virtio-scsi/blk devices Hotplugging a readonly block device could fail with: Block node is read-only The backend block node was created readonly, but the virtio-scsi/blk frontend path still forced share-rw=true. This is unnecessary and can cause QEMU to reject the attach because the frontend configuration does not match the readonly backend. Fix the virtio-scsi/blk hotplug path by: - setting read-only for readonly devices where supported - skipping share-rw for readonly devices Readonly handling remains in the backend block node configuration, while the frontend keeps normal disk semantics for block devices. Signed-off-by: Alex Lyn --- src/runtime-rs/crates/hypervisor/src/qemu/qmp.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/qmp.rs b/src/runtime-rs/crates/hypervisor/src/qemu/qmp.rs index 7abfc66d3c..e9c3747754 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/qmp.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/qmp.rs @@ -775,7 +775,9 @@ impl Qmp { // add SCSI frontend device blkdev_add_args.insert("scsi-id".to_string(), scsi_id.into()); blkdev_add_args.insert("lun".to_string(), lun.into()); - blkdev_add_args.insert("share-rw".to_string(), true.into()); + if !is_readonly { + blkdev_add_args.insert("share-rw".to_string(), true.into()); + } info!( sl!(), @@ -813,7 +815,9 @@ impl Qmp { let ccw_addr = subchannel.address_format_ccw_for_virt_server(slot); blkdev_add_args.insert("devno".to_owned(), devno.clone().into()); - blkdev_add_args.insert("share-rw".to_string(), true.into()); + if !is_readonly { + blkdev_add_args.insert("share-rw".to_string(), true.into()); + } info!( sl!(), @@ -844,7 +848,9 @@ impl Qmp { } else { let (bus, slot) = self.find_free_slot()?; blkdev_add_args.insert("addr".to_owned(), format!("{slot:02}").into()); - blkdev_add_args.insert("share-rw".to_string(), true.into()); + if !is_readonly { + blkdev_add_args.insert("share-rw".to_string(), true.into()); + } info!( sl!(),