Extract general code from qemuPrepareHostdevPCIDevices to
virHostdevPrepareHostdevPCIDevices.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/qemu/qemu_hostdev.c | 49 +++++++++++++++++++++++++++++++---------------
1 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 4a36417..76e3978 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -662,28 +662,19 @@ qemuPrepareHostdevPCICheckSupport(virDomainHostdevDefPtr *hostdevs,
return true;
}
-
-int
-qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
- const char *name,
- const unsigned char *uuid,
- virDomainHostdevDefPtr *hostdevs,
- int nhostdevs,
- virQEMUCapsPtr qemuCaps,
- unsigned int flags)
+static int
+virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
+ const char *name,
+ const unsigned char *uuid,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs,
+ unsigned int flags)
{
virPCIDeviceListPtr pcidevs = NULL;
int last_processed_hostdev_vf = -1;
size_t i;
int ret = -1;
- virHostdevManagerPtr hostdev_mgr;
- if (!qemuPrepareHostdevPCICheckSupport(hostdevs, nhostdevs, qemuCaps))
- goto out;
-
- hostdev_mgr = virHostdevManagerGetDefault();
- if (hostdev_mgr == NULL)
- goto out;
virObjectLock(hostdev_mgr->activePciHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs);
@@ -866,6 +857,32 @@ cleanup:
virObjectUnlock(hostdev_mgr->activePciHostdevs);
virObjectUnlock(hostdev_mgr->inactivePciHostdevs);
virObjectUnref(pcidevs);
+ return ret;
+
+}
+
+int
+qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+ const char *name,
+ const unsigned char *uuid,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs,
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
+{
+ int ret = -1;
+ virHostdevManagerPtr hostdev_mgr;
+
+ if (!qemuPrepareHostdevPCICheckSupport(hostdevs, nhostdevs, qemuCaps))
+ goto out;
+
+ hostdev_mgr = virHostdevManagerGetDefault();
+ if (hostdev_mgr == NULL)
+ goto out;
+
+ ret = virHostdevPreparePCIDevices(hostdev_mgr, name, uuid, hostdevs,
+ nhostdevs, flags);
+
out:
return ret;
}
--
1.6.0.2