First I don't want to add code to handle dummy device that is used when
host usb device is not present at the moment of starting/migrating etc.
Second supporting non mandatory policies would require to handle races
when host usb device is plugged to host and libvirtd starts adding
device but if in the meanwhile host usb device it unplugged back then
current code will use dummy device which is not desired in this case.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_driver.c | 8 ++++++++
src/qemu/qemu_process.c | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9e35427354..1227072bb8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5132,6 +5132,10 @@ processUSBAddedEvent(virQEMUDriverPtr driver,
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
continue;
+ if (hostdev->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_OPTIONAL ||
+ hostdev->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE)
+ continue;
+
usbsrc = &hostdev->source.subsys.u.usb;
if (!usbsrc->replug)
@@ -5190,6 +5194,10 @@ processUSBRemovedEvent(virQEMUDriverPtr driver,
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
continue;
+ if (hostdev->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_OPTIONAL ||
+ hostdev->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE)
+ continue;
+
usbsrc = &hostdev->source.subsys.u.usb;
if (!usbsrc->replug)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 46f04eff44..881bee79a0 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3747,6 +3747,10 @@ qemuProcessReattachUSBDevices(virQEMUDriverPtr driver,
if (!usbsrc->vendor || !usbsrc->product)
continue;
+ if (hostdev->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_OPTIONAL ||
+ hostdev->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE)
+ continue;
+
if (!usbsrc->bus && !usbsrc->device) {
int num;
--
2.23.0