From d325e96546f7bc57435ccff4ef990297304fce9f Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 19 Jun 2025 09:46:38 +0200 Subject: [PATCH] qemuBuildDeviceAddresDriveProps: Prepare for 'drive' address for usb-bot disks While the 'usb-storage' based disks use the USB address directly, with 'usb-bot' the USB address is on the "controller" part of the device and the 'scsi-hd/cd' device will use a 'drive' address from qemu's PoV. Since we do not want to expose the 'usb-bot' as explicit controller to preserve compatibility with existing configs we plan to upgrade implement the formatter for 'drive' address when the "diskbus" property is VIR_DOMAIN_DISK_BUS_USB. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_command.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b752a828ba..e60b1d1038 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -545,8 +545,21 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props, return -1; break; - case VIR_DOMAIN_DISK_BUS_VIRTIO: case VIR_DOMAIN_DISK_BUS_USB: + /* Device info with type VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE and + * VIR_DOMAIN_DISK_BUS_USB diskbus is an internal representation + * for the device address for 'usb-bot'. */ + bus = g_strdup_printf("%s.0", info->alias); + + if (virJSONValueObjectAdd(&props, + "s:bus", bus, + "u:scsi-id", info->addr.drive.target, + "u:lun", info->addr.drive.unit, + NULL) < 0) + return -1; + break; + + case VIR_DOMAIN_DISK_BUS_VIRTIO: case VIR_DOMAIN_DISK_BUS_XEN: case VIR_DOMAIN_DISK_BUS_UML: case VIR_DOMAIN_DISK_BUS_SD: -- 2.47.3