[libvirt PATCH 7/9] conf: use switch in virDomainDefParseBootOptions

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

 



The original code used a lot of conditions and was not that obvious
when each XML bits are parsed.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 14a2c818d6..7729333897 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19702,33 +19702,43 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
      *   - An init script                             (exe)
      */
 
-    if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
-        if (virDomainDefParseBootInitOptions(def, ctxt) < 0)
-            return -1;
-    }
-
-    if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
-        def->os.type == VIR_DOMAIN_OSTYPE_XENPVH ||
-        def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
-        def->os.type == VIR_DOMAIN_OSTYPE_UML) {
-
+    switch ((virDomainOSType) def->os.type) {
+    case VIR_DOMAIN_OSTYPE_HVM:
         virDomainDefParseBootKernelOptions(def, ctxt);
 
-        if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
-            if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0)
-                return -1;
-        }
+        if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0)
+            return -1;
 
         if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0)
             return -1;
-    }
 
-    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0)
             return -1;
 
         if (virDomainDefParseBootXML(ctxt, def) < 0)
             return -1;
+
+        break;
+
+    case VIR_DOMAIN_OSTYPE_XEN:
+    case VIR_DOMAIN_OSTYPE_XENPVH:
+    case VIR_DOMAIN_OSTYPE_UML:
+        virDomainDefParseBootKernelOptions(def, ctxt);
+
+        if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0)
+            return -1;
+
+        break;
+
+    case VIR_DOMAIN_OSTYPE_EXE:
+        if (virDomainDefParseBootInitOptions(def, ctxt) < 0)
+            return -1;
+
+        break;
+
+    case VIR_DOMAIN_OSTYPE_LINUX:
+    case VIR_DOMAIN_OSTYPE_LAST:
+        break;
     }
 
     return 0;
-- 
2.30.2




[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]

  Powered by Linux