[libvirt] [PATCH 20/23] qemu_conf: split out virQEMUDriverConfigLoadVNCEntry

Ján Tomko posted 23 patches 7 years ago
[libvirt] [PATCH 20/23] qemu_conf: split out virQEMUDriverConfigLoadVNCEntry
Posted by Ján Tomko 7 years ago
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 | 50 +++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 62c49c600c..7eecb3ef91 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -423,6 +423,36 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
 }
 
 
+static int
+virQEMUDriverConfigLoadVNCEntry(virQEMUDriverConfigPtr cfg,
+                                virConfPtr conf)
+{
+    int rv;
+
+    if (virConfGetValueBool(conf, "vnc_auto_unix_socket", &cfg->vncAutoUnixSocket) < 0)
+        return -1;
+    if (virConfGetValueBool(conf, "vnc_tls", &cfg->vncTLS) < 0)
+        return -1;
+    if ((rv = virConfGetValueBool(conf, "vnc_tls_x509_verify", &cfg->vncTLSx509verify)) < 0)
+        return -1;
+    if (rv == 1)
+        cfg->vncTLSx509verifyPresent = true;
+    if (virConfGetValueString(conf, "vnc_tls_x509_cert_dir", &cfg->vncTLSx509certdir) < 0)
+        return -1;
+    if (virConfGetValueString(conf, "vnc_listen", &cfg->vncListen) < 0)
+        return -1;
+    if (virConfGetValueString(conf, "vnc_password", &cfg->vncPassword) < 0)
+        return -1;
+    if (virConfGetValueBool(conf, "vnc_sasl", &cfg->vncSASL) < 0)
+        return -1;
+    if (virConfGetValueString(conf, "vnc_sasl_dir", &cfg->vncSASLdir) < 0)
+        return -1;
+    if (virConfGetValueBool(conf, "vnc_allow_host_audio", &cfg->vncAllowHostAudio) < 0)
+        return -1;
+
+    return 0;
+}
+
 static int
 virQEMUDriverConfigLoadNographicsEntry(virQEMUDriverConfigPtr cfg,
                                        virConfPtr conf)
@@ -997,25 +1027,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
                               &cfg->defaultTLSx509secretUUID) < 0)
         goto cleanup;
 
-    if (virConfGetValueBool(conf, "vnc_auto_unix_socket", &cfg->vncAutoUnixSocket) < 0)
-        goto cleanup;
-    if (virConfGetValueBool(conf, "vnc_tls", &cfg->vncTLS) < 0)
-        goto cleanup;
-    if ((rv = virConfGetValueBool(conf, "vnc_tls_x509_verify", &cfg->vncTLSx509verify)) < 0)
-        goto cleanup;
-    if (rv == 1)
-        cfg->vncTLSx509verifyPresent = true;
-    if (virConfGetValueString(conf, "vnc_tls_x509_cert_dir", &cfg->vncTLSx509certdir) < 0)
-        goto cleanup;
-    if (virConfGetValueString(conf, "vnc_listen", &cfg->vncListen) < 0)
-        goto cleanup;
-    if (virConfGetValueString(conf, "vnc_password", &cfg->vncPassword) < 0)
-        goto cleanup;
-    if (virConfGetValueBool(conf, "vnc_sasl", &cfg->vncSASL) < 0)
-        goto cleanup;
-    if (virConfGetValueString(conf, "vnc_sasl_dir", &cfg->vncSASLdir) < 0)
-        goto cleanup;
-    if (virConfGetValueBool(conf, "vnc_allow_host_audio", &cfg->vncAllowHostAudio) < 0)
+    if (virQEMUDriverConfigLoadVNCEntry(cfg, conf) < 0)
         goto cleanup;
 
     if (virQEMUDriverConfigLoadNographicsEntry(cfg, conf) < 0)
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 20/23] qemu_conf: split out virQEMUDriverConfigLoadVNCEntry
Posted by John Ferlan 7 years ago

On 1/15/19 8:23 AM, Ján Tomko wrote:
> 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 | 50 +++++++++++++++++++++++++++-----------------
>  1 file changed, 31 insertions(+), 19 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 62c49c600c..7eecb3ef91 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -423,6 +423,36 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
>  }
>  
>  
> +static int
> +virQEMUDriverConfigLoadVNCEntry(virQEMUDriverConfigPtr cfg,
> +                                virConfPtr conf)
> +{
> +    int rv;
> +
> +    if (virConfGetValueBool(conf, "vnc_auto_unix_socket", &cfg->vncAutoUnixSocket) < 0)
> +        return -1;
> +    if (virConfGetValueBool(conf, "vnc_tls", &cfg->vncTLS) < 0)
> +        return -1;
> +    if ((rv = virConfGetValueBool(conf, "vnc_tls_x509_verify", &cfg->vncTLSx509verify)) < 0)
> +        return -1;
> +    if (rv == 1)
> +        cfg->vncTLSx509verifyPresent = true;
> +    if (virConfGetValueString(conf, "vnc_tls_x509_cert_dir", &cfg->vncTLSx509certdir) < 0)
> +        return -1;
> +    if (virConfGetValueString(conf, "vnc_listen", &cfg->vncListen) < 0)
> +        return -1;
> +    if (virConfGetValueString(conf, "vnc_password", &cfg->vncPassword) < 0)
> +        return -1;
> +    if (virConfGetValueBool(conf, "vnc_sasl", &cfg->vncSASL) < 0)
> +        return -1;
> +    if (virConfGetValueString(conf, "vnc_sasl_dir", &cfg->vncSASLdir) < 0)
> +        return -1;
> +    if (virConfGetValueBool(conf, "vnc_allow_host_audio", &cfg->vncAllowHostAudio) < 0)
> +        return -1;
> +
> +    return 0;
> +}
> +

blank line

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

[...]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list