[PATCH RESEND v2 3/4] qemu: command: add support for acpi-bridge-hotplug feature

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

 



This change adds backend qemu command line support for new libvirt
global feature 'acpi-bridge-hotplug'. This option can be used as
following:

<feature>
  <pci>
    <acpi-bridge-hotplug state='off|on'/>
  </pci>
</feature>

The '<pci>' sub-element under '<feature>' is also newly introduced.

'acpi-bridge-hotplug' turns on the following command line option to
qemu for x86 guests:

(pc): -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=<off|on>

(q35): -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=<off|on>

This change also adds the required qemuxml2argv unit tests in order to
test correct qemu arguments. Unit tests have also been added to test
qemu capability validation checks as well as checks for using this
option with the right architecture.

Signed-off-by: Ani Sinha <ani@xxxxxxxxxxx>
---
 src/qemu/qemu_command.c                       | 19 ++++++++++
 ...-hotplug-bridge-disable.aarch64-latest.err |  1 +
 ...-hotplug-bridge-disable.x86_64-latest.args | 35 +++++++++++++++++
 ...pi-hotplug-bridge-disable.x86_64-6.0.0.err |  1 +
 ...-hotplug-bridge-disable.x86_64-latest.args | 38 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  7 ++++
 6 files changed, 101 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/aarch64-acpi-hotplug-bridge-disable.aarch64-latest.err
 create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-6.0.0.err
 create mode 100644 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-latest.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c836799888..206a9794cb 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6280,6 +6280,7 @@ qemuBuildPMCommandLine(virCommand *cmd,
                        qemuDomainObjPrivate *priv)
 {
     virQEMUCaps *qemuCaps = priv->qemuCaps;
+    int acpihp_br = def->pci_features[VIR_DOMAIN_PCI_ACPI_BRIDGE_HOTPLUG];
 
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SET_ACTION)) {
         /* with new qemu we always want '-no-shutdown' on startup and we set
@@ -6325,6 +6326,24 @@ qemuBuildPMCommandLine(virCommand *cmd,
                                pm_object, def->pm.s4 == VIR_TRISTATE_BOOL_NO);
     }
 
+    if (acpihp_br != VIR_TRISTATE_SWITCH_ABSENT) {
+        const char *pm_object = NULL;
+
+        if (!qemuDomainIsQ35(def))
+            pm_object = "PIIX4_PM";
+
+        if (qemuDomainIsQ35(def) &&
+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE))
+            pm_object = "ICH9-LPC";
+
+        if (pm_object != NULL) {
+            virCommandAddArg(cmd, "-global");
+            virCommandAddArgFormat(cmd, "%s.acpi-pci-hotplug-with-bridge-support=%s",
+                                   pm_object,
+                                   virTristateSwitchTypeToString(acpihp_br));
+        }
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxml2argvdata/aarch64-acpi-hotplug-bridge-disable.aarch64-latest.err b/tests/qemuxml2argvdata/aarch64-acpi-hotplug-bridge-disable.aarch64-latest.err
new file mode 100644
index 0000000000..9f0a88b826
--- /dev/null
+++ b/tests/qemuxml2argvdata/aarch64-acpi-hotplug-bridge-disable.aarch64-latest.err
@@ -0,0 +1 @@
+unsupported configuration: acpi-bridge-hotplug is not available for architecture 'aarch64'
diff --git a/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.x86_64-latest.args b/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.x86_64-latest.args
new file mode 100644
index 0000000000..90527dfefd
--- /dev/null
+++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.x86_64-latest.args
@@ -0,0 +1,35 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-i440fx \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-i440fx/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-i440fx/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-i440fx/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=i440fx,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-i440fx/master-key.aes"}' \
+-machine pc-i440fx-2.5,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-accel tcg \
+-cpu qemu64 \
+-m 1024 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 56f5055c-1b8d-490c-844a-ad646a1caaaa \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off \
+-boot strict=on \
+-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-6.0.0.err b/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-6.0.0.err
new file mode 100644
index 0000000000..8c09a3cd76
--- /dev/null
+++ b/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-6.0.0.err
@@ -0,0 +1 @@
+unsupported configuration: acpi-bridge-hotplug is not available with this QEMU binary
diff --git a/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-latest.args b/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-latest.args
new file mode 100644
index 0000000000..6e3aeb1f30
--- /dev/null
+++ b/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.x86_64-latest.args
@@ -0,0 +1,38 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-q35 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-q35/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-q35/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-q35/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=q35,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-q35/master-key.aes"}' \
+-machine pc-q35-2.5,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-accel tcg \
+-cpu qemu64 \
+-m 1024 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 56f5055c-1b8d-490c-844a-ad646a1caaaa \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off \
+-boot strict=on \
+-device '{"driver":"i82801b11-bridge","id":"pci.1","bus":"pcie.0","addr":"0x1e"}' \
+-device '{"driver":"pci-bridge","chassis_nr":2,"id":"pci.2","bus":"pci.1","addr":"0x0"}' \
+-device '{"driver":"ioh3420","port":8,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1"}' \
+-device '{"driver":"qemu-xhci","id":"usb","bus":"pci.3","addr":"0x0"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.2","addr":"0x1"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ce475df466..bc4f9cbcf1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2592,6 +2592,13 @@ mymain(void)
     DO_TEST_CAPS_LATEST("pc-i440fx-acpi-root-hotplug-enable");
     DO_TEST_CAPS_VER_PARSE_ERROR("pc-i440fx-acpi-root-hotplug-disable", "5.1.0");
     DO_TEST_CAPS_VER_PARSE_ERROR("pc-i440fx-acpi-root-hotplug-enable", "5.1.0");
+    DO_TEST_CAPS_LATEST("q35-acpi-hotplug-bridge-disable");
+    DO_TEST_CAPS_LATEST("pc-i440fx-acpi-hotplug-bridge-disable");
+    DO_TEST_CAPS_VER_PARSE_ERROR("q35-acpi-hotplug-bridge-disable", "6.0.0");
+    /* verify that we fail when acpi-bridge-hotplug option is specified for
+     * archs other than x86
+     */
+    DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("aarch64-acpi-hotplug-bridge-disable", "aarch64");
     DO_TEST("q35-usb2",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
-- 
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