[PATCH 7/7] qemu: Add check for unpriv sgio for SCSI generic host device

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

 



https://bugzilla.redhat.com/show_bug.cgi?id=1072736

Check if the hostdev has set the sgio filtered/unfiltered and handle
appropriately.

This restores functionality removed by commit id 'ce346623' to remove
sgio support the SCSI generic host device. Note that this patch fixes
a bug where if the virGetDeviceUnprivSGIO returned either 0 or 1 in
'val', the 'disk' would be dereferenced; however, since a hostdev
didn't have one - that dereference would have caused a segfault. Instead
these changes use the hostdev's sgio value.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 14ea4c8..485f1cc 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1276,6 +1276,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
 {
     char *dev_path = NULL;
     char *key = NULL;
+    virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
+    virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
     int ret = -1;
 
     if (!qemuIsSharedHostdev(hostdev))
@@ -1286,6 +1288,18 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver,
     if (!(dev_path = qemuGetHostdevPath(hostdev)))
         goto cleanup;
 
+    if (virCheckUnprivSGIO(driver->sharedDevices, dev_path,
+                           scsisrc->sgio) < 0) {
+        if (virGetLastError() == NULL) {
+            virReportError(VIR_ERR_OPERATION_INVALID,
+                           _("sgio of shared scsi host device '%s-%d-%d-%d' "
+                             "conflicts with other active domains"),
+                           scsihostsrc->adapter, scsihostsrc->bus,
+                           scsihostsrc->target, scsihostsrc->unit);
+        }
+        goto cleanup;
+    }
+
     if (!(key = qemuGetSharedHostdevKey(dev_path)))
         goto cleanup;
 
-- 
2.1.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]