[PATCH v1 04/19] qemu: Refactor qemuIsSharedHostdev for readability/extendability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We're going to make some changes here, and the boolean logic
does not lend itself to be easily expanded.

Signed-off-by: Eric Farman <farman@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fa9d65e..64f85dd 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1096,11 +1096,20 @@ qemuAddSharedDisk(virQEMUDriverPtr driver,
 static bool
 qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev)
 {
-    return (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 (!hostdev->shareable)
+        return false;
+
+    if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+        return false;
+
+    if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
+        return false;
+
+    if (hostdev->source.subsys.u.scsi.protocol ==
+        VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
+        return false;
+
+    return true;
 }
 
 
-- 
1.9.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]