Since setting security label is dependent bus/addr being available. This fixes hotplugging a USB device that is referenced only by product/vendor (virt-manager's default). https://bugzilla.redhat.com/show_bug.cgi?id=1016511 --- src/qemu/qemu_hotplug.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f4fc723..d93fef9 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1437,19 +1437,16 @@ cleanup: static int qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainHostdevDefPtr hostdev) + virDomainHostdevDefPtr hostdev, + virUSBDevicePtr usb) { qemuDomainObjPrivatePtr priv = vm->privateData; virUSBDeviceList *list = NULL; - virUSBDevicePtr usb = NULL; char *devstr = NULL; bool added = false; bool teardowncgroup = false; int ret = -1; - if (qemuFindHostdevUSBDevice(hostdev, true, &usb) < 0) - return -1; - if (!(list = virUSBDeviceListNew())) goto cleanup; @@ -1594,6 +1591,8 @@ int qemuDomainAttachHostDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { + virUSBDevicePtr usb = NULL; + if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("hostdev mode '%s' not supported"), @@ -1601,6 +1600,11 @@ int qemuDomainAttachHostDevice(virQEMUDriverPtr driver, return -1; } + /* We need to fill in USB values before the security labeling */ + if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB && + qemuFindHostdevUSBDevice(hostdev, true, &usb) < 0) + return -1; + if (virSecurityManagerSetHostdevLabel(driver->securityManager, vm->def, hostdev, NULL) < 0) return -1; @@ -1614,7 +1618,7 @@ int qemuDomainAttachHostDevice(virQEMUDriverPtr driver, case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: if (qemuDomainAttachHostUsbDevice(driver, vm, - hostdev) < 0) + hostdev, usb) < 0) goto error; break; -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list