From: Peter Krempa Date: Thu, 19 Jun 2025 13:46:46 +0000 (+0200) Subject: conf: introduce usb disk models 'usb-storage' and 'usb-bot' X-Git-Tag: v11.5.0-rc1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d47218419949469273ade51f8fad0085d0b5572;p=thirdparty%2Flibvirt.git conf: introduce usb disk models 'usb-storage' and 'usb-bot' Historically libvirt specified 'usb-storage' as driver for USB disks. This though combined with '-blockdev' doesn't properly configure the device to look like CDROM for . 'usb-bot' acts like a controler and allows explicitly connecting a -device to it. In qemu the devices share implementation so they are effectively identical and can be used interchangably. There is a difference in how the storage device itself (the SCSI part) looks when configured properly as CDROM which is unfortunately not compatible/interchangable. As this is effectively a bugfix we'll be fixing the behaviour for the default configuration. The possibility to explicitly set the model is added as a possibility for working around possible problems if they'd appear. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 4c7ec17d45..9a2f065590 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2862,10 +2862,25 @@ paravirtualized driver is specified via the ``disk`` element. ``model`` Indicates the emulated device model of the disk. Typically this is - indicated solely by the ``bus`` property but for ``bus`` "virtio" the - model can be specified further with "virtio", "virtio-transitional" or - "virtio-non-transitional". See `virtio device models`_ - for more details. :since:`Since 5.2.0` + indicated solely by the ``bus`` property. + + For ``bus`` "virtio" the model can be specified further with "virtio", + "virtio-transitional" or "virtio-non-transitional". See `virtio device + models`_ for more details. :since:`Since 5.2.0` + + For ``bus`` "usb" the model can be specified further with ``usb-storage`` + or ``usb-bot``. There is no difference between the two models for + ````. However with ``usb-bot`` a device configured as + ```` is properly exposed as a cdrom device inside the + guest OS. Unfortunately this configuration is not ABI compatible with + ``usb-storage`` and thus it can't be interchanged during migration. + + The QEMU hypervisor driver will pick ``usb-bot`` for cold starts or + hotplug for cdrom devices to properly configure the devices. This is + not compatible for migration to older versions of libvirt and explicit + configuration needs to be used. + :since:`Since 11.5.0`; relevant only for ``QEMU`` hypervisor. + ``rawio`` Indicates whether the disk needs rawio capability. Valid settings are "yes" or "no" (default is "no"). If any one disk in a domain has diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2469144a66..1e24e41a48 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1400,6 +1400,8 @@ VIR_ENUM_IMPL(virDomainDiskModel, "virtio", "virtio-transitional", "virtio-non-transitional", + "usb-storage", + "usb-bot", ); VIR_ENUM_IMPL(virDomainDiskMirrorState, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 667b3ff10a..6997cf7c09 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -438,6 +438,8 @@ typedef enum { VIR_DOMAIN_DISK_MODEL_VIRTIO, VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL, VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL, + VIR_DOMAIN_DISK_MODEL_USB_STORAGE, + VIR_DOMAIN_DISK_MODEL_USB_BOT, VIR_DOMAIN_DISK_MODEL_LAST } virDomainDiskModel; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 1ff441e184..183dd5db5e 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1766,6 +1766,8 @@ virtio virtio-transitional virtio-non-transitional + usb-storage + usb-bot diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bf77af62d0..96a9ca9b14 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -729,6 +729,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev, case VIR_DOMAIN_DISK_MODEL_DEFAULT: return virtioFlags; case VIR_DOMAIN_DISK_MODEL_LAST: + case VIR_DOMAIN_DISK_MODEL_USB_STORAGE: + case VIR_DOMAIN_DISK_MODEL_USB_BOT: break; } return 0;