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

[libvirt] [PATCH 2/2] qemu: Don't fail if the SCSI host device is shareable between domains



It doesn't make sense to fail if the SCSI host device is specified
as "shareable" explicitly between domains (NB, it works if and only
if the device is specified as "shareable" for *all* domains,
otherwise it fails).

Also don't try to add the device to the activeScsiHostdevs list if
it's already there.
---
 src/qemu/qemu_hostdev.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 86a463a..8536499 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -1120,22 +1120,25 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
         if ((tmp = virSCSIDeviceListFind(driver->activeScsiHostdevs, scsi))) {
             const char *other_name = virSCSIDeviceGetUsedBy(tmp);
 
-            if (other_name)
-                virReportError(VIR_ERR_OPERATION_INVALID,
-                               _("SCSI device %s is in use by domain %s"),
-                               virSCSIDeviceGetName(tmp), other_name);
-            else
-                virReportError(VIR_ERR_OPERATION_INVALID,
-                               _("SCSI device %s is already in use"),
-                               virSCSIDeviceGetName(tmp));
-            goto error;
-        }
-
-        virSCSIDeviceSetUsedBy(scsi, name);
-        VIR_DEBUG("Adding %s to activeScsiHostdevs", virSCSIDeviceGetName(scsi));
+            if (!(virSCSIDeviceGetShareable(scsi) &&
+                  virSCSIDeviceGetShareable(tmp))) {
+                if (other_name)
+                    virReportError(VIR_ERR_OPERATION_INVALID,
+                                   _("SCSI device %s is in use by domain %s"),
+                                   virSCSIDeviceGetName(tmp), other_name);
+                else
+                    virReportError(VIR_ERR_OPERATION_INVALID,
+                                   _("SCSI device %s is already in use"),
+                                   virSCSIDeviceGetName(tmp));
+                goto error;
+            }
+        } else {
+            virSCSIDeviceSetUsedBy(scsi, name);
+            VIR_DEBUG("Adding %s to activeScsiHostdevs", virSCSIDeviceGetName(scsi));
 
-        if (virSCSIDeviceListAdd(driver->activeScsiHostdevs, scsi) < 0)
-            goto error;
+            if (virSCSIDeviceListAdd(driver->activeScsiHostdevs, scsi) < 0)
+                goto error;
+        }
     }
 
     virObjectUnlock(driver->activeScsiHostdevs);
-- 
1.8.1.4


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