[PATCH v3 17/29] conf, qemu: add default 'targetIndex' value for pnv-phb3 devs

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

 



As done with the 'chip-id' attribute, use zero as a default
targetIndex value for pnv-phb3 devices in case it's absent
from the controller definition.

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/qemu/qemu_domain_address.c                |  2 ++
 src/qemu/qemu_validate.c                      | 19 ++++++++++++++++++-
 .../powernv8-basic.ppc64-latest.xml           |  2 +-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index b72a9b7bf4..d9dcea6581 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -2858,6 +2858,8 @@ qemuDomainAssignPCIAddresses(virDomainDef *def,
                 if (options->chipId == -1)
                     options->chipId = 0;
 
+                if (options->targetIndex == -1)
+                    options->targetIndex = 0;
                 break;
             case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
             case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE:
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 84a599d577..ad1deb9b56 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -3737,6 +3737,24 @@ qemuValidateDomainDeviceDefControllerPCI(const virDomainControllerDef *cont,
         }
         break;
 
+    case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+        /* PHBs for PowerNV domains must have a targetIndex */
+        if (pciopts->targetIndex == -1 &&
+            virDomainControllerIsPowerNVPHB(cont)) {
+            virReportControllerMissingOption(cont, model, modelName, "targetIndex");
+            return -1;
+        }
+
+        /*
+         * targetIndex for pcie-root controllers only applies to
+         * PowerNV PHBs.
+         */
+        if (pciopts->targetIndex != -1 &&
+            !virDomainControllerIsPowerNVPHB(cont)) {
+            virReportControllerInvalidOption(cont, model, modelName, "targetIndex");
+            return -1;
+        }
+        break;
     case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
     case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
@@ -3744,7 +3762,6 @@ qemuValidateDomainDeviceDefControllerPCI(const virDomainControllerDef *cont,
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
     case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
-    case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE:
         if (pciopts->targetIndex != -1) {
             virReportControllerInvalidOption(cont, model, modelName, "targetIndex");
diff --git a/tests/qemuxml2xmloutdata/powernv8-basic.ppc64-latest.xml b/tests/qemuxml2xmloutdata/powernv8-basic.ppc64-latest.xml
index 28d86d7d9e..bd22d85f6a 100644
--- a/tests/qemuxml2xmloutdata/powernv8-basic.ppc64-latest.xml
+++ b/tests/qemuxml2xmloutdata/powernv8-basic.ppc64-latest.xml
@@ -19,7 +19,7 @@
     <emulator>/usr/bin/qemu-system-ppc64</emulator>
     <controller type='pci' index='0' model='pcie-root'>
       <model name='pnv-phb3'/>
-      <target chip-id='0'/>
+      <target index='0' chip-id='0'/>
     </controller>
     <serial type='pty'>
       <target type='isa-serial' port='0'>
-- 
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