Blob Blame History Raw
From 75470b7c297be9bdd712282b89c48465dbe8d400 Mon Sep 17 00:00:00 2001
Message-Id: <75470b7c297be9bdd712282b89c48465dbe8d400@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Fri, 21 May 2021 14:16:10 +0200
Subject: [PATCH] conf: use switch in virDomainDefParseBootOptions

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 6330be1ba3af5c4d2150fe2b831f7bc5d87c6d2a)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <900c870b1720688123ed7b69850548ae308ea9a8.1621599207.git.phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
 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 f8d8d33245..93a78f8277 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19483,33 +19483,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.31.1