[PATCH v2 1/4] pm/i386: add support for two options that controls acpi hotplug on q35/i440fx

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

 



'acpi-pci-hotplug-with-bridge-support' and 'acpi-root-pci-hotplug' are two pm
options for i386 that governs acpi pci hotplug support for qemu. This patch tries
to implement support for both these two global i386 pm options within libvirt.

'acpi-pci-hotplug-with-bridge-support' applies both for q35 as well as i440fx
machine types. The 'acpi-root-pci-hotplug' only applies for i440fx machine type.

'acpi-pci-hotplug-with-bridge-support' can be turned off by providing the
following libvirt xml snippet:

<pm>
   <acpi-hotplug-bridge enabled='no'>
</pm>

Similarly, 'acpi-root-pci-hotplug' can be turned off by providing the following
libvirt xml snippet:

<pm>
   <acpi-root-hotplug enabled='no'>
</pm>

Similarly for turning them on explicitly, they can pass " enabled='yes' " in
the above xml snippet.

Unit tests for this change will be added in subsequent patches.

Signed-off-by: Ani Sinha <ani@xxxxxxxxxxx>
---
 docs/schemas/domaincommon.rng                 | 17 +++++++++++
 src/conf/domain_conf.c                        | 21 +++++++++++++-
 src/conf/domain_conf.h                        |  2 ++
 src/qemu/qemu_capabilities.c                  |  8 ++++++
 src/qemu/qemu_capabilities.h                  |  5 ++++
 src/qemu/qemu_command.c                       | 28 +++++++++++++++++++
 src/qemu/qemu_validate.c                      | 21 ++++++++++++++
 .../caps_2.11.0.x86_64.xml                    |  1 +
 .../caps_2.12.0.x86_64.xml                    |  1 +
 .../caps_3.0.0.x86_64.xml                     |  1 +
 .../caps_3.1.0.x86_64.xml                     |  1 +
 .../caps_4.0.0.x86_64.xml                     |  1 +
 .../caps_4.1.0.x86_64.xml                     |  1 +
 .../caps_4.2.0.x86_64.xml                     |  1 +
 .../caps_5.0.0.x86_64.xml                     |  1 +
 .../caps_5.1.0.x86_64.xml                     |  1 +
 .../caps_5.2.0.x86_64.xml                     |  2 ++
 .../caps_6.0.0.x86_64.xml                     |  2 ++
 .../caps_6.1.0.x86_64.xml                     |  3 ++
 19 files changed, 117 insertions(+), 1 deletion(-)

changelog:
v1: initial version.
v2: added code to generate output xml correctly.

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 2442078969..e2d9bb336c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4317,6 +4317,16 @@
             <ref name="suspendChoices"/>
           </element>
         </optional>
+        <optional>
+          <element name="acpi-hotplug-bridge">
+            <ref name="acpiHotplugChoices"/>
+          </element>
+        </optional>
+        <optional>
+          <element name="acpi-root-hotplug">
+            <ref name="acpiHotplugChoices"/>
+          </element>
+        </optional>
       </interleave>
       <empty/>
     </element>
@@ -4328,6 +4338,13 @@
       </attribute>
     </optional>
   </define>
+  <define name="acpiHotplugChoices">
+    <optional>
+      <attribute name="enabled">
+        <ref name="virYesNo"/>
+      </attribute>
+    </optional>
+  </define>
   <!--
       Specific setup for a qemu emulated character device.  Note: this
       definition doesn't fully specify the constraints on this node.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 06c1fcf5e5..778a44e08e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19351,6 +19351,16 @@ virDomainDefLifecycleParse(virDomainDef *def,
                                  &def->pm.s4) < 0)
         goto error;
 
+    if (virDomainPMStateParseXML(ctxt,
+                                 "string(./pm/acpi-hotplug-bridge/@enabled)",
+                                 &def->pm.acpi_hp_bridge) < 0)
+        goto error;
+
+    if (virDomainPMStateParseXML(ctxt,
+                                 "string(./pm/acpi-root-hotplug/@enabled)",
+                                 &def->pm.acpi_root_hp) < 0)
+        goto error;
+
     return 0;
 
  error:
@@ -28179,7 +28189,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
                                       virDomainLockFailureTypeToString) < 0)
         return -1;
 
