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(a)redhat.com>
---
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