From nobody Sun Feb 8 12:19:10 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=1606245701; cv=none; d=zohomail.com; s=zohoarc; b=hZXlcAXolr1mgqdFUc5XhzXK36yCKSysteIQeYaBHuT6LBLe2/eNL+nNQV8LfOn2HxqKoco7D1Ver+2k2R/pvwHW4Rj9Msdk8pOPZHNQ7acgYHraudeVaM19ahlrPYypQvV26Zz9sIy1K+NTnd+bZUGYAW6pzrNyAsHqx+TNH7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245701; 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=jacUqTKLLTL82ME7+F4u4qgIoW3LZPcEWwm9AP3C/oM=; b=nZw7+svLeY6xlkjH2hGINv9dZ3ZJvdajIBWREIELUqNrXgzKIYHpSmO2QWKRWZonoYmUBcjKJvJVYehLB1JesYc8I3NVbw8Bu4HCENbm7/4JVKRJczc837XLbMtk3/NGrbsbrMy2jLfO1Q6ESypekaYnUBX+6NivYyDJN2qlz3w= 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 160624570109972.14520884921626; Tue, 24 Nov 2020 11:21:41 -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-449-bhO99h8-P7OieVwVXRigKA-1; Tue, 24 Nov 2020 14:21:37 -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 BDC0A805BF5; Tue, 24 Nov 2020 19:21:29 +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 9309B12D7E; Tue, 24 Nov 2020 19:21:29 +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 2DAD250039; Tue, 24 Nov 2020 19:21:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJLPpn004370 for ; Tue, 24 Nov 2020 14:21:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id F2B7C110E981; Tue, 24 Nov 2020 19:21:24 +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 EED10110E980 for ; Tue, 24 Nov 2020 19:21:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 DC561811E78 for ; Tue, 24 Nov 2020 19:21:24 +0000 (UTC) Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-EMEubq3HPTqBHX1noXb_5g-1; Tue, 24 Nov 2020 14:21:22 -0500 Received: by mail-qv1-f47.google.com with SMTP id g19so11196915qvy.2 for ; Tue, 24 Nov 2020 11:21:22 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:21:20 -0800 (PST) X-MC-Unique: bhO99h8-P7OieVwVXRigKA-1 X-MC-Unique: EMEubq3HPTqBHX1noXb_5g-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=jacUqTKLLTL82ME7+F4u4qgIoW3LZPcEWwm9AP3C/oM=; b=UTrNP6c52QeavGn59KUwGnu+bP2dB7yTbculXCfVA5rgjyga4zvB2fVVZlFFl2Ldtz S0E/G52lWPkaApNaLXD88IAn6zx4z5oP0xTXO/1kOTDuCO5bufI+wZ0hkknjDLoBs+b6 r2kS8Qss5p+k3qEAMCWcS/iIxTg2klmPIF1bWCPhsm8iQBNMEhNwkdqKQgkcyEf3EcS+ hUNHErH2tU/X23yuZQ+/bTdieBxEZqp0dBNQFBGsx4QGbAkzCjnFK9owHtRqsZ9Uqmzb /eBTWKdrW85jD+1f4MjYUkjRKEDZj5ELeYFjyjis8pSZq8MkwJAb6ijKVuyfcVBhFuL8 BvYw== X-Gm-Message-State: AOAM5301g5Dhqh/S+ziy697u8GKQS4O4EzboJP90aWQwTawliBgjgsKF L1nrI0JU27tzv03sSymzcswqn10s4OY= X-Google-Smtp-Source: ABdhPJy2CMQfZ9p/19e8mJq6His/98lDVelhnbm0VVPs7nlCF7+B1Rh70MNbJWAJYffANsvOvLilFg== X-Received: by 2002:a0c:da0d:: with SMTP id x13mr6554778qvj.20.1606245681339; Tue, 24 Nov 2020 11:21:21 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 16/21] domain_conf.c: move virDomainPCIControllerOpts checks to post parse Date: Tue, 24 Nov 2020 16:20:30 -0300 Message-Id: <20201124192035.2343063-17-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-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.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: 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 post parse time, sharing the logic with other use cases that does not rely on XML parsing. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 89 +++++++++++-------- .../pseries-default-phb-numa-node.err | 2 +- 2 files changed, 52 insertions(+), 39 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 220224cebe..9ca979b345 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5379,6 +5379,57 @@ virDomainControllerDefPostParse(virDomainControllerD= efPtr cdev) return -1; } =20 + if (cdev->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + virDomainPCIControllerOpts pciOpts =3D cdev->opts.pciopts; + + if (pciOpts.chassisNr !=3D -1) { + if (pciOpts.chassisNr < 1 || pciOpts.chassisNr > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller chassisNr '%d' out of ran= ge " + "- must be 1-255"), + pciOpts.chassisNr); + return -1; + } + } + + if (pciOpts.chassis !=3D -1) { + if (pciOpts.chassis < 0 || pciOpts.chassis > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller chassis '%d' out of range= " + "- must be 0-255"), + pciOpts.chassis); + return -1; + } + } + + if (pciOpts.port !=3D -1) { + if (pciOpts.port < 0 || pciOpts.port > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller port '%d' out of range " + "- must be 0-255"), + pciOpts.port); + return -1; + } + } + + if (pciOpts.busNr !=3D -1) { + if (pciOpts.busNr < 1 || pciOpts.busNr > 254) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller busNr '%d' out of range " + "- must be 1-254"), + pciOpts.busNr); + return -1; + } + } + + if (pciOpts.numaNode >=3D 0 && cdev->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; } =20 @@ -11416,14 +11467,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, chassisNr); goto error; } - 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); - goto error; - } } if (chassis) { if (virStrToLong_i(chassis, NULL, 0, @@ -11433,14 +11476,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, chassis); goto error; } - 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); - goto error; - } } if (port) { if (virStrToLong_i(port, NULL, 0, @@ -11450,14 +11485,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, port); goto error; } - 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); - goto error; - } } if (busNr) { if (virStrToLong_i(busNr, NULL, 0, @@ -11467,14 +11494,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, busNr); goto error; } - 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); - goto error; - } } if (targetIndex) { if (virStrToLong_i(targetIndex, NULL, 0, @@ -11487,12 +11506,6 @@ virDomainControllerDefParseXML(virDomainXMLOptionP= tr xmlopt, } } 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")); - goto error; - } def->opts.pciopts.numaNode =3D numaNode; } if (hotplug) { diff --git a/tests/qemuxml2argvdata/pseries-default-phb-numa-node.err b/tes= ts/qemuxml2argvdata/pseries-default-phb-numa-node.err index 5d11109317..20dade0530 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: The PCI controller with index=3D0 can't be asso= ciated with a NUMA node --=20 2.26.2