From nobody Mon Feb 9 17:57:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619020397; cv=none; d=zohomail.com; s=zohoarc; b=lQnxrHkkq+IZtxNb9p/zv9wgSxladbtSa9c7rJLuMmGhcjxuYrEQvPZqsKp0S4VAQdLLwzAhjO8CN5b/L1RqUltCAjSqrR/XMk5b1bBRs0KwOv9Wmw61smB50CWzbbQNKupM7hd8+fKljoIX+n0hGSc4QuHmVqs+ONpe5p4at88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619020397; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kCLL2qPcO6P2kpA12WDOsDrEmPKpcoS2b9cCsfip1u0=; b=aCOaa9Eel96VtB1jU/WIVlI1+s9DVGKnfGtcYq4nHvH9sOiC/FDCwj2WDbzwrFgya73KK9PSCvIvwu0H5eyVmGsaiCQTcwhLDcuNdf4MkKyw4eZOd81lUSj3pFfI6TTpn0AX4188E1vo3HmEF8ifouTHJKzrUJDewaHgYS3m0yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1619020397613754.1254478313491; Wed, 21 Apr 2021 08:53:17 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-Kh1exgTSP4OCssVpL8zYhA-1; Wed, 21 Apr 2021 11:52:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA0EA83DD5A; Wed, 21 Apr 2021 15:52:01 +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 7D91919D80; Wed, 21 Apr 2021 15:52:01 +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 44DBB9964; Wed, 21 Apr 2021 15:52:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LFpncs006948 for ; Wed, 21 Apr 2021 11:51:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 041821017CF5; Wed, 21 Apr 2021 15:51:49 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49E0A10016DB; Wed, 21 Apr 2021 15:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619020396; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kCLL2qPcO6P2kpA12WDOsDrEmPKpcoS2b9cCsfip1u0=; b=JiN1pM1C/ggBaNuT0mLSKCQeP/vsWr+xA3odpLcHCLS66VOlJu7F0IYJf1O+koSqgxi+Oh k4Z9+w08AFOAWYBA8xrlz+dFB1S+by2ObKMCxylZ6+zNsMXe6t93IxBEFNC8mmXafpu7oZ lRX+ahKIG/d3AZK63qdJkIqGSCLtGug= X-MC-Unique: Kh1exgTSP4OCssVpL8zYhA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] virDomainDiskSourceNetworkParse: Use virXMLProp* Date: Wed, 21 Apr 2021 17:51:32 +0200 Message-Id: <20210421155133.162030-10-twiederh@redhat.com> In-Reply-To: <20210421155133.162030-1-twiederh@redhat.com> References: <20210421155133.162030-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/domain_conf.c | 55 ++++++++++++------------------------------ 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 367258bf7a..113f4123d7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8273,24 +8273,14 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virStorageSource *src, unsigned int flags) { - int tlsCfgVal; - g_autofree char *protocol =3D NULL; - g_autofree char *haveTLS =3D NULL; - g_autofree char *tlsCfg =3D NULL; - g_autofree char *sslverifystr =3D NULL; + virStorageNetProtocol protocol; xmlNodePtr tmpnode; =20 - if (!(protocol =3D virXMLPropString(node, "protocol"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing network source protocol type")); + if (virXMLPropEnum(node, "protocol", virStorageNetProtocolTypeFromStri= ng, + VIR_XML_PROP_REQUIRED, &protocol) < 0) return -1; - } =20 - if ((src->protocol =3D virStorageNetProtocolTypeFromString(protocol)) = <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown protocol type '%s'"), protocol); - return -1; - } + src->protocol =3D protocol; =20 if (!(src->path =3D virXMLPropString(node, "name")) && src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_NBD) { @@ -8299,26 +8289,16 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, return -1; } =20 - if ((haveTLS =3D virXMLPropString(node, "tls"))) { - int value; - - if ((value =3D virTristateBoolTypeFromString(haveTLS)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown disk source 'tls' setting '%s'"), ha= veTLS); - return -1; - } - src->haveTLS =3D value; - } + if (virXMLPropTristateBool(node, "tls", VIR_XML_PROP_NONE, + &src->haveTLS) < 0) + return -1; =20 - if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - (tlsCfg =3D virXMLPropString(node, "tlsFromConfig"))) { - if (virStrToLong_i(tlsCfg, NULL, 10, &tlsCfgVal) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid tlsFromConfig value: %s"), - tlsCfg); + if (flags & VIR_DOMAIN_DEF_PARSE_STATUS) { + int value; + if (virXMLPropInt(node, "tlsFromConfig", 10, VIR_XML_PROP_NONE, + &value) < 0) return -1; - } - src->tlsFromConfig =3D !!tlsCfgVal; + src->tlsFromConfig =3D !!value; } =20 /* for historical reasons we store the volume and image name in one XML @@ -8364,15 +8344,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, =20 if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_HTTPS || src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_FTPS) && - (sslverifystr =3D virXPathString("string(./ssl/@verify)", ctxt))) { - int verify; - if ((verify =3D virTristateBoolTypeFromString(sslverifystr)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid ssl verify mode '%s'"), sslverifystr= ); + (tmpnode =3D virXPathNode("./ssl", ctxt))) { + if (virXMLPropTristateBool(tmpnode, "verify", VIR_XML_PROP_NONE, + &src->sslverify) < 0) return -1; - } - - src->sslverify =3D verify; } =20 if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_HTTP || --=20 2.26.3