[PATCH v2 11/14] qemu: Create #define for TLS configuration setup.

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

 



Create GET_CONFIG_TLS_CERT to set up the TLS for 'chardev' TLS setting.
Soon to be reused.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b5b0645..b75cd54 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -529,22 +529,33 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
     if (virConfGetValueBool(conf, "spice_auto_unix_socket", &cfg->spiceAutoUnixSocket) < 0)
         goto cleanup;
 
-    if (virConfGetValueBool(conf, "chardev_tls", &cfg->chardevTLS) < 0)
-        goto cleanup;
-    if (virConfGetValueString(conf, "chardev_tls_x509_cert_dir", &cfg->chardevTLSx509certdir) < 0)
-        goto cleanup;
-    if ((rv = virConfGetValueBool(conf, "chardev_tls_x509_verify", &cfg->chardevTLSx509verify)) < 0)
-        goto cleanup;
-    if (rv == 0)
-        cfg->chardevTLSx509verify = cfg->defaultTLSx509verify;
-    if (virConfGetValueString(conf, "chardev_tls_x509_secret_uuid",
-                              &cfg->chardevTLSx509secretUUID) < 0)
-        goto cleanup;
-    if (!cfg->chardevTLSx509secretUUID && cfg->defaultTLSx509secretUUID) {
-        if (VIR_STRDUP(cfg->chardevTLSx509secretUUID,
-                       cfg->defaultTLSx509secretUUID) < 0)
-            goto cleanup;
-    }
+#define GET_CONFIG_TLS_CERT(val)                                            \
+    do {                                                                    \
+        if (virConfGetValueBool(conf, #val "_tls", &cfg->val## TLS) < 0)    \
+            goto cleanup;                                                   \
+        if ((rv = virConfGetValueBool(conf, #val "_tls_x509_verify",        \
+                                      &cfg->val## TLSx509verify)) < 0)      \
+            goto cleanup;                                                   \
+        if (rv == 0)                                                        \
+            cfg->val## TLSx509verify = cfg->defaultTLSx509verify;           \
+        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;                                                   \
+        if (!cfg->val## TLSx509secretUUID &&                                \
+            cfg->defaultTLSx509secretUUID) {                                \
+            if (VIR_STRDUP(cfg->val## TLSx509secretUUID,                    \
+                           cfg->defaultTLSx509secretUUID) < 0)              \
+                goto cleanup;                                               \
+        }                                                                   \
+    } while (false);
+
+    GET_CONFIG_TLS_CERT(chardev);
+
+#undef GET_CONFIG_TLS_CERT
 
     if (virConfGetValueUInt(conf, "remote_websocket_port_min", &cfg->webSocketPortMin) < 0)
         goto cleanup;
-- 
2.9.3

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