]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
hostdev: Report the domain name for used hostdevs during nodedev-detach
authorShivaprasad G Bhat <shivaprasadbhat@gmail.com>
Wed, 1 Apr 2015 10:58:05 +0000 (16:28 +0530)
committerJán Tomko <jtomko@redhat.com>
Tue, 7 Apr 2015 12:01:40 +0000 (14:01 +0200)
The nodedev-detach can report the name of the domain using the device
just the way nodedev-reattach does it.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/util/virhostdev.c

index 83f567d307a4f06503eaf61240f11f86bace095f..68e060b9852cbd5e8422e0a31bf76a949db8de89 100644 (file)
@@ -1521,11 +1521,18 @@ int
 virHostdevPCINodeDeviceDetach(virHostdevManagerPtr hostdev_mgr,
                               virPCIDevicePtr pci)
 {
+    virPCIDeviceAddressPtr devAddr = NULL;
     int ret = -1;
 
     virObjectLock(hostdev_mgr->activePCIHostdevs);
     virObjectLock(hostdev_mgr->inactivePCIHostdevs);
 
+    if (!(devAddr = virPCIDeviceGetAddress(pci)))
+        goto out;
+
+    if (virHostdevIsPCINodeDeviceUsed(devAddr, hostdev_mgr))
+        goto out;
+
     if (virPCIDeviceDetach(pci, hostdev_mgr->activePCIHostdevs,
                            hostdev_mgr->inactivePCIHostdevs) < 0) {
         goto out;
@@ -1535,6 +1542,7 @@ virHostdevPCINodeDeviceDetach(virHostdevManagerPtr hostdev_mgr,
  out:
     virObjectUnlock(hostdev_mgr->inactivePCIHostdevs);
     virObjectUnlock(hostdev_mgr->activePCIHostdevs);
+    VIR_FREE(devAddr);
     return ret;
 }