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

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

 



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

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