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 e268e2fd1e..f3aae2ba1a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5252,6 +5252,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)
@@ -5310,6 +5314,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 82e10f4743..2ab3b6f0b9 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3755,6 +3755,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