]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Introduce @memReserve to <controller/>
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 11 Sep 2023 12:33:18 +0000 (14:33 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 19 Apr 2024 12:22:42 +0000 (14:22 +0200)
There are PCI devices with pretty large non-prefetchable memory,
for instance:

  Memory at 9d800000 (64-bit, non-prefetchable) [size=8M]
  Memory at a6800000 (64-bit, non-prefetchable) [size=16K]

For cold plugged devices this is not a problem, because firmware
sets PCI controllers in a way that make devices behind them just
work. Problem arises if such PCI device is to be hot plugged.
Since the PCI device wasn't present at cold boot, firmware could
not take it into calculations and the amount of reserved memory
is not sufficient.

Introduce a know that allows users overriding value computed by
FW and thus allow hot plug of such PCI devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
tests/qemuxmlconfdata/q35-usb2.x86_64-latest.xml
tests/qemuxmlconfdata/q35-usb2.xml

index e2f66b982c880b88d0a8e791527307a7dbaa97f1..83c1405c1749e37ce2b57c247220d90874b56ae9 100644 (file)
@@ -4153,6 +4153,12 @@ generated by libvirt. :since:`Since 1.2.19 (QEMU only)`.
 ``index``
    pci-root controllers for pSeries guests use this attribute to record the
    order they will show up in the guest. :since:`Since 3.6.0`
+``memReserve``
+   Some PCI devices have non-prefetchable memory bar larger than 2MiB. Use this
+   attribute to override value computed by firmware and thus make controller
+   reserve more memory (in KiB) so that such PCI device can be hot plugged.
+   For cold plugged PCI devices, the firmware will automatically reserve the
+   correct amount of memory. :since:`Since 10.3.0`
 
 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
index 48c5d546dacd726b55b3be284f0ebc45f50cc654..a0912062ff8a0ffc6658bcf57b1e54df4a0b19f4 100644 (file)
@@ -8528,6 +8528,11 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
                               &def->opts.pciopts.targetIndex,
                               def->opts.pciopts.targetIndex) < 0)
                 return NULL;
+
+            if (virXMLPropULongLong(targetNodes[0], "memReserve", 0,
+                                    VIR_XML_PROP_NONZERO,
+                                    &def->opts.pciopts.memReserve) < 0)
+                return NULL;
         }
     }
 
@@ -23095,6 +23100,10 @@ virDomainControllerDefFormatPCI(virBuffer *buf,
         virBufferAsprintf(&targetAttrBuf, " hotplug='%s'",
                           virTristateSwitchTypeToString(def->opts.pciopts.hotplug));
     }
+    if (def->opts.pciopts.memReserve) {
+        virBufferAsprintf(&targetAttrBuf, " memReserve='%llu'",
+                          def->opts.pciopts.memReserve);
+    }
 
     if (def->opts.pciopts.numaNode != -1)
         virBufferAsprintf(&targetChildBuf, "<node>%d</node>\n", def->opts.pciopts.numaNode);
index 5925faaf1a2847f87a3afd03baca512b4aaf8202..356c25405b2abc329045b42da81654d668660e9a 100644 (file)
@@ -738,6 +738,9 @@ struct _virDomainPCIControllerOpts {
      */
     int numaNode;
     virTristateSwitch hotplug; /* 'off' to prevent hotplug/unplug, default 'on' */
+
+    unsigned long long memReserve; /* used by pci-bridge and pcie-root-port,
+                                      0 == undef, KiB */
 };
 
 struct _virDomainUSBControllerOpts {
index f386e46fae15010a1feec9d7a3edbf6bc7e67d4e..d84e030255d151ae47dad0cdabf66a6ecab804c6 100644 (file)
                       <ref name="unsignedInt"/>
                     </element>
                   </optional>
+                  <optional>
+                    <attribute name="memReserve">
+                      <ref name="unsignedLong"/>
+                    </attribute>
+                  </optional>
                 </element>
               </optional>
               <!-- *-root controllers have an optional element "pcihole64"-->
index b860ae2dee66f7b432d621f9af3f2a55e65a7502..2bbbbfe34636e8943409eeda7a631d59818488a1 100644 (file)
@@ -30,7 +30,7 @@
     </controller>
     <controller type='pci' index='2' model='pci-bridge'>
       <model name='pci-bridge'/>
-      <target chassisNr='56'/>
+      <target chassisNr='56' memReserve='8196'/>
       <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
     </controller>
     <controller type='usb' index='0' model='ich9-ehci1'>
index 571782a17c3cbcd01e56929af6ea54cc27c3cd06..4f5a5580ac5a27d896bf8fe15b92e4f8a0aabbea 100644 (file)
@@ -25,7 +25,7 @@
     </controller>
     <controller type='pci' index='2' model='pci-bridge'>
       <model name='pci-bridge'/>
-      <target chassisNr='56'/>
+      <target chassisNr='56' memReserve='8196'/>
     </controller>
     <controller type='usb' index='0' model='ich9-ehci1'/>
     <controller type='usb' index='0' model='ich9-uhci1'/>