diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 0b6cb3e49262b9d0c3c72f7d37fb771939a2357e..2b4d9f2e1081a07bfd4df7475a6e3dafc0f15a81 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -50,7 +50,8 @@ qemuUpdateActivePCIHostdevs(virQEMUDriverPtr driver, if (!def->nhostdevs) return 0; - return virHostdevUpdateActivePCIDevices(mgr, QEMU_DRIVER_NAME, def); + return virHostdevUpdateActivePCIDevices(mgr, def->hostdevs, def->nhostdevs, + QEMU_DRIVER_NAME, def->name); } int @@ -62,7 +63,8 @@ qemuUpdateActiveUSBHostdevs(virQEMUDriverPtr driver, if (!def->nhostdevs) return 0; - return virHostdevUpdateActiveUSBDevices(mgr, QEMU_DRIVER_NAME, def); + return virHostdevUpdateActiveUSBDevices(mgr, def->hostdevs, def->nhostdevs, + QEMU_DRIVER_NAME, def->name); } int @@ -74,7 +76,8 @@ qemuUpdateActiveSCSIHostdevs(virQEMUDriverPtr driver, if (!def->nhostdevs) return 0; - return virHostdevUpdateActiveSCSIDevices(mgr, QEMU_DRIVER_NAME, def); + return virHostdevUpdateActiveSCSIDevices(mgr, def->hostdevs, def->nhostdevs, + QEMU_DRIVER_NAME, def->name); } diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 58d3d60e13f47fa50bbc715c507b0dad340331b0..1cfba82ffc1911bc61e21a4a43eb5230cda14572 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -776,8 +776,10 @@ cleanup: int virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, const char *drv_name, - virDomainDefPtr def) + const char *dom_name) { virDomainHostdevDefPtr hostdev = NULL; virPCIDevicePtr dev = NULL; @@ -787,8 +789,8 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, virObjectLock(mgr->activePCIHostdevs); virObjectLock(mgr->inactivePCIHostdevs); - for (i = 0; i < def->nhostdevs; i++) { - hostdev = def->hostdevs[i]; + for (i = 0; i < nhostdevs; i++) { + hostdev = hostdevs[i]; if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) continue; @@ -813,7 +815,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, goto cleanup; } - virPCIDeviceSetUsedBy(dev, drv_name, def->name); + virPCIDeviceSetUsedBy(dev, drv_name, dom_name); /* Setup the original states for the PCI device */ virPCIDeviceSetUnbindFromStub(dev, hostdev->origstates.states.pci.unbind_from_stub); @@ -835,17 +837,19 @@ cleanup: int virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, const char *drv_name, - virDomainDefPtr def) + const char *dom_name) { virDomainHostdevDefPtr hostdev = NULL; size_t i; int ret = -1; virObjectLock(mgr->activeUSBHostdevs); - for (i = 0; i < def->nhostdevs; i++) { + for (i = 0; i < nhostdevs; i++) { virUSBDevicePtr usb = NULL; - hostdev = def->hostdevs[i]; + hostdev = hostdevs[i]; if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) continue; @@ -859,11 +863,11 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr, VIR_WARN("Unable to reattach USB device %03d.%03d on domain %s", hostdev->source.subsys.u.usb.bus, hostdev->source.subsys.u.usb.device, - def->name); + dom_name); continue; } - virUSBDeviceSetUsedBy(usb, drv_name, def->name); + virUSBDeviceSetUsedBy(usb, drv_name, dom_name); if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) { virUSBDeviceFree(usb); @@ -878,8 +882,10 @@ cleanup: int virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, const char *drv_name, - virDomainDefPtr def) + const char *dom_name) { virDomainHostdevDefPtr hostdev = NULL; size_t i; @@ -888,8 +894,8 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr, virSCSIDevicePtr tmp = NULL; virObjectLock(mgr->activeSCSIHostdevs); - for (i = 0; i < def->nhostdevs; i++) { - hostdev = def->hostdevs[i]; + for (i = 0; i < nhostdevs; i++) { + hostdev = hostdevs[i]; if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) @@ -905,13 +911,13 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr, goto cleanup; if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) { - if (virSCSIDeviceSetUsedBy(tmp, drv_name, def->name) < 0) { + if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0) { virSCSIDeviceFree(scsi); goto cleanup; } virSCSIDeviceFree(scsi); } else { - if (virSCSIDeviceSetUsedBy(scsi, drv_name, def->name) < 0 || + if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0 || virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) { virSCSIDeviceFree(scsi); goto cleanup; diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index 580f4fe6675230ef15a3869608701458960dda6c..f2ba0effc3409e4fb5c99552c1e4089396942eca 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -92,16 +92,22 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr, int nhostdevs); int virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, const char *drv_name, - virDomainDefPtr def); + const char *dom_name); int virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, const char *drv_name, - virDomainDefPtr def); + const char *dom_name); int virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, const char *drv_name, - virDomainDefPtr def); + const char *dom_name); /* functions used by NodeDevDetach/Reattach/Reset */ int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr,