From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520951914654621.5214163680596; Tue, 13 Mar 2018 07:38:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57AA4C0528C2; Tue, 13 Mar 2018 14:38:33 +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 25FFB5C893; Tue, 13 Mar 2018 14:38:33 +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 DB2C04CA9C; Tue, 13 Mar 2018 14:38:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcLhP003366 for ; Tue, 13 Mar 2018 10:38:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C5F72166BB2; Tue, 13 Mar 2018 14:38:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C54B2166BDA; Tue, 13 Mar 2018 14:38:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:27 +0100 Message-Id: <3b2cd77696cd41e6db2b303ac688ea6ada995b47.1520951803.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/10] conf: Remove unnecessary condition from virDomainDiskSourceFormatInternal 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 13 Mar 2018 14:38:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that the function is using virXMLFormatElement we don't need to conditionally format anything, since we'll format the element according to the presence of content. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 126 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04a6ee77af..ddabc77a9b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22832,81 +22832,79 @@ virDomainDiskSourceFormatInternal(virBufferPtr bu= f, if (policy) startupPolicy =3D virDomainStartupPolicyTypeToString(policy); - if (src->path || src->nhosts > 0 || src->srcpool || startupPolicy) { - switch ((virStorageType)src->type) { - case VIR_STORAGE_TYPE_FILE: - virBufferEscapeString(&attrBuf, " file=3D'%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", start= upPolicy); - - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabel= s, - src->seclabels, flags, - skipSeclabels); - break; - - case VIR_STORAGE_TYPE_BLOCK: - virBufferEscapeString(&attrBuf, " dev=3D'%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", start= upPolicy); - - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabel= s, - src->seclabels, flags, - skipSeclabels); - break; + switch ((virStorageType)src->type) { + case VIR_STORAGE_TYPE_FILE: + virBufferEscapeString(&attrBuf, " file=3D'%s'", src->path); + virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); - case VIR_STORAGE_TYPE_DIR: - virBufferEscapeString(&attrBuf, " dir=3D'%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", start= upPolicy); - break; + virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, + src->seclabels, flags, + skipSeclabels); + break; - case VIR_STORAGE_TYPE_NETWORK: - if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf, - src, flags) < 0) - goto error; - break; + case VIR_STORAGE_TYPE_BLOCK: + virBufferEscapeString(&attrBuf, " dev=3D'%s'", src->path); + virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); - case VIR_STORAGE_TYPE_VOLUME: - if (src->srcpool) { - virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpo= ol->pool); - virBufferEscapeString(&attrBuf, " volume=3D'%s'", - src->srcpool->volume); - if (src->srcpool->mode) - virBufferAsprintf(&attrBuf, " mode=3D'%s'", - virStorageSourcePoolModeTypeToString= (src->srcpool->mode)); - } - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", start= upPolicy); + virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, + src->seclabels, flags, + skipSeclabels); + break; - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabel= s, - src->seclabels, flags, - skipSeclabels); - break; + case VIR_STORAGE_TYPE_DIR: + virBufferEscapeString(&attrBuf, " dir=3D'%s'", src->path); + virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); + break; - case VIR_STORAGE_TYPE_NONE: - case VIR_STORAGE_TYPE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk type %d"), src->type); + case VIR_STORAGE_TYPE_NETWORK: + if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf, + src, flags) < 0) goto error; + break; + + case VIR_STORAGE_TYPE_VOLUME: + if (src->srcpool) { + virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpool->= pool); + virBufferEscapeString(&attrBuf, " volume=3D'%s'", + src->srcpool->volume); + if (src->srcpool->mode) + virBufferAsprintf(&attrBuf, " mode=3D'%s'", + virStorageSourcePoolModeTypeToString(src= ->srcpool->mode)); } + virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); - /* Storage Source formatting will not carry through the blunder - * that disk source formatting had at one time to format the - * for a volume source type. The information is - * kept in the storage pool and would be overwritten anyway. - * So avoid formatting it for volumes. */ - if (src->auth && src->authInherited && - src->type !=3D VIR_STORAGE_TYPE_VOLUME) - virStorageAuthDefFormat(&childBuf, src->auth); + virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, + src->seclabels, flags, + skipSeclabels); + break; - /* If we found encryption as a child of , then format it - * as we found it. */ - if (src->encryption && src->encryptionInherited && - virStorageEncryptionFormat(&childBuf, src->encryption) < 0) - goto error; + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk type %d"), src->type); + goto error; + } - if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xm= lopt) < 0) - goto error; + /* Storage Source formatting will not carry through the blunder + * that disk source formatting had at one time to format the + * for a volume source type. The information is + * kept in the storage pool and would be overwritten anyway. + * So avoid formatting it for volumes. */ + if (src->auth && src->authInherited && + src->type !=3D VIR_STORAGE_TYPE_VOLUME) + virStorageAuthDefFormat(&childBuf, src->auth); - if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0) - goto error; - } + /* If we found encryption as a child of , then format it + * as we found it. */ + if (src->encryption && src->encryptionInherited && + virStorageEncryptionFormat(&childBuf, src->encryption) < 0) + goto error; + + if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt= ) < 0) + goto error; + + if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0) + goto error; return 0; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520951906885155.83978844995124; Tue, 13 Mar 2018 07:38:26 -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 880DBC05004D; Tue, 13 Mar 2018 14:38:25 +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 40EA560BEF; Tue, 13 Mar 2018 14:38:25 +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 D7C304CA99; Tue, 13 Mar 2018 14:38:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcLR3003376 for ; Tue, 13 Mar 2018 10:38:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB5552166BB2; Tue, 13 Mar 2018 14:38:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 660142166BDA; Tue, 13 Mar 2018 14:38:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:28 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/10] conf: Refactor seclabel formatting in virDomainDiskSourceFormatInternal 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.31]); Tue, 13 Mar 2018 14:38:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Call the formatter function only once. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ddabc77a9b..ebe1172fd2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22836,19 +22836,11 @@ virDomainDiskSourceFormatInternal(virBufferPtr bu= f, case VIR_STORAGE_TYPE_FILE: virBufferEscapeString(&attrBuf, " file=3D'%s'", src->path); virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); - - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, - src->seclabels, flags, - skipSeclabels); break; case VIR_STORAGE_TYPE_BLOCK: virBufferEscapeString(&attrBuf, " dev=3D'%s'", src->path); virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); - - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, - src->seclabels, flags, - skipSeclabels); break; case VIR_STORAGE_TYPE_DIR: @@ -22873,9 +22865,6 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, } virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, - src->seclabels, flags, - skipSeclabels); break; case VIR_STORAGE_TYPE_NONE: @@ -22885,6 +22874,12 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, goto error; } + if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) { + virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, + src->seclabels, flags, + skipSeclabels); + } + /* Storage Source formatting will not carry through the blunder * that disk source formatting had at one time to format the * for a volume source type. The information is --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520952112630687.9750974265439; Tue, 13 Mar 2018 07:41:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21D0562E9D; Tue, 13 Mar 2018 14:41:51 +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 8ADF817D79; Tue, 13 Mar 2018 14:41:50 +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 10BA9181B9FE; Tue, 13 Mar 2018 14:41:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcMwl003388 for ; Tue, 13 Mar 2018 10:38:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 977BC2166BB2; Tue, 13 Mar 2018 14:38:22 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20FA72166BDA; Tue, 13 Mar 2018 14:38:22 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:29 +0100 Message-Id: <127fc1843286b007a6719d2dc347dce0596f54f5.1520951803.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/10] conf: Remove virDomainDiskSourceDefFormatSeclabel 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 13 Mar 2018 14:41:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The wrapper functionality can be moved to the only user virDomainDiskSourceFormatInternal. Also removes comment which does not reflect the truth any more. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ebe1172fd2..4aa66fe09c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22704,33 +22704,16 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf, } -/* virDomainSourceDefFormatSeclabel: - * - * This function automatically closes the element and formats any - * possible seclabels. - */ -static void -virDomainDiskSourceDefFormatSeclabel(virBufferPtr buf, - size_t nseclabels, - virSecurityDeviceLabelDefPtr *seclabe= ls, - unsigned int flags, - bool skipSeclables) -{ - size_t n; - - if (nseclabels && !skipSeclables) { - for (n =3D 0; n < nseclabels; n++) - virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags); - } -} - static void virDomainSourceDefFormatSeclabel(virBufferPtr buf, size_t nseclabels, virSecurityDeviceLabelDefPtr *seclabels, unsigned int flags) { - virDomainDiskSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags= , false); + size_t n; + + for (n =3D 0; n < nseclabels; n++) + virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags); } @@ -22875,9 +22858,9 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, } if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) { - virDomainDiskSourceDefFormatSeclabel(&childBuf, src->nseclabels, - src->seclabels, flags, - skipSeclabels); + if (!skipSeclabels) + virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, + src->seclabels, flags); } /* Storage Source formatting will not carry through the blunder --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520951914838833.592175206608; Tue, 13 Mar 2018 07:38:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7461A51F1D; Tue, 13 Mar 2018 14:38:33 +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 43DE45D6A6; Tue, 13 Mar 2018 14:38:33 +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 03F08181BA01; Tue, 13 Mar 2018 14:38:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcNGd003395 for ; Tue, 13 Mar 2018 10:38:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52C7C2166BB2; Tue, 13 Mar 2018 14:38:23 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D10092166BDA; Tue, 13 Mar 2018 14:38:22 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:30 +0100 Message-Id: <14fdf5f952d9b4bbd02c3d9943128c009fd86d22.1520951803.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/10] conf: Refactor formatting of startupPolicy in virDomainDiskSourceFormatInternal 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 13 Mar 2018 14:38:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move it to a single location which also allows to get rid of the temporrary variable. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4aa66fe09c..b77cc8ed9f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22806,29 +22806,22 @@ virDomainDiskSourceFormatInternal(virBufferPtr bu= f, bool skipSeclabels, virDomainXMLOptionPtr xmlopt) { - const char *startupPolicy =3D NULL; virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; virBufferSetChildIndent(&childBuf, buf); - if (policy) - startupPolicy =3D virDomainStartupPolicyTypeToString(policy); - switch ((virStorageType)src->type) { case VIR_STORAGE_TYPE_FILE: virBufferEscapeString(&attrBuf, " file=3D'%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); break; case VIR_STORAGE_TYPE_BLOCK: virBufferEscapeString(&attrBuf, " dev=3D'%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); break; case VIR_STORAGE_TYPE_DIR: virBufferEscapeString(&attrBuf, " dir=3D'%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); break; case VIR_STORAGE_TYPE_NETWORK: @@ -22846,7 +22839,6 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, virBufferAsprintf(&attrBuf, " mode=3D'%s'", virStorageSourcePoolModeTypeToString(src= ->srcpool->mode)); } - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", startupPo= licy); break; @@ -22858,6 +22850,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, } if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) { + if (policy) + virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", + virDomainStartupPolicyTypeToString(polic= y)); + if (!skipSeclabels) virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, src->seclabels, flags); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520952118628209.29326498580292; Tue, 13 Mar 2018 07:41:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17E71804E2; Tue, 13 Mar 2018 14:41:57 +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 C4B4C5E1D8; Tue, 13 Mar 2018 14:41:56 +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 4F9654CA9A; Tue, 13 Mar 2018 14:41:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcO0e003403 for ; Tue, 13 Mar 2018 10:38:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E0E92166BB2; Tue, 13 Mar 2018 14:38:24 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C54B2166BDA; Tue, 13 Mar 2018 14:38:23 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:31 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/10] conf: disk: Separate virStorageSource formatting 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 13 Mar 2018 14:41:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move out formatting of 'startuPolicy' which is a property of the disk out of the element. Extracting the code formating the content and attributes will also allow reuse in other parts of the code. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 90 ++++++++++++++++++++++++++++----------------= ---- src/conf/domain_conf.h | 7 ++++ src/libvirt_private.syms | 1 + 3 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b77cc8ed9f..1c79d2b49b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22798,45 +22798,39 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr= buf, } -static int -virDomainDiskSourceFormatInternal(virBufferPtr buf, - virStorageSourcePtr src, - int policy, - unsigned int flags, - bool skipSeclabels, - virDomainXMLOptionPtr xmlopt) +int +virDomainStorageSourceFormat(virBufferPtr attrBuf, + virBufferPtr childBuf, + virStorageSourcePtr src, + unsigned int flags, + bool skipSeclabels) { - virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; - virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; - - virBufferSetChildIndent(&childBuf, buf); - switch ((virStorageType)src->type) { case VIR_STORAGE_TYPE_FILE: - virBufferEscapeString(&attrBuf, " file=3D'%s'", src->path); + virBufferEscapeString(attrBuf, " file=3D'%s'", src->path); break; case VIR_STORAGE_TYPE_BLOCK: - virBufferEscapeString(&attrBuf, " dev=3D'%s'", src->path); + virBufferEscapeString(attrBuf, " dev=3D'%s'", src->path); break; case VIR_STORAGE_TYPE_DIR: - virBufferEscapeString(&attrBuf, " dir=3D'%s'", src->path); + virBufferEscapeString(attrBuf, " dir=3D'%s'", src->path); break; case VIR_STORAGE_TYPE_NETWORK: - if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf, + if (virDomainDiskSourceFormatNetwork(attrBuf, childBuf, src, flags) < 0) - goto error; + return -1; break; case VIR_STORAGE_TYPE_VOLUME: if (src->srcpool) { - virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpool->= pool); - virBufferEscapeString(&attrBuf, " volume=3D'%s'", + virBufferEscapeString(attrBuf, " pool=3D'%s'", src->srcpool->p= ool); + virBufferEscapeString(attrBuf, " volume=3D'%s'", src->srcpool->volume); if (src->srcpool->mode) - virBufferAsprintf(&attrBuf, " mode=3D'%s'", + virBufferAsprintf(attrBuf, " mode=3D'%s'", virStorageSourcePoolModeTypeToString(src= ->srcpool->mode)); } @@ -22846,18 +22840,12 @@ virDomainDiskSourceFormatInternal(virBufferPtr bu= f, case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %d"), src->type); - goto error; + return -1; } - if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) { - if (policy) - virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", - virDomainStartupPolicyTypeToString(polic= y)); - - if (!skipSeclabels) - virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, - src->seclabels, flags); - } + if (!skipSeclabels && src->type !=3D VIR_STORAGE_TYPE_NETWORK) + virDomainSourceDefFormatSeclabel(childBuf, src->nseclabels, + src->seclabels, flags); /* Storage Source formatting will not carry through the blunder * that disk source formatting had at one time to format the @@ -22866,26 +22854,52 @@ virDomainDiskSourceFormatInternal(virBufferPtr bu= f, * So avoid formatting it for volumes. */ if (src->auth && src->authInherited && src->type !=3D VIR_STORAGE_TYPE_VOLUME) - virStorageAuthDefFormat(&childBuf, src->auth); + virStorageAuthDefFormat(childBuf, src->auth); /* If we found encryption as a child of , then format it * as we found it. */ if (src->encryption && src->encryptionInherited && - virStorageEncryptionFormat(&childBuf, src->encryption) < 0) - goto error; + virStorageEncryptionFormat(childBuf, src->encryption) < 0) + return -1; + + return 0; +} + + +static int +virDomainDiskSourceFormatInternal(virBufferPtr buf, + virStorageSourcePtr src, + int policy, + unsigned int flags, + bool skipSeclabels, + virDomainXMLOptionPtr xmlopt) +{ + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; + int ret =3D -1; + + virBufferSetChildIndent(&childBuf, buf); + + if (virDomainStorageSourceFormat(&attrBuf, &childBuf, src, flags, + skipSeclabels) < 0) + goto cleanup; + + if (policy && src->type !=3D VIR_STORAGE_TYPE_NETWORK) + virBufferEscapeString(&attrBuf, " startupPolicy=3D'%s'", + virDomainStartupPolicyTypeToString(policy)); if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt= ) < 0) - goto error; + goto cleanup; if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0) - goto error; + goto cleanup; - return 0; + ret =3D 0; - error: + cleanup: virBufferFreeAndReset(&attrBuf); virBufferFreeAndReset(&childBuf); - return -1; + return ret; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 337ce79425..61379e50fe 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3427,6 +3427,13 @@ int virDomainDiskDefCheckDuplicateInfo(const virDoma= inDiskDef *a, const virDomainDiskDef *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int virDomainStorageSourceFormat(virBufferPtr attrBuf, + virBufferPtr childBuf, + virStorageSourcePtr src, + unsigned int flags, + bool skipSeclabels) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, int maplen, int ncpumaps, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3766e20d3b..c67bce7389 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -542,6 +542,7 @@ virDomainStateReasonFromString; virDomainStateReasonToString; virDomainStateTypeFromString; virDomainStateTypeToString; +virDomainStorageSourceFormat; virDomainTaintTypeFromString; virDomainTaintTypeToString; virDomainTimerModeTypeFromString; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520951977142400.8425234338; Tue, 13 Mar 2018 07:39:37 -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 7A89761BB2; Tue, 13 Mar 2018 14:39:35 +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 359D39C4E0; Tue, 13 Mar 2018 14:39:35 +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 DA3A81806103; Tue, 13 Mar 2018 14:39:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcOHU003412 for ; Tue, 13 Mar 2018 10:38:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD0A12166BAE; Tue, 13 Mar 2018 14:38:24 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 476252166BDA; Tue, 13 Mar 2018 14:38:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:32 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/10] conf: Validate disk source configuration also for the backing store 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.39]); Tue, 13 Mar 2018 14:39:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we already parse the of a disk source, we should also validate the configuration for the whole backing chain and not only for the top level image. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1c79d2b49b..8cd41edb5e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8974,6 +8974,8 @@ virDomainDiskSourceDefParseAuthValidate(const virStor= ageSource *src) static int virDomainDiskDefParseValidate(const virDomainDiskDef *def) { + virStorageSourcePtr next; + if (def->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { if (def->event_idx !=3D VIR_TRISTATE_SWITCH_ABSENT) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -9044,19 +9046,21 @@ virDomainDiskDefParseValidate(const virDomainDiskDe= f *def) } } - if (virDomainDiskSourceDefParseAuthValidate(def->src) < 0) - return -1; + for (next =3D def->src; next; next =3D next->backingStore) { + if (virDomainDiskSourceDefParseAuthValidate(next) < 0) + return -1; - if (def->src->encryption) { - virStorageEncryptionPtr encryption =3D def->src->encryption; + if (next->encryption) { + virStorageEncryptionPtr encryption =3D next->encryption; - if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && - encryption->encinfo.cipher_name) { + if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LU= KS && + encryption->encinfo.cipher_name) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("supplying for domain disk definitio= n " - "is unnecessary")); - return -1; + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("supplying for domain disk defin= ition " + "is unnecessary")); + return -1; + } } } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520952167844875.1299345076746; Tue, 13 Mar 2018 07:42:47 -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 6D0C1C04C273; Tue, 13 Mar 2018 14:42:46 +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 EB6BF89E80; Tue, 13 Mar 2018 14:42:45 +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 1A1EC4CA9C; Tue, 13 Mar 2018 14:42:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcPuQ003422 for ; Tue, 13 Mar 2018 10:38:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 77D752166BAE; Tue, 13 Mar 2018 14:38:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02A9A2166BDA; Tue, 13 Mar 2018 14:38:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:33 +0100 Message-Id: <3fa0ca51264bed70191c62ebe3cb27e62066046b.1520951803.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/10] conf: Separate seclabel validation from parsing 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.32]); Tue, 13 Mar 2018 14:42:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than checking that the security label is legal when parsing it move the code into a separate function. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 68 ++++++++++++++++++++++++++++++++--------------= ---- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8cd41edb5e..6c2a2f3a75 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8214,8 +8214,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, static int virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels= _rtn, size_t *nseclabels_rtn, - virSecurityLabelDefPtr *vmSeclabels, - int nvmSeclabels, xmlXPathContextPtr ctx= t, + xmlXPathContextPtr ctxt, unsigned int flags) { virSecurityDeviceLabelDefPtr *seclabels =3D NULL; @@ -8223,7 +8222,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLa= belDefPtr **seclabels_rtn, int n; size_t i, j; xmlNodePtr *list =3D NULL; - virSecurityLabelDefPtr vmDef =3D NULL; char *model, *relabel, *label, *labelskip; if ((n =3D virXPathNodeSet("./seclabel", ctxt, &list)) < 0) @@ -8243,14 +8241,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDefPtr **seclabels_rtn, /* get model associated to this override */ model =3D virXMLPropString(list[i], "model"); if (model) { - /* find the security label that it's being overridden */ - for (j =3D 0; j < nvmSeclabels; j++) { - if (STREQ(vmSeclabels[j]->model, model)) { - vmDef =3D vmSeclabels[j]; - break; - } - } - /* check for duplicate seclabels */ for (j =3D 0; j < i; j++) { if (STREQ_NULLABLE(model, seclabels[j]->model)) { @@ -8262,14 +8252,6 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDefPtr **seclabels_rtn, seclabels[i]->model =3D model; } - /* Can't use overrides if top-level doesn't allow relabeling. */ - if (vmDef && !vmDef->relabel) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("label overrides require relabeling to be " - "enabled at the domain level")); - goto error; - } - relabel =3D virXMLPropString(list[i], "relabel"); if (relabel !=3D NULL) { if (STREQ(relabel, "yes")) { @@ -8324,6 +8306,37 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceL= abelDefPtr **seclabels_rtn, } +static int +virSecurityDeviceLabelDefValidateXML(virSecurityDeviceLabelDefPtr *seclabe= ls, + size_t nseclabels, + virSecurityLabelDefPtr *vmSeclabels, + size_t nvmSeclabels) +{ + virSecurityDeviceLabelDefPtr seclabel; + size_t i; + size_t j; + + for (i =3D 0; i < nseclabels; i++) { + seclabel =3D seclabels[i]; + + /* find the security label that it's being overridden */ + for (j =3D 0; j < nvmSeclabels; j++) { + if (STRNEQ_NULLABLE(vmSeclabels[j]->model, seclabel->model)) + continue; + + if (!vmSeclabels[j]->relabel) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("label overrides require relabeling to be= " + "enabled at the domain level")); + return -1; + } + } + } + + return 0; +} + + /* Parse the XML definition for a lease */ static virDomainLeaseDefPtr @@ -9453,11 +9466,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, ctxt->node =3D sourceNode; if (virSecurityDeviceLabelDefParseXML(&def->src->seclabels, &def->src->nseclabels, - vmSeclabels, - nvmSeclabels, ctxt, flags) < 0) goto error; + + if (virSecurityDeviceLabelDefValidateXML(def->src->seclabels, + def->src->nseclabels, + vmSeclabels, + nvmSeclabels) < 0) + goto error; + ctxt->node =3D saved_node; } @@ -12133,10 +12151,12 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, ctxt->node =3D cur; if (virSecurityDeviceLabelDefParseXML(&def->seclabels, &def->nseclabels, - vmSeclabels, - nvmSeclabels, ctxt, - flags) < 0) { + flags) < 0 || + virSecurityDeviceLabelDefValidateXML(def->seclabels, + def->nseclabels, + vmSeclabels, + nvmSeclabels) < 0= ) { ctxt->node =3D saved_node; goto error; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152095198373355.33837777879671; Tue, 13 Mar 2018 07:39:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D32C13A41; Tue, 13 Mar 2018 14:39:42 +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 424EC96565; Tue, 13 Mar 2018 14:39:42 +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 E8E4B4CA99; Tue, 13 Mar 2018 14:39:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcQmY003434 for ; Tue, 13 Mar 2018 10:38:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33BA12166BB2; Tue, 13 Mar 2018 14:38:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1B282166BDA; Tue, 13 Mar 2018 14:38:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:34 +0100 Message-Id: <7429b438229736b3d3ab8747c113d7aa7a68336c.1520951803.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/10] conf: Parse and validate disk source seclabels together with the source 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 13 Mar 2018 14:39:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since seclabels are formatted along with the source element and will also make sense to be passed for the backing chain we should parse them in the place where we parse the disk source. Same applies for validation. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c2a2f3a75..d1ff80feb7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8631,6 +8631,10 @@ virDomainDiskSourceParse(xmlNodePtr node, !(src->encryption =3D virStorageEncryptionParseNode(tmp, ctxt))) goto cleanup; + if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabel= s, + ctxt, flags) < 0) + goto cleanup; + if (virDomainDiskSourcePrivateDataParse(ctxt, src, flags, xmlopt) < 0) goto cleanup; @@ -8985,7 +8989,10 @@ virDomainDiskSourceDefParseAuthValidate(const virSto= rageSource *src) static int -virDomainDiskDefParseValidate(const virDomainDiskDef *def) +virDomainDiskDefParseValidate(const virDomainDiskDef *def, + virSecurityLabelDefPtr *vmSeclabels, + size_t nvmSeclabels) + { virStorageSourcePtr next; @@ -9075,6 +9082,12 @@ virDomainDiskDefParseValidate(const virDomainDiskDef= *def) return -1; } } + + if (virSecurityDeviceLabelDefValidateXML(next->seclabels, + next->nseclabels, + vmSeclabels, + nvmSeclabels) < 0) + return -1; } return 0; @@ -9222,7 +9235,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainDiskDefPtr def; - xmlNodePtr sourceNode =3D NULL; xmlNodePtr cur; xmlNodePtr save_ctxt =3D ctxt->node; char *tmp =3D NULL; @@ -9281,8 +9293,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, continue; if (!source && virXMLNodeNameEqual(cur, "source")) { - sourceNode =3D cur; - if (virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlop= t) < 0) goto error; @@ -9460,25 +9470,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; } - /* If source is present, check for an optional seclabel override. */ - if (sourceNode) { - xmlNodePtr saved_node =3D ctxt->node; - ctxt->node =3D sourceNode; - if (virSecurityDeviceLabelDefParseXML(&def->src->seclabels, - &def->src->nseclabels, - ctxt, - flags) < 0) - goto error; - - if (virSecurityDeviceLabelDefValidateXML(def->src->seclabels, - def->src->nseclabels, - vmSeclabels, - nvmSeclabels) < 0) - goto error; - - ctxt->node =3D saved_node; - } - if (!target && !(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) { if (def->src->srcpool) { if (virAsprintf(&tmp, "pool =3D '%s', volume =3D '%s'", @@ -9644,7 +9635,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } - if (virDomainDiskDefParseValidate(def) < 0) + if (virDomainDiskDefParseValidate(def, vmSeclabels, nvmSeclabels) < 0) goto error; cleanup: --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15209521260271017.0865129593315; Tue, 13 Mar 2018 07:42:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B00521BB1; Tue, 13 Mar 2018 14:42:04 +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 1FDBF600D2; Tue, 13 Mar 2018 14:42:04 +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 367374CA9D; Tue, 13 Mar 2018 14:42:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcRej003444 for ; Tue, 13 Mar 2018 10:38:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id E333C2166BAE; Tue, 13 Mar 2018 14:38:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CF952166BDA; Tue, 13 Mar 2018 14:38:26 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:35 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 09/10] conf: Extract parsing of storage source related data 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 13 Mar 2018 14:42:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split out the parser and separate it from the private data part so that it can be later reused in other parts of the code. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d1ff80feb7..86fc275116 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8554,24 +8554,26 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, static int -virDomainDiskSourcePrivateDataParse(xmlXPathContextPtr ctxt, +virDomainDiskSourcePrivateDataParse(xmlNodePtr node, + xmlXPathContextPtr ctxt, virStorageSourcePtr src, unsigned int flags, virDomainXMLOptionPtr xmlopt) { xmlNodePtr saveNode =3D ctxt->node; - xmlNodePtr node; int ret =3D -1; if (!(flags & VIR_DOMAIN_DEF_PARSE_STATUS) || !xmlopt || !xmlopt->privateData.storageParse) return 0; - if (!(node =3D virXPathNode("./privateData", ctxt))) - return 0; - ctxt->node =3D node; + if (!(ctxt->node =3D virXPathNode("./privateData", ctxt))) { + ret =3D 0; + goto cleanup; + } + if (xmlopt->privateData.storageParse(ctxt, src) < 0) goto cleanup; @@ -8584,12 +8586,11 @@ virDomainDiskSourcePrivateDataParse(xmlXPathContext= Ptr ctxt, } -int -virDomainDiskSourceParse(xmlNodePtr node, - xmlXPathContextPtr ctxt, - virStorageSourcePtr src, - unsigned int flags, - virDomainXMLOptionPtr xmlopt) +static int +virDomainStorageSourceParse(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virStorageSourcePtr src, + unsigned int flags) { int ret =3D -1; xmlNodePtr saveNode =3D ctxt->node; @@ -8635,9 +8636,6 @@ virDomainDiskSourceParse(xmlNodePtr node, ctxt, flags) < 0) goto cleanup; - if (virDomainDiskSourcePrivateDataParse(ctxt, src, flags, xmlopt) < 0) - goto cleanup; - /* People sometimes pass a bogus '' source path when they mean to omit= the * source element completely (e.g. CDROM without media). This is just a * little compatibility check to help those broken apps */ @@ -8652,6 +8650,23 @@ virDomainDiskSourceParse(xmlNodePtr node, } +int +virDomainDiskSourceParse(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virStorageSourcePtr src, + unsigned int flags, + virDomainXMLOptionPtr xmlopt) +{ + if (virDomainStorageSourceParse(node, ctxt, src, flags) < 0) + return -1; + + if (virDomainDiskSourcePrivateDataParse(node, ctxt, src, flags, xmlopt= ) < 0) + return -1; + + return 0; +} + + static int virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, virStorageSourcePtr src, --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 06:35:58 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520952174231271.7782434423052; Tue, 13 Mar 2018 07:42:54 -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 EB76480F9E; Tue, 13 Mar 2018 14:42:52 +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 B82C553B20; Tue, 13 Mar 2018 14:42:52 +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 31E6D181BA00; Tue, 13 Mar 2018 14:42:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2DEcRxf003449 for ; Tue, 13 Mar 2018 10:38:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E81D2166BB2; Tue, 13 Mar 2018 14:38:27 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 288A52166BDA; Tue, 13 Mar 2018 14:38:27 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 15:37:36 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/10] conf: Add and export wrapper for parsing storage source XML 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.27]); Tue, 13 Mar 2018 14:42:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a helper that parses a storage source XML node into a new virStorageSource object. Since there are multiple approaches to store the 'type' and 'format' attributes, they need to be parsed manually prior to calling the function. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 60 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 6 +++++ src/libvirt_private.syms | 1 + 3 files changed, 67 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86fc275116..0b25c6316f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8650,6 +8650,66 @@ virDomainStorageSourceParse(xmlNodePtr node, } +/** + * virDomainStorageSourceParseNew: + * @node: XML node object to parse + * @ctxt: XML XPath context + * @flags: virDomainDefParseFlags + * + * Parses the XML @node and returns a virStorageSource object with the par= sed + * data. Note that 'format' and 'type' attributes need to be members of th= e same + * object and need to be provided. + */ +virStorageSourcePtr +virDomainStorageSourceParseNew(xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + virStorageSourcePtr src =3D NULL; + virStorageSourcePtr ret =3D NULL; + char *format =3D NULL; + char *type =3D NULL; + + if (VIR_ALLOC(src) < 0) + return NULL; + + if (!(type =3D virXMLPropString(node, "type"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing storage source type")); + goto cleanup; + } + + if (!(format =3D virXMLPropString(node, "format"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + ("missing storage source format")); + goto cleanup; + } + + if ((src->type =3D virStorageTypeFromString(type)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown storage source type '%s'"), type); + goto cleanup; + } + + if ((src->format =3D virStorageFileFormatTypeFromString(format)) <=3D = 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown storage source format '%s'"), format); + goto cleanup; + } + + if (virDomainStorageSourceParse(node, ctxt, src, flags) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, src); + + cleanup: + virStorageSourceFree(src); + VIR_FREE(format); + VIR_FREE(type); + return ret; +} + + int virDomainDiskSourceParse(xmlNodePtr node, xmlXPathContextPtr ctxt, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 61379e50fe..c82a23d220 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3434,6 +3434,12 @@ int virDomainStorageSourceFormat(virBufferPtr attrBu= f, bool skipSeclabels) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +virStorageSourcePtr +virDomainStorageSourceParseNew(xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, int maplen, int ncpumaps, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c67bce7389..4dfcbb4230 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -543,6 +543,7 @@ virDomainStateReasonToString; virDomainStateTypeFromString; virDomainStateTypeToString; virDomainStorageSourceFormat; +virDomainStorageSourceParseNew; virDomainTaintTypeFromString; virDomainTaintTypeToString; virDomainTimerModeTypeFromString; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list