[PATCH 25/33] domain_validate.c: allow targetIndex 0 out of idx 0 for PowerNV PHBs

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

 



PowerNV PHBs uses the 'targetIndex' attribute in a different manner than
pSeries PHBs, having no restiction of targetIndex = 0 in controllers
with non-zero indexes.

This can happen when the domain has 2 or more sockets and the pnv-phb3
controller can have targetIndex=0 in a different chip-id.

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/conf/domain_validate.c                    |  5 ++-
 src/qemu/qemu_domain.c                        |  2 +-
 src/qemu/qemu_validate.c                      |  5 +++
 .../qemuxml2argvdata/powernv8-two-sockets.xml | 26 +++++++++++++
 .../powernv8-two-sockets.xml                  | 38 +++++++++++++++++++
 tests/qemuxml2xmltest.c                       |  3 ++
 6 files changed, 76 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/powernv8-two-sockets.xml
 create mode 100644 tests/qemuxml2xmloutdata/powernv8-two-sockets.xml

diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index e9baf1d41a..5510cb073b 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -1055,8 +1055,9 @@ virDomainControllerDefValidate(const virDomainControllerDef *controller)
                 return -1;
             }
 
-            if ((controller->idx == 0 && opts->targetIndex != 0) ||
-                (controller->idx != 0 && opts->targetIndex == 0)) {
+            if (!virDomainControllerIsPowerNVPHB(controller) &&
+                ((controller->idx == 0 && opts->targetIndex != 0) ||
+                 (controller->idx != 0 && opts->targetIndex == 0))) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("Only the PCI controller with index 0 can "
                                  "have target index 0, and vice versa"));
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d0bb4938ec..25523a6020 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5100,7 +5100,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
 
         /* pSeries guests can have multiple pci-root controllers,
          * but other machine types only support a single one */
-        if (!qemuDomainIsPSeries(def) &&
+        if (!qemuDomainIsPowerPC(def) &&
             (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
              cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) &&
             cont->idx != 0) {
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index b101ea8064..3be29af958 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -3697,6 +3697,11 @@ qemuValidateDomainDeviceDefControllerPCI(const virDomainControllerDef *cont,
             break;
         }
 
+        /* PowerNV domains, like pSeries guest, can also have
+         * multiple PHBs. */
+        if (virDomainControllerIsPowerNVPHB(cont))
+            break;
+
         /* For all other pci-root and pcie-root controllers, though,
          * the index must be zero */
         if (cont->idx != 0) {
diff --git a/tests/qemuxml2argvdata/powernv8-two-sockets.xml b/tests/qemuxml2argvdata/powernv8-two-sockets.xml
new file mode 100644
index 0000000000..c6f2024a33
--- /dev/null
+++ b/tests/qemuxml2argvdata/powernv8-two-sockets.xml
@@ -0,0 +1,26 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>b20fcfe3-4a0a-4039-8735-9e024256e0f7</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='ppc64' machine='powernv8'>hvm</type>
+  </os>
+  <cpu>
+    <topology sockets='2' dies='1' cores='1' threads='1'/>
+  </cpu>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='pci' index='0' model='pcie-root'>
+      <model name='pnv-phb3'/>
+      <target index='0' chip-id='0'/>
+    </controller>
+    <controller type='pci' index='1' model='pcie-root'>
+      <model name='pnv-phb3'/>
+      <target index='0' chip-id='1'/>
+    </controller>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/powernv8-two-sockets.xml b/tests/qemuxml2xmloutdata/powernv8-two-sockets.xml
new file mode 100644
index 0000000000..10b4794877
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/powernv8-two-sockets.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>b20fcfe3-4a0a-4039-8735-9e024256e0f7</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='ppc64' machine='powernv8'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <topology sockets='2' dies='1' cores='1' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='pci' index='0' model='pcie-root'>
+      <model name='pnv-phb3'/>
+      <target index='0' chip-id='0'/>
+    </controller>
+    <controller type='pci' index='1' model='pcie-root'>
+      <model name='pnv-phb3'/>
+      <target index='0' chip-id='1'/>
+    </controller>
+    <serial type='pty'>
+      <target type='isa-serial' port='0'>
+        <model name='isa-serial'/>
+      </target>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+    <audio id='1' type='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 322a1b47cc..5ed8283546 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -644,6 +644,9 @@ mymain(void)
             QEMU_CAPS_DEVICE_ISA_SERIAL,
             QEMU_CAPS_DEVICE_PNV_PHB3,
             QEMU_CAPS_DEVICE_PNV_PHB3_ROOT_PORT);
+    DO_TEST("powernv8-two-sockets",
+            QEMU_CAPS_DEVICE_ISA_SERIAL,
+            QEMU_CAPS_DEVICE_PNV_PHB3);
 
     DO_TEST("pseries-nvram",
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-- 
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