[PATCH 06/24] virQEMUDriverConfigLoadSpecificTLSEntry: Split up fetching of server-only config options

Peter Krempa posted 24 patches 5 years, 7 months ago
[PATCH 06/24] virQEMUDriverConfigLoadSpecificTLSEntry: Split up fetching of server-only config options
Posted by Peter Krempa 5 years, 7 months ago
The '*_tls_x509_verify' options are relevant only when we are going to
expose a server socket as client sockets always enable verification.

Split up the macro to separate the common bits from the server bits so
that when we'll later extend support of 'nbd' and 'vxhs' disks which are
client only we can reuse the existing macros.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_conf.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2cbff1348a..b9b90e853f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -486,13 +486,8 @@ virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
     if (virConfGetValueBool(conf, "chardev_tls", &cfg->chardevTLS) < 0)
         return -1;

-#define GET_CONFIG_TLS_CERTINFO(val) \
+#define GET_CONFIG_TLS_CERTINFO_COMMON(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; \
@@ -502,11 +497,23 @@ virQEMUDriverConfigLoadSpecificTLSEntry(virQEMUDriverConfigPtr cfg,
             return -1; \
     } while (0)

-    GET_CONFIG_TLS_CERTINFO(chardev);
+#define GET_CONFIG_TLS_CERTINFO_SERVER(val) \
+    do { \
+        if ((rv = virConfGetValueBool(conf, #val "_tls_x509_verify", \
+                                      &cfg->val## TLSx509verify)) < 0) \
+            return -1; \
+        if (rv == 1) \
+            cfg->val## TLSx509verifyPresent = true; \
+    } while (0)
+
+    GET_CONFIG_TLS_CERTINFO_COMMON(chardev);
+    GET_CONFIG_TLS_CERTINFO_SERVER(chardev);

-    GET_CONFIG_TLS_CERTINFO(migrate);
+    GET_CONFIG_TLS_CERTINFO_COMMON(migrate);
+    GET_CONFIG_TLS_CERTINFO_SERVER(migrate);

-#undef GET_CONFIG_TLS_CERTINFO
+#undef GET_CONFIG_TLS_CERTINFO_COMMON
+#undef GET_CONFIG_TLS_CERTINFO_SERVER
     return 0;
 }

-- 
2.26.2

Re: [PATCH 06/24] virQEMUDriverConfigLoadSpecificTLSEntry: Split up fetching of server-only config options
Posted by Eric Blake 5 years, 7 months ago
On 7/2/20 9:39 AM, Peter Krempa wrote:
> The '*_tls_x509_verify' options are relevant only when we are going to
> expose a server socket as client sockets always enable verification.
> 
> Split up the macro to separate the common bits from the server bits so
> that when we'll later extend support of 'nbd' and 'vxhs' disks which are
> client only we can reuse the existing macros.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/qemu/qemu_conf.c | 25 ++++++++++++++++---------
>   1 file changed, 16 insertions(+), 9 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org