On 06/16/2015 03:51 PM, John Ferlan wrote: > Add a single boolean function to handle whether the hostdev is shared or not > > Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> > --- > src/qemu/qemu_conf.c | 23 +++++++++++++++-------- > 1 file changed, 15 insertions(+), 8 deletions(-) > Given Jan's comments about the overall series, I'd like to propose squashing in the attached patch into this patch. Essentially it's making the same check and returning 0 if the shared bit wasn't set. The current code checks for shared hostdev *and* sgio is set, then fail; otherwise, return 0. This patch will check shared hostdev, return 0 if not.. then check sgio singularly and fail; otherwise return 0. John > diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c > index 16ae6ab..8e9da0d 100644 > --- a/src/qemu/qemu_conf.c > +++ b/src/qemu/qemu_conf.c > @@ -1196,6 +1196,19 @@ qemuAddSharedDisk(virQEMUDriverPtr driver, > } > > > +static bool > +qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev) > +{ > + if (hostdev->shareable && > + (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && > + hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && > + hostdev->source.subsys.u.scsi.protocol != > + VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)) > + return true; > + return false; > +} > + > + > static char * > qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) > { > @@ -1233,10 +1246,7 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, > char *key = NULL; > int ret = -1; > > - if (!hostdev->shareable || > - !(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && > - hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && > - hostdev->source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)) > + if (!qemuIsSharedHostdev(hostdev)) > return 0; > > if (!(key = qemuGetSharedHostdevKey(hostdev))) > @@ -1337,10 +1347,7 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver, > char *key = NULL; > int ret; > > - if (!hostdev->shareable || > - !(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && > - hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && > - hostdev->source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)) > + if (!qemuIsSharedHostdev(hostdev)) > return 0; > > if (!(key = qemuGetSharedHostdevKey(hostdev))) >
>From c8e7805d57c2ce2f8bd0a41ef0dbdcbc359a1223 Mon Sep 17 00:00:00 2001 From: John Ferlan <jferlan@xxxxxxxxxx> Date: Wed, 24 Jun 2015 10:32:38 -0400 Subject: [PATCH 02/10] Merge into patch 1 Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 305cfb5..48fb74a 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1414,11 +1414,10 @@ 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) { + if (hostdev->source.subsys.u.scsi.sgio) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'sgio' is not supported for SCSI " "generic device yet ")); -- 2.1.0
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list