-    if (def->pm.s3 || def->pm.s4) {
+    if (def->pm.s3 || def->pm.s4 || def->pm.acpi_hp_bridge ||
+        def->pm.acpi_root_hp) {
         virBufferAddLit(buf, "<pm>\n");
         virBufferAdjustIndent(buf, 2);
         if (def->pm.s3) {
@@ -28190,6 +28201,14 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
             virBufferAsprintf(buf, "<suspend-to-disk enabled='%s'/>\n",
                               virTristateBoolTypeToString(def->pm.s4));
         }
+        if (def->pm.acpi_hp_bridge) {
+            virBufferAsprintf(buf, "<acpi-hotplug-bridge enabled='%s'/>\n",
+                              virTristateBoolTypeToString(def->pm.acpi_hp_bridge));
+        }
+        if (def->pm.acpi_root_hp) {
+            virBufferAsprintf(buf, "<acpi-root-hotplug enabled='%s'/>\n",
+                              virTristateBoolTypeToString(def->pm.acpi_root_hp));
+        }
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</pm>\n");
     }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ca21082624..94283cbb04 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2643,6 +2643,8 @@ struct _virDomainPowerManagement {
     /* These options are of type enum virTristateBool */
     int s3;
     int s4;
+    int acpi_hp_bridge;
+    int acpi_root_hp;
 };
 
 struct _virDomainPerfDef {
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9558938866..ba0665474c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -637,6 +637,11 @@ VIR_ENUM_IMPL(virQEMUCaps,
               "confidential-guest-support",
               "query-display-options",
               "s390-pv-guest",
+              "piix4-acpi-hotplug-bridge",
+              "piix4-acpi-root-hotplug-en",
+
+              /* 410 */
+              "ich9-acpi-hotplug-bridge",
     );
 
 
@@ -1467,6 +1472,8 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsIDEDrive[] = {
 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPiix4PM[] = {
     { "disable_s3", QEMU_CAPS_PIIX_DISABLE_S3, NULL },
     { "disable_s4", QEMU_CAPS_PIIX_DISABLE_S4, NULL },
+    { "acpi-pci-hotplug-with-bridge-support", QEMU_CAPS_PIIX_ACPI_HOTPLUG_BRIDGE, NULL },
+    { "acpi-root-pci-hotplug", QEMU_CAPS_PIIX_ACPI_ROOT_PCI_HOTPLUG, NULL },
 };
 
 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBRedir[] = {
@@ -1519,6 +1526,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioGpu[] = {
 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsICH9[] = {
     { "disable_s3", QEMU_CAPS_ICH9_DISABLE_S3, NULL },
     { "disable_s4", QEMU_CAPS_ICH9_DISABLE_S4, NULL },
+    { "acpi-pci-hotplug-with-bridge-support", QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE, NULL },
 };
 
 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBNECXHCI[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2b1bb57a49..e988527f39 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -617,6 +617,11 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT, /* -machine confidential-guest-support */
     QEMU_CAPS_QUERY_DISPLAY_OPTIONS, /* 'query-display-options' qmp command present */
     QEMU_CAPS_S390_PV_GUEST, /* -object s390-pv-guest,... */
+    QEMU_CAPS_PIIX_ACPI_HOTPLUG_BRIDGE, /* -M pc PIIX4_PM.acpi-pci-hotplug-with-bridge-support */
+    QEMU_CAPS_PIIX_ACPI_ROOT_PCI_HOTPLUG, /* -M pc PIIX4_PM.acpi-root-pci-hotplug */
+
+    /* 410 */
+    QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE, /* -M q35 PIIX4_PM.acpi-pci-hotplug-with-bridge-support */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 156af4caee..16c609202c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6171,6 +6171,34 @@ qemuBuildPMCommandLine(virCommand *cmd,
                                pm_object, def->pm.s4 == VIR_TRISTATE_BOOL_NO);
     }
 
+    if (def->pm.acpi_hp_bridge) {
+        const char *pm_object = "PIIX4_PM";
+        const char *switch_str = "on";
+
+        if (def->pm.acpi_hp_bridge == VIR_TRISTATE_BOOL_NO)
+            switch_str = "off";
+
+        if (qemuDomainIsQ35(def) &&
+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE))
+            pm_object = "ICH9-LPC";
+
+        virCommandAddArg(cmd, "-global");
+        virCommandAddArgFormat(cmd, "%s.acpi-pci-hotplug-with-bridge-support=%s",
+                               pm_object, switch_str);
+    }
+
+    if (def->pm.acpi_root_hp) {
+        const char *pm_object = "PIIX4_PM";
+        const char *switch_str = "on";
+
+        if (def->pm.acpi_root_hp == VIR_TRISTATE_BOOL_NO)
+            switch_str = "off";
+
+        virCommandAddArg(cmd, "-global");
+        virCommandAddArgFormat(cmd, "%s.acpi-root-pci-hotplug=%s",
+                               pm_object, switch_str);
+    }
+
     return 0;
 }
 
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index a964c8593d..22403e6d01 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -560,6 +560,27 @@ qemuValidateDomainDefPM(const virDomainDef *def,
         }
     }
 
+    if (def->pm.acpi_hp_bridge) {
+        bool q35ICH9_pcihpbr = q35Dom &&
+                                virQEMUCapsGet(qemuCaps,
+                                              QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE);
+
+        if (!q35ICH9_pcihpbr && !virQEMUCapsGet(qemuCaps,
+                                                QEMU_CAPS_PIIX_ACPI_HOTPLUG_BRIDGE)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           "%s", _("setting ACPI hotplug bridge not supported"));
+            return -1;
+        }
+    }
+
+    if (def->pm.acpi_root_hp) {
+        if (!q35Dom && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_ACPI_ROOT_PCI_HOTPLUG)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           "%s", _("setting ACPI root pci hotplug not supported"));
+            return -1;
+        }
+    }
+
     return 0;
 }
 
diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml
index 37fb33e8e3..75ebb88dd8 100644
--- a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml
@@ -196,6 +196,7 @@
   <flag name='cpu-max'/>
   <flag name='vnc-opts'/>
   <flag name='input-linux'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>2011000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100288</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
index 37aaabe0d3..dbf77b04a1 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
@@ -207,6 +207,7 @@
   <flag name='cpu-max'/>
   <flag name='vnc-opts'/>
   <flag name='input-linux'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>2011090</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100289</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
index f45fd84aaa..9cde4a95a3 100644
--- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml
@@ -213,6 +213,7 @@
   <flag name='cpu-max'/>
   <flag name='vnc-opts'/>
   <flag name='input-linux'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>3000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100239</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml
index dcc5f6f137..5dcf3b5a08 100644
--- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml
@@ -217,6 +217,7 @@
   <flag name='vnc-opts'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>3000092</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100240</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
index 7eff08235e..7ab188072d 100644
--- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
@@ -225,6 +225,7 @@
   <flag name='rotation-rate'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>4000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100240</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
index 736b120547..bacb5f8dd2 100644
--- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
@@ -232,6 +232,7 @@
   <flag name='rotation-rate'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>4001000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100241</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
index 8352fd0200..e89655d209 100644
--- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml
@@ -243,6 +243,7 @@
   <flag name='rotation-rate'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>4002000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100242</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml
index 6a99f4e343..058c943716 100644
--- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml
@@ -250,6 +250,7 @@
   <flag name='rotation-rate'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>5000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100241</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml
index 674d984432..85e9ba95d0 100644
--- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml
@@ -252,6 +252,7 @@
   <flag name='rotation-rate'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
   <version>5001000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100242</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml
index ec3384cab8..190e36719a 100644
--- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml
@@ -253,6 +253,8 @@
   <flag name='rotation-rate'/>
   <flag name='input-linux'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
+  <flag name='piix4-acpi-root-hotplug-en'/>
   <version>5002000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100243</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml
index d6198c2479..cf9c06470d 100644
--- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml
@@ -260,6 +260,8 @@
   <flag name='input-linux'/>
   <flag name='confidential-guest-support'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
+  <flag name='piix4-acpi-root-hotplug-en'/>
   <version>6000000</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100242</microcodeVersion>
diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml
index 933b8eb2b5..e3a7d231ce 100644
--- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml
@@ -262,6 +262,9 @@
   <flag name='virtio-vga-gl'/>
   <flag name='confidential-guest-support'/>
   <flag name='query-display-options'/>
+  <flag name='piix4-acpi-hotplug-bridge'/>
+  <flag name='piix4-acpi-root-hotplug-en'/>
+  <flag name='ich9-acpi-hotplug-bridge'/>
   <version>6000090</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>43100243</microcodeVersion>
-- 
2.25.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