[PATCH v13 24/49] extract general code from qemuPrepareHostUSBDevices

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

 



Extract general code from qemuPrepareHostUSBDevices to
virHostdevPrepareHostUSBDevices.

Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/qemu/qemu_hostdev.c |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index e39bc47..1a589f4 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -390,26 +390,19 @@ out:
     return 0;
 }
 
-
-int
-qemuPrepareHostUSBDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
-                          virDomainDefPtr def,
-                          unsigned int flags)
+static int
+virHostdevPrepareUSBDevices(virHostdevManagerPtr hostdev_mgr,
+                            const char *dom_name,
+                            virDomainHostdevDefPtr *hostdevs,
+                            int nhostdevs,
+                            unsigned int flags)
 {
     size_t i;
     int ret = -1;
     virUSBDeviceListPtr list;
     virUSBDevicePtr tmp;
-    virDomainHostdevDefPtr *hostdevs = def->hostdevs;
-    int nhostdevs = def->nhostdevs;
-    const char *dom_name = def->name;
-    virHostdevManagerPtr hostdev_mgr;
     bool coldBoot = !!(flags & VIR_COLD_BOOT);
 
-    hostdev_mgr = virHostdevManagerGetDefault();
-    if (hostdev_mgr == NULL)
-        return -1;
-
     /* To prevent situation where USB device is assigned to two domains
      * we need to keep a list of currently assigned USB devices.
      * This is done in several loops which cannot be joined into one big
@@ -467,6 +460,24 @@ cleanup:
     return ret;
 }
 
+int
+qemuPrepareHostUSBDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+                          virDomainDefPtr def,
+                          unsigned int flags)
+{
+    virDomainHostdevDefPtr *hostdevs = def->hostdevs;
+    int nhostdevs = def->nhostdevs;
+    const char *dom_name = def->name;
+    virHostdevManagerPtr hostdev_mgr;
+
+    hostdev_mgr = virHostdevManagerGetDefault();
+    if (hostdev_mgr == NULL)
+        return -1;
+
+    return virHostdevPrepareUSBDevices(hostdev_mgr, dom_name,
+                                       hostdevs, nhostdevs, flags);
+}
+
 
 int
 qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
-- 
1.6.0.2

--
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]