From nobody Sun Feb 8 16:04:59 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 1642686825680328.0789079443483; Thu, 20 Jan 2022 05:53:45 -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-302-gyv2NtJXM7eam_iMqM9KFQ-1; Thu, 20 Jan 2022 08:53:41 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 675B6874984; Thu, 20 Jan 2022 13:53:35 +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 17B515E4B6; Thu, 20 Jan 2022 13:53:35 +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 D95044A707; Thu, 20 Jan 2022 13:53:34 +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 20KDrWrh009381 for ; Thu, 20 Jan 2022 08:53:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 320B4C33AE5; Thu, 20 Jan 2022 13:53:32 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E98EC33AE3 for ; Thu, 20 Jan 2022 13:53:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 14B7F2A38D02 for ; Thu, 20 Jan 2022 13:53:32 +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-639-p4d6YCQ5MX6JEyzNpQ8cAg-4; Thu, 20 Jan 2022 08:53:30 -0500 Received: by mail-oi1-f179.google.com with SMTP id s22so8911297oie.10 for ; Thu, 20 Jan 2022 05:53:30 -0800 (PST) Received: from rekt.COMFAST ([191.8.61.226]) by smtp.gmail.com with ESMTPSA id a26sm1574102oiy.26.2022.01.20.05.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 05:53:29 -0800 (PST) X-MC-Unique: gyv2NtJXM7eam_iMqM9KFQ-1 X-MC-Unique: p4d6YCQ5MX6JEyzNpQ8cAg-4 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=x67mcVPMrBwiinPj71GelGWH9Fv4/HRXwR7wGyc3PEI=; b=dc8agvLKVpyYvO7dkSmLynTf/ZsMewFLGoaen224E/TezZnyoojwONjf1kW1ZBHeo7 5IbZEU3cjrG+jzHLjejdUvhdefzZRrr0wwjOtxAF9r5EawiQo5mUe9T5RHxeGBNoZrzm WlMyW/5jscD/qpZ4X0cAJ2C1Oi6pQ3e0AnbUFIAD/49OEDImvp8PkJCfoCdM5uSRDzqb 3cWKrQxb3Oy6T74D0SAtdip6ScpNzre46DZ/33W9gmsePOn0gtFZZcqcWslfSrxJ4Aol Sxe0Lb1zRSYmsc65mjDNJKy2ahuDvomOgS4N5c1E99l6Y2Id578JAGZLYKOVX3axH8/F NQHg== X-Gm-Message-State: AOAM532fIrbg595iTrUoSz21OWlC0u2qsytv4C1WJJOTiIllGgwQmuQ1 FVFkHw3iuEfKYZc8lgE2uK6SNtEU1qY= X-Google-Smtp-Source: ABdhPJxa2M7dpzMS+UATZFT+p4FIeAURP6MG/wqoTmNnIQLkEcO+/Qkt3yclls6Pj7yqxgsBPOrLfw== X-Received: by 2002:a54:4807:: with SMTP id j7mr7522204oij.48.1642686809834; Thu, 20 Jan 2022 05:53:29 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 23/33] domain_conf: format pnv-phb3-root-port empty addr Date: Thu, 20 Jan 2022 10:52:26 -0300 Message-Id: <20220120135236.719924-24-danielhb413@gmail.com> In-Reply-To: <20220120135236.719924-1-danielhb413@gmail.com> References: <20220120135236.719924-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: fbarrat@linux.ibm.com, 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.13 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: 1642686827467100001 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 1815308a8c..8e44e4b53c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2462,6 +2462,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) { @@ -6489,7 +6508,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, @@ -24151,6 +24171,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 4317039e8b..e4323d0e6f 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