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

[libvirt] [PATCH 13/23] qemu_conf: split out virQEMUDriverConfigLoadDeviceEntry



Split out parts of the config parsing code to make
the parent function easier to read.

Signed-off-by: Ján Tomko <jtomko redhat com>
---
 src/qemu/qemu_conf.c | 45 +++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b555e33e7b..776ba3f3ad 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -423,6 +423,31 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
 }
 
 
+static int
+virQEMUDriverConfigLoadDeviceEntry(virQEMUDriverConfigPtr cfg,
+                                   virConfPtr conf)
+{
+    bool tmp;
+    int rv;
+
+    if (virConfGetValueBool(conf, "mac_filter", &cfg->macFilter) < 0)
+        return -1;
+
+    if (virConfGetValueBool(conf, "relaxed_acs_check", &cfg->relaxedACS) < 0)
+        return -1;
+    if (virConfGetValueString(conf, "lock_manager", &cfg->lockManagerName) < 0)
+        return -1;
+    if ((rv = virConfGetValueBool(conf, "allow_disk_format_probing", &tmp)) < 0)
+        return -1;
+    if (rv == 1 && tmp) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("allow_disk_format_probing is no longer supported"));
+        return -1;
+    }
+
+    return 0;
+}
+
 static int
 virQEMUDriverConfigLoadRPCEntry(virQEMUDriverConfigPtr cfg,
                                 virConfPtr conf)
@@ -701,7 +726,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
     char *stdioHandler = NULL;
     char **hugetlbfs = NULL;
     char *corestr = NULL;
-    bool tmp;
 
     /* Just check the file is readable before opening it, otherwise
      * libvirt emits an error.
@@ -900,21 +924,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
     if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0)
         goto cleanup;
 
-    if (virConfGetValueBool(conf, "mac_filter", &cfg->macFilter) < 0)
-        goto cleanup;
-
-    if (virConfGetValueBool(conf, "relaxed_acs_check", &cfg->relaxedACS) < 0)
-        goto cleanup;
     if (virConfGetValueBool(conf, "clear_emulator_capabilities", &cfg->clearEmulatorCapabilities) < 0)
         goto cleanup;
-
-    if ((rv = virConfGetValueBool(conf, "allow_disk_format_probing", &tmp)) < 0)
-        goto cleanup;
-    if (rv == 1 && tmp) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("allow_disk_format_probing is no longer supported"));
-        goto cleanup;
-    }
     if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName) < 0)
         goto cleanup;
     if (virConfGetValueUInt(conf, "max_processes", &cfg->maxProcesses) < 0)
@@ -940,9 +951,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
     if (virConfGetValueBool(conf, "dump_guest_core", &cfg->dumpGuestCore) < 0)
         goto cleanup;
 
-    if (virConfGetValueString(conf, "lock_manager", &cfg->lockManagerName) < 0)
-        goto cleanup;
-
     if (virConfGetValueString(conf, "stdio_handler", &stdioHandler) < 0)
         goto cleanup;
     if (stdioHandler) {
@@ -960,6 +968,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
         VIR_FREE(stdioHandler);
     }
 
+    if (virQEMUDriverConfigLoadDeviceEntry(cfg, conf) < 0)
+        goto cleanup;
+
     if (virQEMUDriverConfigLoadRPCEntry(cfg, conf) < 0)
         goto cleanup;
 
-- 
2.20.1


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