On Mon, Jun 23, 2025 at 21:59:18 +0200, Peter Krempa via Devel wrote:
> From: Akihiko Odaki <[email protected]>
>
> usb-storage is a compound device that automatically creates a USB mass
> storage device and a SCSI device as its backend. Unfortunately it lacks
> some configuration options that are usually present with a SCSI device,
> and cannot represent CD-ROM in particular.
>
> Replace usb-storage with usb-bot, which can be combined with a manually
> created SCSI device. libvirt will configure the SCSI device in a way
> identical with how QEMU does for usb-storage except that now it respects
> a configuration option to represent CD-ROM.
>
> Resolves: https://gitlab.com/libvirt/libvirt/-/issues/368
> Signed-off-by: Akihiko Odaki <[email protected]>
> Signed-off-by: Peter Krempa <[email protected]>
> ---
> src/qemu/qemu_alias.c | 20 ++++-
> src/qemu/qemu_capabilities.c | 3 +-
> src/qemu/qemu_command.c | 86 ++++++++++++++++---
> src/qemu/qemu_command.h | 5 ++
> src/qemu/qemu_hotplug.c | 18 ++++
> src/qemu/qemu_validate.c | 38 ++++++--
> tests/qemuhotplugtest.c | 4 +-
> ...om-usb-empty.x86_64-latest.abi-update.args | 3 +-
> .../disk-usb-device-model.x86_64-latest.args | 6 +-
> ...k-usb-device.x86_64-latest.abi-update.args | 12 ++-
> 10 files changed, 167 insertions(+), 28 deletions(-)
>
> diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
> index 9d39ebd63d..67cbddd470 100644
> --- a/src/qemu/qemu_alias.c
> +++ b/src/qemu/qemu_alias.c
> @@ -268,8 +268,24 @@ qemuAssignDeviceDiskAlias(virDomainDef *def,
> break;
>
> case VIR_DOMAIN_DISK_BUS_USB:
> - diskPriv->qomName =
> g_strdup_printf("/machine/peripheral/%s/%s.0/legacy[0]",
> - disk->info.alias,
> disk->info.alias);
> + switch (disk->model) {
> + case VIR_DOMAIN_DISK_MODEL_USB_STORAGE:
> + diskPriv->qomName =
> g_strdup_printf("/machine/peripheral/%s/%s.0/legacy[0]",
> + disk->info.alias,
> disk->info.alias);
> + break;
> +
> + case VIR_DOMAIN_DISK_MODEL_USB_BOT:
> + diskPriv->qomName =
> g_strdup_printf("/machine/peripheral/%s-disk",
I noticed that this is supposed to be "%s-device" to format the proper
qom name:
virsh qemu-monitor-command --pretty fedora41-mig query-block
{
"return": [
[...]
{
"io-status": "ok",
"device": "",
"locked": false,
"removable": false,
"inserted": {
"iops_rd": 0,
"detect_zeroes": "off",
"active": true,
"image": {
"virtual-size": 104857600,
"filename": "/tmp/img1",
"format": "file",
"actual-size": 104857600,
"format-specific": {
"type": "file",
"data": {}
},
"dirty-flag": false
},
"iops_wr": 0,
"ro": false,
"node-name": "libvirt-6-storage",
"backing_file_depth": 0,
"drv": "file",
"iops": 0,
"bps_wr": 0,
"write_threshold": 0,
"encrypted": false,
"bps": 0,
"bps_rd": 0,
"cache": {
"no-flush": false,
"direct": false,
"writeback": true
},
"file": "/tmp/img1"
},
"qdev": "usb-disk0-device",
^^^^^^^^^^^^^^^^
"type": "unknown"
},
[...]
I'll update it before pushing.