From nobody Fri Apr 26 04:48:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487694947357471.7229754576176; Tue, 21 Feb 2017 08:35:47 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LGVn6o005487; Tue, 21 Feb 2017 11:31:49 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LGVnc0026347 for ; Tue, 21 Feb 2017 11:31:49 -0500 Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LGVm3d017501 for ; Tue, 21 Feb 2017 11:31:48 -0500 From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 21 Feb 2017 17:31:42 +0100 Message-Id: <1b961f731daa266c46a215b2f77bcfe6d253a273.1487694702.git.mprivozn@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: Don't accept dummy values for attributes 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Our virSomeEnumTypeFromString() functions return either the value of item from the enum or -1 on error. Usually however the value 0 means 'this value is not set in the domain XML, use some sensible default'. Therefore, we don't accept corresponding string in domain XML, for instance: should be rejected as invalid XML. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79bdbdf50..f718b9abc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16724,7 +16724,7 @@ virDomainDefParseXML(xmlDocPtr xml, =20 tmp =3D virXPathString("string(./memoryBacking/source/@type)", ctxt); if (tmp) { - if ((def->mem.source =3D virDomainMemorySourceTypeFromString(tmp))= < 0) { + if ((def->mem.source =3D virDomainMemorySourceTypeFromString(tmp))= <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown memoryBacking/source/type '%s'"), tm= p); goto error; @@ -16734,7 +16734,7 @@ virDomainDefParseXML(xmlDocPtr xml, =20 tmp =3D virXPathString("string(./memoryBacking/access/@mode)", ctxt); if (tmp) { - if ((def->mem.access =3D virDomainMemoryAccessTypeFromString(tmp))= < 0) { + if ((def->mem.access =3D virDomainMemoryAccessTypeFromString(tmp))= <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown memoryBacking/access/mode '%s'"), tm= p); goto error; @@ -16744,7 +16744,7 @@ virDomainDefParseXML(xmlDocPtr xml, =20 tmp =3D virXPathString("string(./memoryBacking/allocation/@mode)", ctx= t); if (tmp) { - if ((def->mem.allocation =3D virDomainMemoryAllocationTypeFromStri= ng(tmp)) < 0) { + if ((def->mem.allocation =3D virDomainMemoryAllocationTypeFromStri= ng(tmp)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown memoryBacking/allocation/mode '%s'")= , tmp); goto error; --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list