From nobody Sun Feb 8 16:30:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645622580461576.7094209322983; Wed, 23 Feb 2022 05:23:00 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-YSIkb1F1N8CF_uoc3B-AjA-1; Wed, 23 Feb 2022 08:22:54 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B221801502; Wed, 23 Feb 2022 13:22:44 +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 69D28832B6; Wed, 23 Feb 2022 13:22:44 +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 34A081807D69; Wed, 23 Feb 2022 13:22:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21NDKbxu029852 for ; Wed, 23 Feb 2022 08:20:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6EA1D492D4D; Wed, 23 Feb 2022 13:20:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A565492D4A for ; Wed, 23 Feb 2022 13:20:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 511621C05EA2 for ; Wed, 23 Feb 2022 13:20:37 +0000 (UTC) Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-272-lpGw7uHHPlmWdrj4jQ_X2Q-1; Wed, 23 Feb 2022 08:20:35 -0500 Received: by mail-oo1-f42.google.com with SMTP id j7-20020a4ad6c7000000b0031c690e4123so13106036oot.11 for ; Wed, 23 Feb 2022 05:20:35 -0800 (PST) Received: from rekt.ibmuc.com ([191.193.99.92]) by smtp.gmail.com with ESMTPSA id a4sm27646154oaa.42.2022.02.23.05.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 05:20:34 -0800 (PST) X-MC-Unique: YSIkb1F1N8CF_uoc3B-AjA-1 X-MC-Unique: lpGw7uHHPlmWdrj4jQ_X2Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MEYbg648Uh6YTY8LJ+rSenkj2KF1txg0GfCt7wJiuS8=; b=kk1y8LM01z7ZTpyrtIlpBlCuXdLBNHt3xhF3FGkWroVmnEyYW6jQG+FxsCAtwYD7oo Ufn4ZlDiN+MesfvatlSYS0Q8CVOUXGLESYhxM/xpK7iJf6dBcU1EmxhyDETCqiMiy3Wi GQh0bsiUqkDWkf5ypyVDmzcw3P3SSUu4XLFfIzupV5mMn5u7HCVsarPRoC0lJLg6PJcD m4q+xNRKg8YVPd0G8qXjdyHL+PJRJCJTeiGhbL5w+mP9/zxUs3BIGOBlMroR+qoX6u+7 eJXwiirLCc80AIIeSaBHHs2MePqU3PWIcdYU5CqGmxiXWWLYXvzHf9b6ypQ6e5dH5/00 5j9g== X-Gm-Message-State: AOAM530+9BRVEiv54xAcr0BQrjKYpHsFhdKEmLw/MkOSydNILDIbZ5V9 y/5Iu8U8iOuwV5A2GqHX+q8IbWhpYXg= X-Google-Smtp-Source: ABdhPJynPd9LkiHExVsptejJM+vH9tIU6mmTLFCVscuwnHkJx7UG79guPgiJxrbAipeG7Hs4zbFPsw== X-Received: by 2002:a05:6870:e887:b0:d2:c981:4106 with SMTP id q7-20020a056870e88700b000d2c9814106mr3892060oan.263.1645622434313; Wed, 23 Feb 2022 05:20:34 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 23/29] domain_conf.c: reject duplicated pnv-phb3 devices Date: Wed, 23 Feb 2022 10:19:46 -0300 Message-Id: <20220223131952.922228-24-danielhb413@gmail.com> In-Reply-To: <20220223131952.922228-1-danielhb413@gmail.com> References: <20220223131952.922228-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.85 on 10.11.54.9 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.com 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.15 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 X-ZM-MESSAGEID: 1645622581481100004 Content-Type: text/plain; charset="utf-8" These devices must have unique targetIndex/chip-id pairs. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 35 +++++++++++++++++++ tests/qemuxml2argvdata/powernv8-dupPHBs.err | 1 + .../powernv8-dupPHBs.ppc64-latest.err | 1 + tests/qemuxml2argvdata/powernv8-dupPHBs.xml | 27 ++++++++++++++ tests/qemuxml2argvtest.c | 1 + 5 files changed, 65 insertions(+) create mode 100644 tests/qemuxml2argvdata/powernv8-dupPHBs.err create mode 100644 tests/qemuxml2argvdata/powernv8-dupPHBs.ppc64-latest.err create mode 100644 tests/qemuxml2argvdata/powernv8-dupPHBs.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 625949e44e..c551134d37 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2485,6 +2485,33 @@ virDomainControllerIsPowerNVRootPort(const virDomain= ControllerDef *cont) } =20 =20 +/* Caller must ensure that 'cont' is a PowerNV PHB device */ +static bool +virDomainControllerDuplicatedPHB(virDomainDef *def, + virDomainControllerDef *cont) +{ + int chipId =3D cont->opts.pciopts.chipId; + int targetIndex =3D cont->opts.pciopts.targetIndex; + size_t i; + + for (i =3D 0; i < def->ncontrollers; i++) { + virDomainControllerDef *cont2 =3D def->controllers[i]; + + if (!virDomainControllerIsPowerNVPHB(cont2)) + continue; + + if (cont2 =3D=3D cont) + continue; + + if (cont2->opts.pciopts.chipId =3D=3D chipId && + cont2->opts.pciopts.targetIndex =3D=3D targetIndex) + return true; + } + + return false; +} + + virDomainFSDef * virDomainFSDefNew(virDomainXMLOption *xmlopt) { @@ -4749,6 +4776,14 @@ virDomainDefRejectDuplicateControllers(virDomainDef = *def) cont->idx); goto cleanup; } + + if (virDomainControllerIsPowerNVPHB(cont) && + virDomainControllerDuplicatedPHB(def, cont)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Multiple pnv-phb controllers with same chip-= id and index")); + goto cleanup; + } + ignore_value(virBitmapSetBit(bitmaps[cont->type], cont->idx)); } =20 diff --git a/tests/qemuxml2argvdata/powernv8-dupPHBs.err b/tests/qemuxml2ar= gvdata/powernv8-dupPHBs.err new file mode 100644 index 0000000000..bc5879640d --- /dev/null +++ b/tests/qemuxml2argvdata/powernv8-dupPHBs.err @@ -0,0 +1 @@ +XML error: Multiple pnv-phb controllers with same chip-id and index diff --git a/tests/qemuxml2argvdata/powernv8-dupPHBs.ppc64-latest.err b/tes= ts/qemuxml2argvdata/powernv8-dupPHBs.ppc64-latest.err new file mode 100644 index 0000000000..bc5879640d --- /dev/null +++ b/tests/qemuxml2argvdata/powernv8-dupPHBs.ppc64-latest.err @@ -0,0 +1 @@ +XML error: Multiple pnv-phb controllers with same chip-id and index diff --git a/tests/qemuxml2argvdata/powernv8-dupPHBs.xml b/tests/qemuxml2ar= gvdata/powernv8-dupPHBs.xml new file mode 100644 index 0000000000..43ee3051eb --- /dev/null +++ b/tests/qemuxml2argvdata/powernv8-dupPHBs.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + b20fcfe3-4a0a-4039-8735-9e024256e0f7 + 2097152 + 1 + + hvm + + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d688004251..82e8b4482f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2178,6 +2178,7 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("powernv8-basic", "ppc64"); DO_TEST_CAPS_ARCH_LATEST("powernv8-root-port", "ppc64"); DO_TEST_CAPS_ARCH_LATEST("powernv8-two-sockets", "ppc64"); + DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("powernv8-dupPHBs", "ppc64"); =20 DO_TEST("pseries-basic", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, --=20 2.35.1