From nobody Fri May 3 00:07:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498678240331803.7269077402366; Wed, 28 Jun 2017 12:30:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62A671555A; Wed, 28 Jun 2017 19:30:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74911756A5; Wed, 28 Jun 2017 19:30:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F3BCE41F63; Wed, 28 Jun 2017 19:30:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5SJUXRl003480 for ; Wed, 28 Jun 2017 15:30:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 521EF5DC1D; Wed, 28 Jun 2017 19:30:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-36.phx2.redhat.com [10.3.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0501917D14 for ; Wed, 28 Jun 2017 19:30:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 62A671555A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 62A671555A From: John Ferlan To: libvir-list@redhat.com Date: Wed, 28 Jun 2017 15:30:27 -0400 Message-Id: <20170628193028.5256-2-jferlan@redhat.com> In-Reply-To: <20170628193028.5256-1-jferlan@redhat.com> References: <20170628193028.5256-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Clean up long lines in virQEMUDriverConfigLoadFile X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 28 Jun 2017 19:30:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Keep line length <=3D 80 cols. Signed-off-by: John Ferlan --- src/qemu/qemu_conf.c | 93 ++++++++++++++++++++++++++++++++++--------------= ---- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 73c33d6..94e00b2 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -467,23 +467,28 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPt= r cfg, if (!(conf =3D virConfReadFile(filename, 0))) goto cleanup; =20 - if (virConfGetValueString(conf, "default_tls_x509_cert_dir", &cfg->def= aultTLSx509certdir) < 0) + if (virConfGetValueString(conf, "default_tls_x509_cert_dir", + &cfg->defaultTLSx509certdir) < 0) goto cleanup; - if (virConfGetValueBool(conf, "default_tls_x509_verify", &cfg->default= TLSx509verify) < 0) + if (virConfGetValueBool(conf, "default_tls_x509_verify", + &cfg->defaultTLSx509verify) < 0) goto cleanup; if (virConfGetValueString(conf, "default_tls_x509_secret_uuid", &cfg->defaultTLSx509secretUUID) < 0) goto cleanup; =20 - if (virConfGetValueBool(conf, "vnc_auto_unix_socket", &cfg->vncAutoUni= xSocket) < 0) + if (virConfGetValueBool(conf, "vnc_auto_unix_socket", + &cfg->vncAutoUnixSocket) < 0) goto cleanup; if (virConfGetValueBool(conf, "vnc_tls", &cfg->vncTLS) < 0) goto cleanup; - if ((rv =3D virConfGetValueBool(conf, "vnc_tls_x509_verify", &cfg->vnc= TLSx509verify)) < 0) + if ((rv =3D virConfGetValueBool(conf, "vnc_tls_x509_verify", + &cfg->vncTLSx509verify)) < 0) goto cleanup; if (rv =3D=3D 0) cfg->vncTLSx509verify =3D cfg->defaultTLSx509verify; - if (virConfGetValueString(conf, "vnc_tls_x509_cert_dir", &cfg->vncTLSx= 509certdir) < 0) + if (virConfGetValueString(conf, "vnc_tls_x509_cert_dir", + &cfg->vncTLSx509certdir) < 0) goto cleanup; if (virConfGetValueString(conf, "vnc_listen", &cfg->vncListen) < 0) goto cleanup; @@ -493,16 +498,20 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPt= r cfg, goto cleanup; if (virConfGetValueString(conf, "vnc_sasl_dir", &cfg->vncSASLdir) < 0) goto cleanup; - if (virConfGetValueBool(conf, "vnc_allow_host_audio", &cfg->vncAllowHo= stAudio) < 0) + if (virConfGetValueBool(conf, "vnc_allow_host_audio", + &cfg->vncAllowHostAudio) < 0) goto cleanup; - if (virConfGetValueBool(conf, "nographics_allow_host_audio", &cfg->nog= fxAllowHostAudio) < 0) + if (virConfGetValueBool(conf, "nographics_allow_host_audio", + &cfg->nogfxAllowHostAudio) < 0) goto cleanup; =20 =20 - if (virConfGetValueStringList(conf, "security_driver", true, &cfg->sec= urityDriverNames) < 0) + if (virConfGetValueStringList(conf, "security_driver", true, + &cfg->securityDriverNames) < 0) goto cleanup; =20 - for (i =3D 0; cfg->securityDriverNames && cfg->securityDriverNames[i] = !=3D NULL; i++) { + for (i =3D 0; + cfg->securityDriverNames && cfg->securityDriverNames[i] !=3D NULL= ; i++) { for (j =3D i + 1; cfg->securityDriverNames[j] !=3D NULL; j++) { if (STREQ(cfg->securityDriverNames[i], cfg->securityDriverNames[j])) { @@ -514,14 +523,17 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPt= r cfg, } } =20 - if (virConfGetValueBool(conf, "security_default_confined", &cfg->secur= ityDefaultConfined) < 0) + if (virConfGetValueBool(conf, "security_default_confined", + &cfg->securityDefaultConfined) < 0) goto cleanup; - if (virConfGetValueBool(conf, "security_require_confined", &cfg->secur= ityRequireConfined) < 0) + if (virConfGetValueBool(conf, "security_require_confined", + &cfg->securityRequireConfined) < 0) goto cleanup; =20 if (virConfGetValueBool(conf, "spice_tls", &cfg->spiceTLS) < 0) goto cleanup; - if (virConfGetValueString(conf, "spice_tls_x509_cert_dir", &cfg->spice= TLSx509certdir) < 0) + if (virConfGetValueString(conf, "spice_tls_x509_cert_dir", + &cfg->spiceTLSx509certdir) < 0) goto cleanup; if (virConfGetValueBool(conf, "spice_sasl", &cfg->spiceSASL) < 0) goto cleanup; @@ -531,7 +543,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; if (virConfGetValueString(conf, "spice_password", &cfg->spicePassword)= < 0) goto cleanup; - if (virConfGetValueBool(conf, "spice_auto_unix_socket", &cfg->spiceAut= oUnixSocket) < 0) + if (virConfGetValueBool(conf, "spice_auto_unix_socket", + &cfg->spiceAutoUnixSocket) < 0) goto cleanup; =20 #define GET_CONFIG_TLS_CERTINFO(val) = \ @@ -564,7 +577,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, =20 #undef GET_CONFIG_TLS_CERTINFO =20 - if (virConfGetValueUInt(conf, "remote_websocket_port_min", &cfg->webSo= cketPortMin) < 0) + if (virConfGetValueUInt(conf, "remote_websocket_port_min", + &cfg->webSocketPortMin) < 0) goto cleanup; if (cfg->webSocketPortMin < QEMU_WEBSOCKET_PORT_MIN) { /* if the port is too low, we can't get the display name @@ -577,7 +591,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; } =20 - if (virConfGetValueUInt(conf, "remote_websocket_port_max", &cfg->webSo= cketPortMax) < 0) + if (virConfGetValueUInt(conf, "remote_websocket_port_max", + &cfg->webSocketPortMax) < 0) goto cleanup; if (cfg->webSocketPortMax > QEMU_WEBSOCKET_PORT_MAX || cfg->webSocketPortMax < cfg->webSocketPortMin) { @@ -595,7 +610,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; } =20 - if (virConfGetValueUInt(conf, "remote_display_port_min", &cfg->remoteP= ortMin) < 0) + if (virConfGetValueUInt(conf, "remote_display_port_min", + &cfg->remotePortMin) < 0) goto cleanup; if (cfg->remotePortMin < QEMU_REMOTE_PORT_MIN) { /* if the port is too low, we can't get the display name @@ -608,7 +624,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; } =20 - if (virConfGetValueUInt(conf, "remote_display_port_max", &cfg->remoteP= ortMax) < 0) + if (virConfGetValueUInt(conf, "remote_display_port_max", + &cfg->remotePortMax) < 0) goto cleanup; if (cfg->remotePortMax > QEMU_REMOTE_PORT_MAX || cfg->remotePortMax < cfg->remotePortMin) { @@ -626,7 +643,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; } =20 - if (virConfGetValueUInt(conf, "migration_port_min", &cfg->migrationPor= tMin) < 0) + if (virConfGetValueUInt(conf, "migration_port_min", + &cfg->migrationPortMin) < 0) goto cleanup; if (cfg->migrationPortMin <=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -635,7 +653,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; } =20 - if (virConfGetValueUInt(conf, "migration_port_max", &cfg->migrationPor= tMax) < 0) + if (virConfGetValueUInt(conf, "migration_port_max", + &cfg->migrationPortMax) < 0) goto cleanup; if (cfg->migrationPortMax > 65535 || cfg->migrationPortMax < cfg->migrationPortMin) { @@ -656,7 +675,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, if (group && virGetGroupID(group, &cfg->group) < 0) goto cleanup; =20 - if (virConfGetValueBool(conf, "dynamic_ownership", &cfg->dynamicOwners= hip) < 0) + if (virConfGetValueBool(conf, "dynamic_ownership", + &cfg->dynamicOwnership) < 0) goto cleanup; =20 if (virConfGetValueStringList(conf, "cgroup_controllers", false, @@ -681,18 +701,23 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPt= r cfg, &cfg->cgroupDeviceACL) < 0) goto cleanup; =20 - if (virConfGetValueString(conf, "save_image_format", &cfg->saveImageFo= rmat) < 0) + if (virConfGetValueString(conf, "save_image_format", + &cfg->saveImageFormat) < 0) goto cleanup; - if (virConfGetValueString(conf, "dump_image_format", &cfg->dumpImageFo= rmat) < 0) + if (virConfGetValueString(conf, "dump_image_format", + &cfg->dumpImageFormat) < 0) goto cleanup; - if (virConfGetValueString(conf, "snapshot_image_format", &cfg->snapsho= tImageFormat) < 0) + if (virConfGetValueString(conf, "snapshot_image_format", + &cfg->snapshotImageFormat) < 0) goto cleanup; =20 if (virConfGetValueString(conf, "auto_dump_path", &cfg->autoDumpPath) = < 0) goto cleanup; - if (virConfGetValueBool(conf, "auto_dump_bypass_cache", &cfg->autoDump= BypassCache) < 0) + if (virConfGetValueBool(conf, "auto_dump_bypass_cache", + &cfg->autoDumpBypassCache) < 0) goto cleanup; - if (virConfGetValueBool(conf, "auto_start_bypass_cache", &cfg->autoSta= rtBypassCache) < 0) + if (virConfGetValueBool(conf, "auto_start_bypass_cache", + &cfg->autoStartBypassCache) < 0) goto cleanup; =20 if (virConfGetValueStringList(conf, "hugetlbfs_mount", true, @@ -718,7 +743,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, } } =20 - if (virConfGetValueString(conf, "bridge_helper", &cfg->bridgeHelperNam= e) < 0) + if (virConfGetValueString(conf, "bridge_helper", + &cfg->bridgeHelperName) < 0) goto cleanup; =20 if (virConfGetValueBool(conf, "mac_filter", &cfg->macFilter) < 0) @@ -726,9 +752,11 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr= cfg, =20 if (virConfGetValueBool(conf, "relaxed_acs_check", &cfg->relaxedACS) <= 0) goto cleanup; - if (virConfGetValueBool(conf, "clear_emulator_capabilities", &cfg->cle= arEmulatorCapabilities) < 0) + if (virConfGetValueBool(conf, "clear_emulator_capabilities", + &cfg->clearEmulatorCapabilities) < 0) goto cleanup; - if (virConfGetValueBool(conf, "allow_disk_format_probing", &cfg->allow= DiskFormatProbing) < 0) + if (virConfGetValueBool(conf, "allow_disk_format_probing", + &cfg->allowDiskFormatProbing) < 0) goto cleanup; if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName= ) < 0) goto cleanup; @@ -777,7 +805,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, if (virConfGetValueUInt(conf, "max_queued", &cfg->maxQueuedJobs) < 0) goto cleanup; =20 - if (virConfGetValueInt(conf, "keepalive_interval", &cfg->keepAliveInte= rval) < 0) + if (virConfGetValueInt(conf, "keepalive_interval", + &cfg->keepAliveInterval) < 0) goto cleanup; if (virConfGetValueUInt(conf, "keepalive_count", &cfg->keepAliveCount)= < 0) goto cleanup; @@ -830,7 +859,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; } } - if (virConfGetValueUInt(conf, "gluster_debug_level", &cfg->glusterDebu= gLevel) < 0) + if (virConfGetValueUInt(conf, "gluster_debug_level", + &cfg->glusterDebugLevel) < 0) goto cleanup; =20 if (virConfGetValueStringList(conf, "namespaces", false, &namespaces) = < 0) @@ -871,7 +901,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, } } =20 - if (virConfGetValueString(conf, "memory_backing_dir", &cfg->memoryBack= ingDir) < 0) + if (virConfGetValueString(conf, "memory_backing_dir", + &cfg->memoryBackingDir) < 0) goto cleanup; =20 ret =3D 0; --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 00:07:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498678239183379.46493610582127; Wed, 28 Jun 2017 12:30:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B725B7F6A5; Wed, 28 Jun 2017 19:30:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73D15784AF; Wed, 28 Jun 2017 19:30:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6B8D11800C89; Wed, 28 Jun 2017 19:30:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5SJUXVn003489 for ; Wed, 28 Jun 2017 15:30:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB2B75DC1D; Wed, 28 Jun 2017 19:30:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-36.phx2.redhat.com [10.3.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73C8F5DD71 for ; Wed, 28 Jun 2017 19:30:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B725B7F6A5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B725B7F6A5 From: John Ferlan To: libvir-list@redhat.com Date: Wed, 28 Jun 2017 15:30:28 -0400 Message-Id: <20170628193028.5256-3-jferlan@redhat.com> In-Reply-To: <20170628193028.5256-1-jferlan@redhat.com> References: <20170628193028.5256-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Check for existence of provided *_tls_x509_cert_dir X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Jun 2017 19:30:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1458630 Introduce virQEMUDriverConfigSetCertDir which will handle reading the qemu.conf config file specific setting for default, vnc, spice, chardev, and migrate. Then if a setting was provided, validating the existence of the directory and overwriting the default set by virQEMUDriverConfigNew. Also update the qemu.conf description for default to indicate the consequen= ces if the default directory does not exist. Signed-off-by: John Ferlan --- src/qemu/qemu.conf | 9 ++++++++- src/qemu/qemu_conf.c | 42 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index e6c0832..737fa46 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -3,7 +3,7 @@ # defaults are used. =20 # Use of TLS requires that x509 certificates be issued. The default is -# to keep them in /etc/pki/qemu. This directory must contain +# to keep them in /etc/pki/qemu. This directory must exist and contain: # # ca-cert.pem - the CA master certificate # server-cert.pem - the server certificate signed with ca-cert.pem @@ -13,6 +13,13 @@ # # dh-params.pem - the DH params configuration file # +# If the directory does not exist or does not contain the necessary files, +# QEMU domains will fail to start if they are configured to use TLS. +# +# In order to overwrite the default directory alter the following. If the +# provided directory does not exist, then the setting reverts back to the +# default /etc/pki/qemu. +# #default_tls_x509_cert_dir =3D "/etc/pki/qemu" =20 =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 94e00b2..a52349f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -440,6 +440,32 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr huget= lbfs, } =20 =20 +static int +virQEMUDriverConfigSetCertDir(virConfPtr conf, + const char *setting, + char **value) +{ + char *tlsCertDir =3D NULL; + + if (virConfGetValueString(conf, setting, &tlsCertDir) < 0) + return -1; + + if (!tlsCertDir) + return 0; + + if (!virFileExists(tlsCertDir)) { + VIR_INFO("%s, directory '%s' does not exist, retain default", + setting, tlsCertDir); + VIR_FREE(tlsCertDir); + } else { + VIR_FREE(*value); + VIR_STEAL_PTR(*value, tlsCertDir); + } + + return 0; +} + + int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, const char *filename, bool privileged) @@ -467,8 +493,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, if (!(conf =3D virConfReadFile(filename, 0))) goto cleanup; =20 - if (virConfGetValueString(conf, "default_tls_x509_cert_dir", - &cfg->defaultTLSx509certdir) < 0) + if (virQEMUDriverConfigSetCertDir(conf, "default_tls_x509_cert_dir", + &cfg->defaultTLSx509certdir) < 0) goto cleanup; if (virConfGetValueBool(conf, "default_tls_x509_verify", &cfg->defaultTLSx509verify) < 0) @@ -487,8 +513,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; if (rv =3D=3D 0) cfg->vncTLSx509verify =3D cfg->defaultTLSx509verify; - if (virConfGetValueString(conf, "vnc_tls_x509_cert_dir", - &cfg->vncTLSx509certdir) < 0) + if (virQEMUDriverConfigSetCertDir(conf, "vnc_tls_x509_cert_dir", + &cfg->vncTLSx509certdir) < 0) goto cleanup; if (virConfGetValueString(conf, "vnc_listen", &cfg->vncListen) < 0) goto cleanup; @@ -532,8 +558,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, =20 if (virConfGetValueBool(conf, "spice_tls", &cfg->spiceTLS) < 0) goto cleanup; - if (virConfGetValueString(conf, "spice_tls_x509_cert_dir", - &cfg->spiceTLSx509certdir) < 0) + if (virQEMUDriverConfigSetCertDir(conf, "spice_tls_x509_cert_dir", + &cfg->spiceTLSx509certdir) < 0) goto cleanup; if (virConfGetValueBool(conf, "spice_sasl", &cfg->spiceSASL) < 0) goto cleanup; @@ -554,8 +580,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; = \ if (rv =3D=3D 0) = \ cfg->val## TLSx509verify =3D cfg->defaultTLSx509verify; = \ - if (virConfGetValueString(conf, #val "_tls_x509_cert_dir", = \ - &cfg->val## TLSx509certdir) < 0) = \ + if (virQEMUDriverConfigSetCertDir(conf, #val "_tls_x509_cert_dir",= \ + &cfg->val## TLSx509certdir) < 0)= \ goto cleanup; = \ if (virConfGetValueString(conf, = \ #val "_tls_x509_secret_uuid", = \ --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list