Add necessary checks in order to allow setting sgio values for a scsi host device Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 797e5f1..14ea4c8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1441,6 +1441,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) virDomainDiskDefPtr disk = NULL; virDomainHostdevDefPtr hostdev = NULL; char *sysfs_path = NULL; + char *hostdev_path = NULL; const char *path = NULL; int val = -1; int ret = 0; @@ -1459,19 +1460,13 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { hostdev = dev->data.hostdev; + if (!qemuIsSharedHostdev(hostdev)) + return 0; - if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type == - VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && - hostdev->source.subsys.u.scsi.sgio) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("'sgio' is not supported for SCSI " - "generic device yet ")); - ret = -1; + if (!(hostdev_path = qemuGetHostdevPath(hostdev))) goto cleanup; - } - return 0; + path = hostdev_path; } else { return 0; } @@ -1483,7 +1478,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) } /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */ - val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); + if (dev->type == VIR_DOMAIN_DEVICE_DISK) + val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); + else + val = (hostdev->source.subsys.u.scsi.sgio == + VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); /* Do not do anything if unpriv_sgio is not supported by the kernel and the * whitelist is enabled. But if requesting unfiltered access, always call @@ -1494,6 +1493,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) ret = -1; cleanup: + VIR_FREE(hostdev_path); VIR_FREE(sysfs_path); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list