Add a single boolean function to handle whether the hostdev is shared or not
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_conf.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
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)))
--
2.1.0