Extract general code from qemuDomainReAttachHostScsiDevices to
virHostdevDomainReAttachHostScsiDevices.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/qemu/qemu_hostdev.c | 48 ++++++++++++++++++++++++++++++----------------
1 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 6e65a02..66fb26a 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -358,31 +358,19 @@ qemuDomainReAttachHostUsbDevices(virQEMUDriverPtr driver
ATTRIBUTE_UNUSED,
name, hostdevs, nhostdevs);
}
-
-void
-qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
- const char *name,
- virDomainHostdevDefPtr *hostdevs,
- int nhostdevs)
+static void
+virHostdevReAttachScsiHostdevs(virHostdevManagerPtr hostdev_mgr,
+ const char *name,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs)
{
size_t i;
- virHostdevManagerPtr hostdev_mgr;
-
- hostdev_mgr = virHostdevManagerGetDefault();
- if (hostdev_mgr == NULL)
- return;
virObjectLock(hostdev_mgr->activeScsiHostdevs);
for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
virSCSIDevicePtr scsi;
virSCSIDevicePtr tmp;
- virDomainDeviceDef dev;
-
- dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
- dev.data.hostdev = hostdev;
-
- ignore_value(qemuRemoveSharedDevice(driver, &dev, name));
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
@@ -432,6 +420,32 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
}
void
+qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
+ const char *name,
+ virDomainHostdevDefPtr *hostdevs,
+ int nhostdevs)
+{
+ size_t i;
+ virHostdevManagerPtr hostdev_mgr;
+
+ hostdev_mgr = virHostdevManagerGetDefault();
+ if (hostdev_mgr == NULL)
+ return;
+
+ for (i = 0; i < nhostdevs; i++) {
+ virDomainHostdevDefPtr hostdev = hostdevs[i];
+ virDomainDeviceDef dev;
+
+ dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
+ dev.data.hostdev = hostdev;
+
+ ignore_value(qemuRemoveSharedDevice(driver, &dev, name));
+ }
+
+ virHostdevReAttachScsiHostdevs(hostdev_mgr, name, hostdevs, nhostdevs);
+}
+
+void
qemuDomainReAttachHostDevices(virQEMUDriverPtr driver,
virDomainDefPtr def)
{
--
1.6.0.2