Split out parts of the config parsing code to make
the parent function easier to read.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_conf.c | 49 +++++++++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ca31a222e8..29f948346d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -423,6 +423,37 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
}
+static int
+virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfigPtr cfg,
+ virConfPtr conf)
+{
+ char **nvram = NULL;
+ int ret = -1;
+ size_t i;
+
+ if (virConfGetValueStringList(conf, "nvram", false, &nvram) < 0)
+ goto cleanup;
+ if (nvram) {
+ virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares);
+
+ cfg->nfirmwares = virStringListLength((const char *const *)nvram);
+ if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) <
0)
+ goto cleanup;
+
+ for (i = 0; nvram[i] != NULL; i++) {
+ if (VIR_ALLOC(cfg->firmwares[i]) < 0)
+ goto cleanup;
+ if (virFirmwareParse(nvram[i], cfg->firmwares[i]) < 0)
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+ cleanup:
+ virStringListFree(nvram);
+ return ret;
+}
+
static int
virQEMUDriverConfigLoadGlusterDebugEntry(virQEMUDriverConfigPtr cfg,
virConfPtr conf)
@@ -591,7 +622,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
size_t i;
char *stdioHandler = NULL;
char **hugetlbfs = NULL;
- char **nvram = NULL;
char *corestr = NULL;
bool tmp;
@@ -907,22 +937,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
if (virConfGetValueBool(conf, "log_timestamp", &cfg->logTimestamp)
< 0)
goto cleanup;
- if (virConfGetValueStringList(conf, "nvram", false, &nvram) < 0)
+ if (virQEMUDriverConfigLoadNVRAMEntry(cfg, conf) < 0)
goto cleanup;
- if (nvram) {
- virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares);
-
- cfg->nfirmwares = virStringListLength((const char *const *)nvram);
- if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) <
0)
- goto cleanup;
-
- for (i = 0; nvram[i] != NULL; i++) {
- if (VIR_ALLOC(cfg->firmwares[i]) < 0)
- goto cleanup;
- if (virFirmwareParse(nvram[i], cfg->firmwares[i]) < 0)
- goto cleanup;
- }
- }
if (virQEMUDriverConfigLoadGlusterDebugEntry(cfg, conf) < 0)
goto cleanup;
@@ -940,7 +956,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
cleanup:
virStringListFree(hugetlbfs);
- virStringListFree(nvram);
VIR_FREE(corestr);
virConfFree(conf);
return ret;
--
2.20.1