From nobody Sat Feb 7 15:29:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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.133.124]) by mx.zohomail.com with SMTPS id 1643143827130982.041806026092; Tue, 25 Jan 2022 12:50:27 -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-154-JGR2woNRMQebpaBV-CxOxg-1; Tue, 25 Jan 2022 15:50:23 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2613100C687; Tue, 25 Jan 2022 20:50:16 +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 2BD565ED5A; Tue, 25 Jan 2022 20:50:16 +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 E7B35180065F; Tue, 25 Jan 2022 20:50:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20PKoDD3024463 for ; Tue, 25 Jan 2022 15:50:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 94F20C50953; Tue, 25 Jan 2022 20:50:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91507C4237C for ; Tue, 25 Jan 2022 20:50:11 +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 0C5E880B90A for ; Tue, 25 Jan 2022 20:50:00 +0000 (UTC) Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-xt1wwyi0N8WU5eo4lPHc-Q-2; Tue, 25 Jan 2022 15:49:47 -0500 Received: by mail-oi1-f179.google.com with SMTP id s127so33544375oig.2 for ; Tue, 25 Jan 2022 12:49:47 -0800 (PST) Received: from rekt.COMFAST ([191.8.61.226]) by smtp.gmail.com with ESMTPSA id ay32sm1368569oob.16.2022.01.25.12.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 12:49:46 -0800 (PST) X-MC-Unique: JGR2woNRMQebpaBV-CxOxg-1 X-MC-Unique: xt1wwyi0N8WU5eo4lPHc-Q-2 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=9vGEirU2ImK1BoXstezfn9ovlbj8zCCvNtFMcTj9vXE=; b=77bRISszuqoVAnhdi5LTOu8h9UmHnGcQH/Ng6xZsFn+TLhLCME2VYqxCV24td+6di8 k4OvzeJ1AIURrx0DC9GqDAi7L482SKWQw0w/GhZ73lpuaxg5MhUJIRdmbt4a+23a4nMv 6/bzzTPZsFk8lnDpSf6y3NJNGBY6Y+e8C42UH1uJy8JUI8MFLJDpMnxbEZpW6P7SFrJE /X/gNXAKDQi71vfMMF5PD130fz/TYmE4golDy6aYZC0RhxdPz/z1dlv97jqV7XCFwnQ/ Ogc7g38L1QDfQ91xfiC/vWxhjom3lwn4oS2b8oeTaxrmyUmZ1JA01KDkHPMmKuMD3zyf 9bZg== X-Gm-Message-State: AOAM531TEoi2uXOUm2TpC0z1YT89F4OxBRkYzZ53RDc6ZkytmGxvPH20 KtpC1vo/+ADuENdVe8M60aN54FCMilA= X-Google-Smtp-Source: ABdhPJyQSxTBoc8Gnafv/3S9wa6+R7aWmxw6p8xcuyrhsJLL52ORVJDgygk0EbuRA/yVSGk6+XUvyQ== X-Received: by 2002:a05:6808:d4f:: with SMTP id w15mr1789830oik.62.1643143786686; Tue, 25 Jan 2022 12:49:46 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 20/29] domain_conf: format pnv-phb3-root-port empty addr Date: Tue, 25 Jan 2022 17:48:53 -0300 Message-Id: <20220125204902.772350-21-danielhb413@gmail.com> In-Reply-To: <20220125204902.772350-1-danielhb413@gmail.com> References: <20220125204902.772350-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.8 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.14 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: 1643143829995100001 Content-Type: text/plain; charset="utf-8" Hiding the empty (0000:00:0.0) PCI address in the case of devices that will connect to slot 0x0 can be counterintuitive to the user, which will see something like this: Even if the user deliberately adds the root-port
element:
We end up removing the
element after saving the domain file. This happens because virPCIDeviceAddressIsEmpty() can't distinguish between a zeroed address that was set by the user versus an address that wasn't filled at all. Given that all root-ports of PowerNV domains will connect to slot 0 of the PHB, if the PHB controller has index =3D 0 this scenario will occur every time. This patch aims to alleaviate this behavior by adding a new virDomainDefFormatFlags that will allow an empty address to be formatted in the XML. This flag is then used only when formatting PowerNV root ports. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 25 ++++++++++++++++++++++++- src/conf/domain_conf.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 13d5eb5b9d..026d801682 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2463,6 +2463,25 @@ virDomainControllerIsPowerNVPHB(const virDomainContr= ollerDef *cont) } =20 =20 +static bool +virDomainControllerIsPowerNVRootPort(const virDomainControllerDef *cont) +{ + virDomainControllerPCIModelName name; + + if (cont->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI || + cont->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT) { + return false; + } + + name =3D cont->opts.pciopts.modelName; + + if (name !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT) + return false; + + return true; +} + + virDomainFSDef * virDomainFSDefNew(virDomainXMLOption *xmlopt) { @@ -6490,7 +6509,8 @@ virDomainDeviceInfoFormat(virBuffer *buf, =20 switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - if (!virPCIDeviceAddressIsEmpty(&info->addr.pci)) { + if (!virPCIDeviceAddressIsEmpty(&info->addr.pci) || + flags & VIR_DOMAIN_DEF_FORMAT_EMPTY_PCI_ADDR) { virBufferAsprintf(&attrBuf, " domain=3D'0x%04x' bus=3D'0x%02x'= " "slot=3D'0x%02x' function=3D'0x%d'", info->addr.pci.domain, @@ -23958,6 +23978,9 @@ virDomainControllerDefFormat(virBuffer *buf, } } =20 + if (virDomainControllerIsPowerNVRootPort(def)) + flags |=3D VIR_DOMAIN_DEF_FORMAT_EMPTY_PCI_ADDR; + virDomainControllerDriverFormat(&childBuf, def); =20 virDomainDeviceInfoFormat(&childBuf, &def->info, flags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index adeafa83e7..dd3d942a35 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3502,6 +3502,8 @@ typedef enum { VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM =3D 1 << 6, VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT =3D 1 << 7, VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST =3D 1 << 8, + /* format empty PCI addr (0000:00:0.0) */ + VIR_DOMAIN_DEF_FORMAT_EMPTY_PCI_ADDR =3D 1 << 9, } virDomainDefFormatFlags; =20 /* Use these flags to skip specific domain ABI consistency checks done --=20 2.34.1