[PATCH 19/25] qemu: Manage shared device entry for scsi host device

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

 



This adds the shared device entry when starting domain (more
exactly, when preparing host devices), and remove the entry
when destroying domain (when reattaching host devices).
---
 src/qemu/qemu_hostdev.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index d5f94d5..f099a27 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -879,6 +879,19 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
     virSCSIDeviceListPtr list;
     virSCSIDevicePtr tmp;
 
+    /* Loop 1: Add the shared scsi host device to shared device
+     * table.
+     */
+    for (i = 0; i < nhostdevs; i++) {
+        virDomainDeviceDef dev;
+
+        dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
+        dev.data.hostdev = hostdevs[i];
+
+        if (qemuAddSharedDevice(driver, &dev, name) < 0)
+            return -1;
+    }
+
     /* To prevent situation where SCSI device is assigned to two domains
      * we need to keep a list of currently assigned SCSI devices.
      * This is done in several loops which cannot be joined into one big
@@ -887,7 +900,7 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
     if (!(list = virSCSIDeviceListNew()))
         goto cleanup;
 
-    /* Loop 1: build temporary list */
+    /* Loop 2: build temporary list */
     for (i = 0 ; i < nhostdevs ; i++) {
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         virSCSIDevicePtr scsi;
@@ -915,7 +928,7 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
         }
     }
 
-    /* Loop 2: Mark devices in temporary list as used by @name
+    /* Loop 3: Mark devices in temporary list as used by @name
      * and add them to driver list. However, if something goes
      * wrong, perform rollback.
      */
@@ -947,7 +960,7 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
 
     virObjectUnlock(driver->activeScsiHostdevs);
 
-    /* Loop 3: Temporary list was successfully merged with
+    /* Loop 4: Temporary list was successfully merged with
      * driver list, so steal all items to avoid freeing them
      * when freeing temporary list.
      */
@@ -1185,6 +1198,12 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
         virDomainHostdevDefPtr hostdev = hostdevs[i];
         virSCSIDevicePtr scsi, tmp;
         const char *used_by = NULL;
+        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)
-- 
1.8.1.4

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