[RFC PATCH 2/4] Add helpers qemuPrepareHostdevPCIDevices and qemuDomainReAttachHostdevDevices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Cc: Don Dutile <ddutile@xxxxxxxxxx>
Cc: Chris Lalancette <clalance@xxxxxxxxxx>
Cc: Mark McLoughlin <markmc@xxxxxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]