These new helpers take hostdev list and count directly rather than
getting them indirectly from domain definition. This will allow reuse
for the attach-device case.
Cc: Alex Williamson <alex.williamson(a)redhat.com>
Cc: Don Dutile <ddutile(a)redhat.com>
Cc: Chris Lalancette <clalance(a)redhat.com>
Cc: Mark McLoughlin <markmc(a)redhat.com>
Signed-off-by: Chris Wright <chrisw(a)redhat.com>
---
src/qemu/qemu_driver.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6e18d41..d8288da 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2897,14 +2897,15 @@ cleanup:
static int
-qemuPrepareHostPCIDevices(struct qemud_driver *driver,
- virDomainDefPtr def)
+qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs)
{
pciDeviceList *pcidevs;
int i;
int ret = -1;
- if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs)))
+ if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
return -1;
/* We have to use 3 loops here. *All* devices must
@@ -2954,6 +2955,13 @@ cleanup:
return ret;
}
+static int
+qemuPrepareHostPCIDevices(struct qemud_driver *driver,
+ virDomainDefPtr def)
+{
+ return qemuPrepareHostdevPCIDevices(driver, def->hostdevs, def->nhostdevs);
+}
+
static int
qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
@@ -3047,16 +3055,14 @@ qemudReattachManagedDevice(pciDevice *dev, struct qemud_driver
*driver)
}
static void
-qemuDomainReAttachHostDevices(struct qemud_driver *driver,
- virDomainDefPtr def)
+qemuDomainReAttachHostdevDevices(struct qemud_driver *driver,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs)
{
pciDeviceList *pcidevs;
int i;
- if (!def->nhostdevs)
- return;
-
- if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs))) {
+ if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs))) {
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),
err ? err->message : _("unknown error"));
@@ -3090,6 +3096,16 @@ qemuDomainReAttachHostDevices(struct qemud_driver *driver,
pciDeviceListFree(pcidevs);
}
+static void
+qemuDomainReAttachHostDevices(struct qemud_driver *driver,
+ virDomainDefPtr def)
+{
+ if (!def->nhostdevs)
+ return;
+
+ qemuDomainReAttachHostdevDevices(driver, def->hostdevs, def->nhostdevs);
+}
+
static const char *const defaultDeviceACL[] = {
"/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/urandom",
--
1.7.1.1