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