Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/qemu/qemu_driver.c | 61 +++++++++++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 25 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b980725..3abcf5a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11374,34 +11374,11 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
}
static int
-qemuNodeDeviceReAttach(virNodeDevicePtr dev)
+virHostdevPciNodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr,
+ virPCIDevicePtr pci)
{
- virQEMUDriverPtr driver = dev->conn->privateData;
- virPCIDevicePtr pci = NULL;
virPCIDevicePtr other;
- unsigned domain = 0, bus = 0, slot = 0, function = 0;
int ret = -1;
- virNodeDeviceDefPtr def = NULL;
- char *xml = NULL;
- virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
-
- xml = virNodeDeviceGetXMLDesc(dev, 0);
- if (!xml)
- goto cleanup;
-
- def = virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL);
- if (!def)
- goto cleanup;
-
- if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
- goto cleanup;
-
- if (qemuNodeDeviceGetPciInfo(def, &domain, &bus, &slot, &function)
< 0)
- goto cleanup;
-
- pci = virPCIDeviceNew(domain, bus, slot, function);
- if (!pci)
- goto cleanup;
virObjectLock(hostdev_mgr->activePciHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs);
@@ -11434,6 +11411,40 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
out:
virObjectUnlock(hostdev_mgr->inactivePciHostdevs);
virObjectUnlock(hostdev_mgr->activePciHostdevs);
+ return ret;
+}
+
+static int
+qemuNodeDeviceReAttach(virNodeDevicePtr dev)
+{
+ virQEMUDriverPtr driver = dev->conn->privateData;
+ virPCIDevicePtr pci = NULL;
+ unsigned domain = 0, bus = 0, slot = 0, function = 0;
+ int ret = -1;
+ virNodeDeviceDefPtr def = NULL;
+ char *xml = NULL;
+ virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
+
+ xml = virNodeDeviceGetXMLDesc(dev, 0);
+ if (!xml)
+ goto cleanup;
+
+ def = virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL);
+ if (!def)
+ goto cleanup;
+
+ if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
+ goto cleanup;
+
+ if (qemuNodeDeviceGetPciInfo(def, &domain, &bus, &slot, &function)
< 0)
+ goto cleanup;
+
+ pci = virPCIDeviceNew(domain, bus, slot, function);
+ if (!pci)
+ goto cleanup;
+
+ ret = virHostdevPciNodeDeviceReAttach(hostdev_mgr, pci);
+
virPCIDeviceFree(pci);
cleanup:
virNodeDeviceDefFree(def);
--
1.9.0