[PATCH v3 20/29] domain_conf: always format pnv-phb3-root-port address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



pnv-phb3-root-ports can use an all zeroed address (0000:00:0.0) as a way
of connecting to a PHB3 bus that has index 0. Today, these addresses
aren't being displayed in the domain XML due to the use of
virPCIDeviceAddressIsEmpty() inside virDomainDeviceInfoFormat(), where
0000:00:0.0 is considered an empty address and thus not displayed,
regardless of the user manually adding

    <address type='pci' domain='0x0000' bus='0x00' slot='0x00' function='0x0'/>

in the domain XML.

Changing virPCIDeviceAddressIsEmpty() to recognize the difference
between an user adding a zeroed address by hand, versus all the other
current cases in which this function is used (e.g. to check whether an
address should be assigned or not), is not trivial and will change a lot
of existing, working code, to accomodate a niche case of a new device we
want to add.

Instead, this patch adds a new VIR_DOMAIN_DEF_FORMAT_PCI_ADDR_ALWAYS
flag to be used by virDomainDefFormatFlags that will allow for an
<address> element to always be formatted regardless of
virPCIDeviceAddressIsEmpty() mechanics/semantics. Then we use this flag
when formatting pnv-phb3-root-port devices.

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 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 f72045eb39..625949e44e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2466,6 +2466,25 @@ virDomainControllerIsPowerNVPHB(const virDomainControllerDef *cont)
 }
 
 
+static bool
+virDomainControllerIsPowerNVRootPort(const virDomainControllerDef *cont)
+{
+    virDomainControllerPCIModelName name;
+
+    if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_PCI ||
+        cont->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT) {
+        return false;
+    }
+
+    name = cont->opts.pciopts.modelName;
+
+    if (name != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT)
+        return false;
+
+    return true;
+}
+
+
 virDomainFSDef *
 virDomainFSDefNew(virDomainXMLOption *xmlopt)
 {
@@ -6509,7 +6528,8 @@ virDomainDeviceInfoFormat(virBuffer *buf,
 
     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_PCI_ADDR_ALWAYS) {
             virBufferAsprintf(&attrBuf, " domain='0x%04x' bus='0x%02x' "
                               "slot='0x%02x' function='0x%d'",
                               info->addr.pci.domain,
@@ -23911,6 +23931,9 @@ virDomainControllerDefFormat(virBuffer *buf,
         }
     }
 
+    if (virDomainControllerIsPowerNVRootPort(def))
+        flags |= VIR_DOMAIN_DEF_FORMAT_PCI_ADDR_ALWAYS;
+
     virDomainControllerDriverFormat(&childBuf, def);
 
     virDomainDeviceInfoFormat(&childBuf, &def->info, flags);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 404289aa26..835b8111e0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3508,6 +3508,8 @@ typedef enum {
     VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM       = 1 << 6,
     VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT      = 1 << 7,
     VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST    = 1 << 8,
+    /* always format the PCI address */
+    VIR_DOMAIN_DEF_FORMAT_PCI_ADDR_ALWAYS  = 1 << 9,
 } virDomainDefFormatFlags;
 
 /* Use these flags to skip specific domain ABI consistency checks done
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux