[PATCH v14 36/49] move virHostdevReAttachHostScsiDevices to virhostdev.c

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

 



Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_hostdev.c  | 62 ------------------------------------------------
 src/util/virhostdev.c    | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/util/virhostdev.h    |  6 +++++
 4 files changed, 69 insertions(+), 62 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ed23337..0a4f341 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1298,6 +1298,7 @@ virHostdevPreparePCIDevices;
 virHostdevPrepareSCSIDevices;
 virHostdevPrepareUSBDevices;
 virHostdevReAttachPCIDevices;
+virHostdevReAttachScsiHostdevs;
 virHostdevReAttachUsbHostdevs;
 virHostdevUpdateActivePciHostdevs;
 virHostdevUpdateActiveScsiHostdevs;
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index b4ab1bd..c83b95d 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -328,68 +328,6 @@ qemuDomainReAttachHostUsbDevices(virQEMUDriverPtr driver,
                                   name, hostdevs, nhostdevs);
 }
 
-static void
-virHostdevReAttachScsiHostdevs(virHostdevManagerPtr hostdev_mgr,
-                               const char *drv_name,
-                               const char *name,
-                               virDomainHostdevDefPtr *hostdevs,
-                               int nhostdevs)
-{
-    size_t i;
-
-    virObjectLock(hostdev_mgr->activeScsiHostdevs);
-    for (i = 0; i < nhostdevs; i++) {
-        virDomainHostdevDefPtr hostdev = hostdevs[i];
-        virSCSIDevicePtr scsi;
-        virSCSIDevicePtr tmp;
-
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
-            hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
-            continue;
-
-        if (!(scsi = virSCSIDeviceNew(NULL,
-                                      hostdev->source.subsys.u.scsi.adapter,
-                                      hostdev->source.subsys.u.scsi.bus,
-                                      hostdev->source.subsys.u.scsi.target,
-                                      hostdev->source.subsys.u.scsi.unit,
-                                      hostdev->readonly,
-                                      hostdev->shareable))) {
-            VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s",
-                     hostdev->source.subsys.u.scsi.adapter,
-                     hostdev->source.subsys.u.scsi.bus,
-                     hostdev->source.subsys.u.scsi.target,
-                     hostdev->source.subsys.u.scsi.unit,
-                     name);
-            continue;
-        }
-
-        /* Only delete the devices which are marked as being used by @name,
-         * because qemuProcessStart could fail on the half way. */
-
-        if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeScsiHostdevs, scsi))) {
-            VIR_WARN("Unable to find device %s:%d:%d:%d "
-                     "in list of active SCSI devices",
-                     hostdev->source.subsys.u.scsi.adapter,
-                     hostdev->source.subsys.u.scsi.bus,
-                     hostdev->source.subsys.u.scsi.target,
-                     hostdev->source.subsys.u.scsi.unit);
-            virSCSIDeviceFree(scsi);
-            continue;
-        }
-
-        VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeScsiHostdevs",
-                   hostdev->source.subsys.u.scsi.adapter,
-                   hostdev->source.subsys.u.scsi.bus,
-                   hostdev->source.subsys.u.scsi.target,
-                   hostdev->source.subsys.u.scsi.unit,
-                   name);
-
-        virSCSIDeviceListDel(hostdev_mgr->activeScsiHostdevs, tmp, drv_name, name);
-        virSCSIDeviceFree(scsi);
-    }
-    virObjectUnlock(hostdev_mgr->activeScsiHostdevs);
-}
-
 void
 qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
                                   const char *name,
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index e679e20..d9bfe43 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -1320,3 +1320,65 @@ virHostdevReAttachUsbHostdevs(virHostdevManagerPtr hostdev_mgr,
     }
     virObjectUnlock(hostdev_mgr->activeUsbHostdevs);
 }
+
+void
+virHostdevReAttachScsiHostdevs(virHostdevManagerPtr hostdev_mgr,
+                               const char *drv_name,
+                               const char *name,
+                               virDomainHostdevDefPtr *hostdevs,
+                               int nhostdevs)
+{
+    size_t i;
+
+    virObjectLock(hostdev_mgr->activeScsiHostdevs);
+    for (i = 0; i < nhostdevs; i++) {
+        virDomainHostdevDefPtr hostdev = hostdevs[i];
+        virSCSIDevicePtr scsi;
+        virSCSIDevicePtr tmp;
+
+        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+            hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
+            continue;
+
+        if (!(scsi = virSCSIDeviceNew(NULL,
+                                      hostdev->source.subsys.u.scsi.adapter,
+                                      hostdev->source.subsys.u.scsi.bus,
+                                      hostdev->source.subsys.u.scsi.target,
+                                      hostdev->source.subsys.u.scsi.unit,
+                                      hostdev->readonly,
+                                      hostdev->shareable))) {
+            VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s",
+                     hostdev->source.subsys.u.scsi.adapter,
+                     hostdev->source.subsys.u.scsi.bus,
+                     hostdev->source.subsys.u.scsi.target,
+                     hostdev->source.subsys.u.scsi.unit,
+                     name);
+            continue;
+        }
+
+        /* Only delete the devices which are marked as being used by @name,
+         * because qemuProcessStart could fail on the half way. */
+
+        if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeScsiHostdevs, scsi))) {
+            VIR_WARN("Unable to find device %s:%d:%d:%d "
+                     "in list of active SCSI devices",
+                     hostdev->source.subsys.u.scsi.adapter,
+                     hostdev->source.subsys.u.scsi.bus,
+                     hostdev->source.subsys.u.scsi.target,
+                     hostdev->source.subsys.u.scsi.unit);
+            virSCSIDeviceFree(scsi);
+            continue;
+        }
+
+        VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeScsiHostdevs",
+                   hostdev->source.subsys.u.scsi.adapter,
+                   hostdev->source.subsys.u.scsi.bus,
+                   hostdev->source.subsys.u.scsi.target,
+                   hostdev->source.subsys.u.scsi.unit,
+                   name);
+
+        virSCSIDeviceListDel(hostdev_mgr->activeScsiHostdevs, tmp, drv_name, name);
+        virSCSIDeviceFree(scsi);
+    }
+    virObjectUnlock(hostdev_mgr->activeScsiHostdevs);
+}
diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
index 7bd5da1..809996c 100644
--- a/src/util/virhostdev.h
+++ b/src/util/virhostdev.h
@@ -84,6 +84,12 @@ virHostdevReAttachUsbHostdevs(virHostdevManagerPtr hostdev_mgr,
                               const char *name,
                               virDomainHostdevDefPtr *hostdevs,
                               int nhostdevs);
+void
+virHostdevReAttachScsiHostdevs(virHostdevManagerPtr hostdev_mgr,
+                               const char *drv_name,
+                               const char *name,
+                               virDomainHostdevDefPtr *hostdevs,
+                               int nhostdevs);
 int
 virHostdevUpdateActivePciHostdevs(virHostdevManagerPtr mgr,
                                   const char *drv_name,
-- 
1.9.0

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