[PATCH 17/23] qemu_conf: split out virQEMUDriverConfigLoadSpecificTLS

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

 



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

This is the only patch that mixes various augeas entry
groups in one function.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 71 ++++++++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 29 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 317756d2a0..b5024705d8 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -423,6 +423,47 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
 }
 
 
+static int
+virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
+                                        virConfPtr conf)
+{
+    int rv;
+
+    if (virConfGetValueBool(conf, "vxhs_tls", &cfg->vxhsTLS) < 0)
+        return -1;
+    if (virConfGetValueString(conf, "vxhs_tls_x509_cert_dir", &cfg->vxhsTLSx509certdir) < 0)
+        return -1;
+    if (virConfGetValueBool(conf, "nbd_tls", &cfg->nbdTLS) < 0)
+        return -1;
+    if (virConfGetValueString(conf, "nbd_tls_x509_cert_dir", &cfg->nbdTLSx509certdir) < 0)
+        return -1;
+
+#define GET_CONFIG_TLS_CERTINFO(val) \
+    do { \
+        if ((rv = virConfGetValueBool(conf, #val "_tls_x509_verify", \
+                                      &cfg->val## TLSx509verify)) < 0) \
+            return -1; \
+        if (rv == 1) \
+            cfg->val## TLSx509verifyPresent = true; \
+        if (virConfGetValueString(conf, #val "_tls_x509_cert_dir", \
+                                  &cfg->val## TLSx509certdir) < 0) \
+            return -1; \
+        if (virConfGetValueString(conf, \
+                                  #val "_tls_x509_secret_uuid", \
+                                  &cfg->val## TLSx509secretUUID) < 0) \
+            return -1; \
+    } while (0)
+
+    if (virConfGetValueBool(conf, "chardev_tls", &cfg->chardevTLS) < 0)
+        return -1;
+    GET_CONFIG_TLS_CERTINFO(chardev);
+
+    GET_CONFIG_TLS_CERTINFO(migrate);
+
+#undef GET_CONFIG_TLS_CERTINFO
+    return 0;
+}
+
 static int
 virQEMUDriverConfigLoadRemoteDisplayEntry(virQEMUDriverConfigPtr cfg,
                                           virConfPtr conf,
@@ -962,38 +1003,10 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
         goto cleanup;
     if (virConfGetValueBool(conf, "spice_auto_unix_socket", &cfg->spiceAutoUnixSocket) < 0)
         goto cleanup;
-    if (virConfGetValueBool(conf, "vxhs_tls", &cfg->vxhsTLS) < 0)
-        goto cleanup;
-    if (virConfGetValueString(conf, "vxhs_tls_x509_cert_dir", &cfg->vxhsTLSx509certdir) < 0)
-        goto cleanup;
-    if (virConfGetValueBool(conf, "nbd_tls", &cfg->nbdTLS) < 0)
-        goto cleanup;
-    if (virConfGetValueString(conf, "nbd_tls_x509_cert_dir", &cfg->nbdTLSx509certdir) < 0)
         goto cleanup;
 
-#define GET_CONFIG_TLS_CERTINFO(val) \
-    do { \
-        if ((rv = virConfGetValueBool(conf, #val "_tls_x509_verify", \
-                                      &cfg->val## TLSx509verify)) < 0) \
-            goto cleanup; \
-        if (rv == 1) \
-            cfg->val## TLSx509verifyPresent = true; \
-        if (virConfGetValueString(conf, #val "_tls_x509_cert_dir", \
-                                  &cfg->val## TLSx509certdir) < 0) \
-            goto cleanup; \
-        if (virConfGetValueString(conf, \
-                                  #val "_tls_x509_secret_uuid", \
-                                  &cfg->val## TLSx509secretUUID) < 0) \
-            goto cleanup; \
-    } while (0)
-
-    if (virConfGetValueBool(conf, "chardev_tls", &cfg->chardevTLS) < 0)
+    if (virQEMUDriverConfigLoadSpecificTLSEntry(cfg, conf) < 0)
         goto cleanup;
-    GET_CONFIG_TLS_CERTINFO(chardev);
-
-    GET_CONFIG_TLS_CERTINFO(migrate);
-
-#undef GET_CONFIG_TLS_CERTINFO
 
     if (virQEMUDriverConfigLoadRemoteDisplayEntry(cfg, conf, filename) < 0)
         goto cleanup;
-- 
2.20.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]

  Powered by Linux