From nobody Sun Feb 8 01:34:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1607466092; cv=none; d=zohomail.com; s=zohoarc; b=SH5Q09Y/d8PmKDXU0xa9ddV4gQS6ycGWNikWiOf2Y+3TZf/PLJY2752YYQYxYWwlHarqsmMgwDxeM6Zd2di68Qg9DMl1k35bV9jWQ0Dy4XWEuJ4IN0k9zxGHO1gwzve4srf8NJt8y1PuHwat+g/vDfZM7H1gVrFVEMNjAGRRwvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466092; 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=T5dwxDaiDOG3d8lhdG3lXKI0c/SPiieJlZ4rGp+Ez7o=; b=ekxPEra4AyxjKBK3shBfvPhNEgtmVwv4S0sUw8OImA9gGl90+OuC6mupEEUTtBcZ49KE0idty4uga2zRfA+9KZ6L6XmKRI52NQKD9K0RLFDfoZx+cAorHHqbBTBym/iNPZb8PLvCpB7jQqDFFfex98+rCLTpX/6yByYcieFetPI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466092859114.1739558493307; Tue, 8 Dec 2020 14:21:32 -0800 (PST) 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-259-AqXod7ENNo-A9uTBAx2ZDg-1; Tue, 08 Dec 2020 17:21:27 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9CCB107AD38; Tue, 8 Dec 2020 22:21:20 +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 C927160BD8; Tue, 8 Dec 2020 22:21:20 +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 935A550035; Tue, 8 Dec 2020 22:21:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLJWm017423 for ; Tue, 8 Dec 2020 17:21:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26BABA9FD5; Tue, 8 Dec 2020 22:21:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EE9FA9FDF for ; Tue, 8 Dec 2020 22:21:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15273811E86 for ; Tue, 8 Dec 2020 22:21:18 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-PWwZvgutM_u4eplWwfO75w-1; Tue, 08 Dec 2020 17:21:15 -0500 Received: by mail-qk1-f181.google.com with SMTP id 1so261354qka.0; Tue, 08 Dec 2020 14:21:14 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:13 -0800 (PST) X-MC-Unique: AqXod7ENNo-A9uTBAx2ZDg-1 X-MC-Unique: PWwZvgutM_u4eplWwfO75w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T5dwxDaiDOG3d8lhdG3lXKI0c/SPiieJlZ4rGp+Ez7o=; b=cgKx7D75nbNYGDUf2NkBXFEI974s3vFBH4DHIPd135ep9ScuXOKoFlp/D8J9o7iYwv WWY41kFxsoe+QFFEpGSAiratsMAEjPbNdbTgqVa/yX7kd5lDUetTuCwGuAIpkRWZBnTn Sa1OfxTnD/tx/CuzGQaVp94+wx2/2QXNqSOYhhSaRO7TDYBH6FTzyLSZ0mrqHGOAp+rx tffxidX6eFRL9gO+bI3mVIj3/tjIEZ3NZCibK92jTI/WJTVdebTpRIQrms5zhwteuDTs TOGHDDa12hgJiRd49IRfTZyLIxV/IejiNwF98sl0GWtYo3FkvRbEM4+6wlt4ZfE2uy6o A+oA== X-Gm-Message-State: AOAM531szRw5eOQs60zpjCcnWKVxW9CaBGC3k9Dz5unusTm8m+nVKagy yIX7jABT4GTKR9/rUTbIEvdNShJZ1v4= X-Google-Smtp-Source: ABdhPJwYptZB8D83ENZBqOEI0tr6DNBWNOh8mczm6ORMlgpsYxDpNxI2Cz0XEP6mpiVwdheZbolclA== X-Received: by 2002:a37:4816:: with SMTP id v22mr32876961qka.42.1607466073910; Tue, 08 Dec 2020 14:21:13 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 12/14] domain_conf: move virDomainPCIControllerOpts checks to domain_validate.c Date: Tue, 8 Dec 2020 19:20:28 -0300 Message-Id: <20201208222030.1302229-13-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Daniel Henrique Barboza 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.79 on 10.5.11.11 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 Content-Type: text/plain; charset="utf-8" virDomainControllerDefParseXML() does a lot of checks with virDomainPCIControllerOpts parameters that can be moved to virDomainControllerDefValidate, sharing the logic with other use cases that does not rely on XML parsing. 'pseries-default-phb-numa-node' parse error was changed to reflect the error that is being thrown by qemuValidateDomainDeviceDefController() via deviceValidateCallback, that is executed before virDomainControllerDefValidate(). Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 42 +--------------- src/conf/domain_validate.c | 48 +++++++++++++++++++ .../pseries-default-phb-numa-node.err | 2 +- tests/qemuxml2argvtest.c | 6 ++- 4 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 453dc6cf6a..7adf2700ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10864,14 +10864,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, chassisNr); return NULL; } - if (def->opts.pciopts.chassisNr < 1 || - def->opts.pciopts.chassisNr > 255) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller chassisNr '%s' out of ran= ge " - "- must be 1-255"), - chassisNr); - return NULL; - } } if (chassis) { if (virStrToLong_i(chassis, NULL, 0, @@ -10881,14 +10873,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, chassis); return NULL; } - if (def->opts.pciopts.chassis < 0 || - def->opts.pciopts.chassis > 255) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller chassis '%s' out of range= " - "- must be 0-255"), - chassis); - return NULL; - } } if (port) { if (virStrToLong_i(port, NULL, 0, @@ -10898,14 +10882,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, port); return NULL; } - if (def->opts.pciopts.port < 0 || - def->opts.pciopts.port > 255) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller port '%s' out of range " - "- must be 0-255"), - port); - return NULL; - } } if (busNr) { if (virStrToLong_i(busNr, NULL, 0, @@ -10915,14 +10891,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, busNr); return NULL; } - if (def->opts.pciopts.busNr < 1 || - def->opts.pciopts.busNr > 254) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller busNr '%s' out of range " - "- must be 1-254"), - busNr); - return NULL; - } } if (targetIndex) { if (virStrToLong_i(targetIndex, NULL, 0, @@ -10934,15 +10902,9 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, return NULL; } } - if (numaNode >=3D 0) { - if (def->idx =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("The PCI controller with index=3D0 can't " - "be associated with a NUMA node")); - return NULL; - } + if (numaNode >=3D 0) def->opts.pciopts.numaNode =3D numaNode; - } + if (hotplug) { int val =3D virTristateSwitchTypeFromString(hotplug); =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 416c24f97b..f47e80ca38 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -551,6 +551,54 @@ virDomainControllerDefValidate(const virDomainControll= erDef *controller) return -1; } } + + if (opts->chassisNr !=3D -1) { + if (opts->chassisNr < 1 || opts->chassisNr > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller chassisNr '%d' out of ran= ge " + "- must be 1-255"), + opts->chassisNr); + return -1; + } + } + + if (opts->chassis !=3D -1) { + if (opts->chassis < 0 || opts->chassis > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller chassis '%d' out of range= " + "- must be 0-255"), + opts->chassis); + return -1; + } + } + + if (opts->port !=3D -1) { + if (opts->port < 0 || opts->port > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller port '%d' out of range " + "- must be 0-255"), + opts->port); + return -1; + } + } + + if (opts->busNr !=3D -1) { + if (opts->busNr < 1 || opts->busNr > 254) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller busNr '%d' out of range " + "- must be 1-254"), + opts->busNr); + return -1; + } + } + + if (opts->numaNode >=3D 0 && controller->idx =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("The PCI controller with index=3D0 can't " + "be associated with a NUMA node")); + return -1; + } } + return 0; } diff --git a/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err b/tes= ts/qemuxml2argvdata/pseries-default-phb-numa-node.err index 5d11109317..e46b710330 100644 --- a/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err +++ b/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err @@ -1 +1 @@ -XML error: The PCI controller with index=3D0 can't be associated with a NU= MA node +unsupported configuration: Option 'numaNode' is not valid for PCI controll= er with index '0', model 'pci-root' and modelName 'spapr-pci-host-bridge' diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0e7d8d5ba3..9b853c6d59 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2115,7 +2115,11 @@ mymain(void) 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-default-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-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 2.26.2