From nobody Fri May 3 15:06:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502984701207268.32432648729355; Thu, 17 Aug 2017 08:45:01 -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 6A12A356DA; Thu, 17 Aug 2017 15:44:59 +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 43CE8649A4; Thu, 17 Aug 2017 15:44:59 +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 0B16F3FAD4; Thu, 17 Aug 2017 15:44:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7HFiYFA023354 for ; Thu, 17 Aug 2017 11:44:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id C45695EDE4; Thu, 17 Aug 2017 15:44:34 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-132.brq.redhat.com [10.40.204.132]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93F725EDEE for ; Thu, 17 Aug 2017 15:44:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6A12A356DA Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 17 Aug 2017 17:44:21 +0200 Message-Id: <20170817154423.5825-2-abologna@redhat.com> In-Reply-To: <20170817154423.5825-1-abologna@redhat.com> References: <20170817154423.5825-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/3] tests: Improve target index validation coverage 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]); Thu, 17 Aug 2017 15:44:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split one of the existing tests to ensure both configuration errors it contained cause a failure, and introduce a new test case. Signed-off-by: Andrea Bolognani --- ...ml =3D> qemuxml2argv-pseries-phb-invalid-target-index-1.xml} | 4 ---- ...ml =3D> qemuxml2argv-pseries-phb-invalid-target-index-2.xml} | 6 +----- ...ml =3D> qemuxml2argv-pseries-phb-invalid-target-index-3.xml} | 11 ++++-= ------ tests/qemuxml2argvtest.c | 4 +++- 4 files changed, 8 insertions(+), 17 deletions(-) copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-phb-wrong-target-index.x= ml =3D> qemuxml2argv-pseries-phb-invalid-target-index-1.xml} (79%) copy tests/qemuxml2argvdata/{qemuxml2argv-pseries-phb-wrong-target-index.x= ml =3D> qemuxml2argv-pseries-phb-invalid-target-index-2.xml} (68%) rename tests/qemuxml2argvdata/{qemuxml2argv-pseries-phb-wrong-target-index= .xml =3D> qemuxml2argv-pseries-phb-invalid-target-index-3.xml} (57%) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-i= ndex.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-i= ndex-1.xml similarity index 79% copy from tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-inde= x.xml copy to tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-inde= x-1.xml index 48e3b1f80..4de341978 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-= 1.xml @@ -12,10 +12,6 @@ - - - - diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-i= ndex.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-i= ndex-2.xml similarity index 68% copy from tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-inde= x.xml copy to tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-inde= x-2.xml index 48e3b1f80..5e4aa2635 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-= 2.xml @@ -8,11 +8,7 @@ /usr/bin/qemu-system-ppc64 - - - - - + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-i= ndex.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-i= ndex-3.xml similarity index 57% rename from tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-in= dex.xml rename to tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-in= dex-3.xml index 48e3b1f80..864c5d875 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-= 3.xml @@ -8,13 +8,10 @@ /usr/bin/qemu-system-ppc64 - - - - - - - + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 77cfe8d28..5cdbc78eb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1764,13 +1764,15 @@ mymain(void) DO_TEST("pseries-phb-default-missing", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); - DO_TEST_PARSE_ERROR("pseries-phb-wrong-target-index", NONE); DO_TEST("pseries-phb-numa-node", QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE); DO_TEST_PARSE_ERROR("pseries-default-phb-numa-node", NONE); + DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-1", NONE); + DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-2", NONE); + DO_TEST_PARSE_ERROR("pseries-phb-invalid-target-index-3", NONE); =20 DO_TEST("pseries-many-devices", QEMU_CAPS_NODEFCONFIG, --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 15:06:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502984705082826.8152600910573; Thu, 17 Aug 2017 08:45:05 -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 37E3E81DEC; Thu, 17 Aug 2017 15:45:02 +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 16436614CA; Thu, 17 Aug 2017 15:45:02 +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 CD9341800C8A; Thu, 17 Aug 2017 15:45:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7HFiaaJ023362 for ; Thu, 17 Aug 2017 11:44:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36A445EDE5; Thu, 17 Aug 2017 15:44:36 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-132.brq.redhat.com [10.40.204.132]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F6455EDE4 for ; Thu, 17 Aug 2017 15:44:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 37E3E81DEC 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 17 Aug 2017 17:44:22 +0200 Message-Id: <20170817154423.5825-3-abologna@redhat.com> In-Reply-To: <20170817154423.5825-1-abologna@redhat.com> References: <20170817154423.5825-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/3] conf: Move target index validation 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]); Thu, 17 Aug 2017 15:45:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Validation should happen after parsing, so the proper location for it is virDomainControllerDefValidate() rather than virDomainControllerDefParseXML(). Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3db56ffb7..86afeaa3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4995,12 +4995,34 @@ static int virDomainControllerDefValidate(const virDomainControllerDef *controller) { if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + const virDomainPCIControllerOpts *opts =3D &controller->opts.pciop= ts; + if (controller->idx > 255) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller index %d too high, maximum is= 255"), controller->idx); return -1; } + + /* Only validate the target index if it's been set */ + if (opts->targetIndex !=3D -1) { + + if (opts->targetIndex < 0 || opts->targetIndex > 31) { + virReportError(VIR_ERR_XML_ERROR, + _("PCI controller target index '%d' out of " + "range - must be 0-31"), + opts->targetIndex); + return -1; + } + + if ((controller->idx =3D=3D 0 && opts->targetIndex !=3D 0) || + (controller->idx !=3D 0 && opts->targetIndex =3D=3D 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Only the PCI controller with index 0 can= " + "have target index 0, and vice versa")); + return -1; + } + } } return 0; } @@ -9322,27 +9344,13 @@ virDomainControllerDefParseXML(xmlNodePtr node, } if (targetIndex) { if (virStrToLong_i(targetIndex, NULL, 0, - &def->opts.pciopts.targetIndex) < 0) { + &def->opts.pciopts.targetIndex) < 0 || + def->opts.pciopts.targetIndex =3D=3D -1) { virReportError(VIR_ERR_XML_ERROR, _("Invalid target index '%s' in PCI control= ler"), targetIndex); goto error; } - if (def->opts.pciopts.targetIndex < 0 || - def->opts.pciopts.targetIndex > 31) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller target index '%s' out of " - "range - must be 0-31"), - targetIndex); - goto error; - } - if ((def->idx =3D=3D 0 && def->opts.pciopts.targetIndex !=3D 0= ) || - (def->idx !=3D 0 && def->opts.pciopts.targetIndex =3D=3D 0= )) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Only the PCI controller with index 0 can= " - "have target index 0, and vice versa")); - goto error; - } } if (numaNode >=3D 0) { if (def->idx =3D=3D 0) { --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 15:06:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502984681756176.40789600388382; Thu, 17 Aug 2017 08:44:41 -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 8C42D155DF; Thu, 17 Aug 2017 15:44:39 +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 6AAFF5C472; Thu, 17 Aug 2017 15:44:39 +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 A021F3FAD0; Thu, 17 Aug 2017 15:44:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7HFibIK023376 for ; Thu, 17 Aug 2017 11:44:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4A965EDE2; Thu, 17 Aug 2017 15:44:37 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-132.brq.redhat.com [10.40.204.132]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B59A25EDEB for ; Thu, 17 Aug 2017 15:44:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C42D155DF 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 17 Aug 2017 17:44:23 +0200 Message-Id: <20170817154423.5825-4-abologna@redhat.com> In-Reply-To: <20170817154423.5825-1-abologna@redhat.com> References: <20170817154423.5825-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/3] conf: Use the correct limit for the number of PHBs 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]); Thu, 17 Aug 2017 15:44:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" I mistakenly thought pSeries guests supported 32 PHBs, but it turns out they only support 31. Validate the target index accordingly. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1479647 Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 4 ++= -- .../qemuxml2argv-pseries-phb-invalid-target-index-3.xml | 6 ++= +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86afeaa3f..41a2a7bc8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5007,10 +5007,10 @@ virDomainControllerDefValidate(const virDomainContr= ollerDef *controller) /* Only validate the target index if it's been set */ if (opts->targetIndex !=3D -1) { =20 - if (opts->targetIndex < 0 || opts->targetIndex > 31) { + if (opts->targetIndex < 0 || opts->targetIndex > 30) { virReportError(VIR_ERR_XML_ERROR, _("PCI controller target index '%d' out of " - "range - must be 0-31"), + "range - must be 0-30"), opts->targetIndex); return -1; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target= -index-3.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-targ= et-index-3.xml index 864c5d875..3d99da499 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-= 3.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-invalid-target-index-= 3.xml @@ -8,10 +8,10 @@ /usr/bin/qemu-system-ppc64 - + - + --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list