[PATCH 20/33] 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 ++++++++++++++++++-
 tests/qemuxml2xmloutdata/powernv8-basic.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 9c2ea5cf00..7ffdfa6478 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 f7d73f7c2e..b101ea8064 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -3733,6 +3733,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:
@@ -3740,7 +3758,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.xml b/tests/qemuxml2xmloutdata/powernv8-basic.xml
index 0a093367f2..fe918480eb 100644
--- a/tests/qemuxml2xmloutdata/powernv8-basic.xml
+++ b/tests/qemuxml2xmloutdata/powernv8-basic.xml
@@ -16,7 +16,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.34.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