[PATCH v2 1/2] Add pcihole64 attribute to root PCI controllers

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

 



<controller type='pci' index='0' model='pci-root' pcihole64='1'/>

It can be used to adjust (or disable) the size of the 64-bit
PCI hole. The size attribute is in gigabytes, since it would
get rounded up to nearest GB by QEMU anyway.

Disabling it will be needed for guests that crash with the
64-bit PCI hole (like Windows XP), see:
https://bugzilla.redhat.com/show_bug.cgi?id=990418
---
 docs/formatdomain.html.in                          |  8 ++++++
 docs/schemas/domaincommon.rng                      | 32 ++++++++++++++++------
 src/conf/domain_conf.c                             | 17 ++++++++++++
 src/conf/domain_conf.h                             |  8 ++++++
 .../qemuxml2argv-pcihole64-none.xml                | 21 ++++++++++++++
 .../qemuxml2argv-pcihole64-q35.xml                 | 31 +++++++++++++++++++++
 tests/qemuxml2argvdata/qemuxml2argv-pcihole64.xml  | 21 ++++++++++++++
 tests/qemuxml2xmltest.c                            |  4 +++
 8 files changed, 134 insertions(+), 8 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcihole64-none.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcihole64.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 83d551a..3475022 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2344,6 +2344,14 @@
       PCI controllers have an optional <code>model</code> attribute with
       possible values <code>pci-root</code>, <code>pcie-root</code>,
       <code>pci-bridge</code>, or <code>dmi-to-pci-bridge</code>.
+      The root controllers (<code>pci-root</code> and <code>pcie-root</code>)
+      have an optional <code>pcihole64</code> attribute specifying how big
+      (in gigabytes) the 64-bit PCI hole should be. Some guests (like
+      Windows XP or Windows Server 2003) might crash when QEMU and Seabios
+      are recent enough to support 64-bit PCI holes, unless this is disabled
+      (set to 0). <span class="since">Since 1.1.2 (QEMU only)</span>
+    </p>
+    <p>
       For machine types which provide an implicit PCI bus, the pci-root
       controller with index=0 is auto-added and required to use PCI devices.
       pci-root has no address.
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ac807e6..2cff4d8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1541,14 +1541,30 @@
             <attribute name="type">
               <value>pci</value>
             </attribute>
-            <attribute name="model">
-              <choice>
-                <value>pci-root</value>
-                <value>pcie-root</value>
-                <value>pci-bridge</value>
-                <value>dmi-to-pci-bridge</value>
-              </choice>
-            </attribute>
+            <!-- *-root controllers have an optional attribute "pcihole64"-->
+            <choice>
+              <group>
+                <attribute name="model">
+                  <choice>
+                    <value>pci-root</value>
+                    <value>pcie-root</value>
+                  </choice>
+                </attribute>
+                <optional>
+                  <attribute name="pcihole64">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+              </group>
+              <group>
+                <attribute name="model">
+                  <choice>
+                    <value>pci-bridge</value>
+                    <value>dmi-to-pci-bridge</value>
+                  </choice>
+                </attribute>
+              </group>
+            </choice>
           </group>
           <!-- virtio-serial has optional "ports" and "vectors" -->
           <group>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7309877..5c044e9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5614,6 +5614,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
     char *idx = NULL;
     char *model = NULL;
     char *queues = NULL;
+    char *pcihole64 = NULL;
 
     if (VIR_ALLOC(def) < 0)
         return NULL;
@@ -5737,6 +5738,16 @@ virDomainControllerDefParseXML(xmlNodePtr node,
                                  "should have index 0"));
                 goto error;
             }
+            if ((pcihole64 = virXMLPropString(node, "pcihole64"))) {
+                def->opts.pciopts.pcihole64 = true;
+                if (virStrToLong_ui(pcihole64, NULL, 10,
+                                    &def->opts.pciopts.pcihole64size) < 0) {
+                    virReportError(VIR_ERR_XML_ERROR,
+                                   _("Cannot parse pcihole64 size %s"),
+                                   pcihole64);
+                    goto error;
+                }
+            }
 
         }
 
@@ -14491,6 +14502,12 @@ virDomainControllerDefFormat(virBufferPtr buf,
         }
         break;
 
+    case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
+        if (def->opts.pciopts.pcihole64)
+            virBufferAsprintf(buf, " pcihole64='%u'",
+                              def->opts.pciopts.pcihole64size);
+        break;
+
     default:
         break;
     }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3e118d6..e20c7a9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -811,6 +811,13 @@ struct _virDomainVirtioSerialOpts {
     int vectors; /* -1 == undef */
 };
 
+typedef struct _virDomainPciControllerOpts virDomainPciControllerOpts;
+typedef virDomainPciControllerOpts *virDomainPciControllerOptsPtr;
+struct _virDomainPciControllerOpts {
+    bool pcihole64;
+    unsigned int pcihole64size;
+};
+
 /* Stores the virtual disk controller configuration */
 struct _virDomainControllerDef {
     int type;
@@ -819,6 +826,7 @@ struct _virDomainControllerDef {
     unsigned int queues;
     union {
         virDomainVirtioSerialOpts vioserial;
+        virDomainPciControllerOpts pciopts;
     } opts;
     virDomainDeviceInfo info;
 };
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-none.xml
new file mode 100644
index 0000000..762b529
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-none.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+  <name>foo</name>
+  <uuid>c84fc647-6198-4ff9-bf81-d65a1f8f5ec0</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-1.2'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <controller type='pci' index='0' model='pci-root' pcihole64='0'/>
+    <controller type='usb' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
new file mode 100644
index 0000000..92e92ff
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+  <name>q35-test</name>
+  <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='q35'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='sda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pcie-root' pcihole64='1'/>
+    <controller type='pci' index='1' model='dmi-to-pci-bridge'/>
+    <controller type='pci' index='2' model='pci-bridge'/>
+    <controller type='sata' index='0'/>
+    <video>
+      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64.xml
new file mode 100644
index 0000000..397f0c0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+  <name>foo</name>
+  <uuid>3c7c30b5-7866-4b05-8a29-efebccba52a0</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-1.2'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <controller type='pci' index='0' model='pci-root' pcihole64='1'/>
+    <controller type='usb' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5c6730d..96b94ac 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -309,6 +309,10 @@ mymain(void)
 
     DO_TEST_DIFFERENT("s390-defaultconsole");
 
+    DO_TEST("pcihole64");
+    DO_TEST("pcihole64-none");
+    DO_TEST("pcihole64-q35");
+
     virObjectUnref(driver.caps);
     virObjectUnref(driver.xmlopt);
 
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]