From nobody Tue Feb 10 08:26:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1631417283332897.2184880974688; Sat, 11 Sep 2021 20:28:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-cYq-0w81O1CF0AFFoS5bCA-1; Sat, 11 Sep 2021 23:27:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8776281426E; Sun, 12 Sep 2021 03:27:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B9D7102AE54; Sun, 12 Sep 2021 03:27:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 332204EA29; Sun, 12 Sep 2021 03:27:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18C3Qtkv032414 for ; Sat, 11 Sep 2021 23:26:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8DDF92166B1C; Sun, 12 Sep 2021 03:26:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88F7B2166B3F for ; Sun, 12 Sep 2021 03:26:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D541185A794 for ; Sun, 12 Sep 2021 03:26:55 +0000 (UTC) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-YdxXMGIiNCWTs0vt1HzisQ-1; Sat, 11 Sep 2021 23:26:53 -0400 Received: by mail-pj1-f53.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so4227028pjr.1 for ; Sat, 11 Sep 2021 20:26:53 -0700 (PDT) Received: from anisinha-lenovo.ba.nuagenetworks.net ([115.96.79.166]) by smtp.googlemail.com with ESMTPSA id w5sm2854343pfu.160.2021.09.11.20.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Sep 2021 20:26:52 -0700 (PDT) X-MC-Unique: cYq-0w81O1CF0AFFoS5bCA-1 X-MC-Unique: YdxXMGIiNCWTs0vt1HzisQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OCDIPKOs5svW4Pq63etulHmFdIYZRq4286lFWgAp4Tw=; b=3HGWmrQFSNoElxp9ucNsGSyIrF3GyS81BsVszdggvr9H0amZnGx3yLC86x+KtIvRRW Dz7ldR8VUk3dwP2vrR3rFQWpWGwy+iRAswECCjFyZx4GEUUvZS/SzIT7lNvJEvfhOFzV TXA2XTMI+3EizyhuetgtYtcxuz4sWdNCu+aiRZ1xZIE+8CveDk8lboGNngKeHuzdkVx+ hcjrvHL/yUQq1vhNDsDytpTX3PPNpBy1yxRCY+klBTdgUSJGXDZ2YbKQSLDO1SwiH9ch slABnfBn3ookC2l4N3oemydX3pBbcByaU0rFQ8U303KS8sDSQVfkT4bnxMdJxTa7rcIY 4/PQ== X-Gm-Message-State: AOAM532mhg/GccTpwW5iki0Fw07Zh2N42IMTWsxD8wh1m9/ozjWjavNu 9XMdhChVGfXOhXDY+PRmxteo+Y2ePPiRrQ== X-Google-Smtp-Source: ABdhPJwZhhCCLY906ypTP5C/nvM/FbR1CALQj8JFtSh3DFQqJiw8pLNfLq1t3zEHbhBKIUmzY6Dc3g== X-Received: by 2002:a17:902:9b95:b0:13a:4db7:162 with SMTP id y21-20020a1709029b9500b0013a4db70162mr4701797plp.73.1631417212414; Sat, 11 Sep 2021 20:26:52 -0700 (PDT) From: Ani Sinha To: libvir-list@redhat.com Subject: [PATCH v3 4/5] qemu: command: add support for qemu options that enables/disables acpi hotplug Date: Sun, 12 Sep 2021 08:56:30 +0530 Message-Id: <20210912032631.2853520-5-ani@anisinha.ca> In-Reply-To: <20210912032631.2853520-1-ani@anisinha.ca> References: <20210912032631.2853520-1-ani@anisinha.ca> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: ani@anisinha.ca, jusual@redhat.com, laine@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631417284960100001 Content-Type: text/plain; charset="utf-8" This change adds backend qemu commandline support for two new libvirt global conf options: Additionally it adds validations to make sure that qemu has the capabilities to support the above two options. The details of the above two options are provided in the commit log for the following commit: 69e01d2d3a50f ("conf: introduce acpi-hotplug-bridge and acpi-root-hotplug p= m options") 'acpi-hotplug-bridge' turns on the following commandline option to qemu for x86 guests: (pc machines): -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=3D (q35 machines): -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=3D 'acpi-root-hotplug' is only valid for pc machines and turns on the following commandline option to qemu for x86 guests: -global PIIX4_PM.acpi-root-pci-hotplug=3D This change also adds the required qemuxml2argv unit tests in order to test correct qemu arguments. Also unit tests have been added to test qemu capabi= lity validation checks. Signed-off-by: Ani Sinha --- src/qemu/qemu_command.c | 28 +++++++++++++++++ src/qemu/qemu_validate.c | 21 +++++++++++++ ...pc-i440fx-acpi-hotplug-bridge-disable.args | 29 +++++++++++++++++ .../pc-i440fx-acpi-hotplug-bridge-enable.err | 1 + .../pc-i440fx-acpi-root-hotplug-disable.args | 29 +++++++++++++++++ .../pc-i440fx-acpi-root-hotplug-enable.err | 1 + .../q35-acpi-hotplug-bridge-disable.args | 31 +++++++++++++++++++ .../q35-acpi-hotplug-bridge-enable.err | 1 + tests/qemuxml2argvtest.c | 18 +++++++++++ 9 files changed, 159 insertions(+) create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-di= sable.args create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-en= able.err create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disa= ble.args create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-enab= le.err create mode 100644 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.= args create mode 100644 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-enable.e= rr diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4d29313f45..f23b9a7b1d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6197,6 +6197,34 @@ qemuBuildPMCommandLine(virCommand *cmd, pm_object, def->pm.s4 =3D=3D VIR_TRISTATE_B= OOL_NO); } =20 + if (def->pm.acpi_hp_bridge) { + const char *pm_object =3D "PIIX4_PM"; + const char *switch_str =3D "on"; + + if (def->pm.acpi_hp_bridge =3D=3D VIR_TRISTATE_BOOL_NO) + switch_str =3D "off"; + + if (qemuDomainIsQ35(def) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE)) + pm_object =3D "ICH9-LPC"; + + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "%s.acpi-pci-hotplug-with-bridge-suppo= rt=3D%s", + pm_object, switch_str); + } + + if (def->pm.acpi_root_hp) { + const char *pm_object =3D "PIIX4_PM"; + const char *switch_str =3D "on"; + + if (def->pm.acpi_root_hp =3D=3D VIR_TRISTATE_BOOL_NO) + switch_str =3D "off"; + + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "%s.acpi-root-pci-hotplug=3D%s", + pm_object, switch_str); + } + return 0; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 9d93f373ab..9bde0e1f0a 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -561,6 +561,27 @@ qemuValidateDomainDefPM(const virDomainDef *def, } } =20 + if (def->pm.acpi_hp_bridge) { + bool q35ICH9_pcihpbr =3D q35Dom && + virQEMUCapsGet(qemuCaps, + QEMU_CAPS_ICH9_ACPI_HOTPLUG_= BRIDGE); + + if (!q35ICH9_pcihpbr && !virQEMUCapsGet(qemuCaps, + QEMU_CAPS_PIIX_ACPI_HOTPLU= G_BRIDGE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("setting ACPI hotplug bridge not suppor= ted")); + 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 supp= orted")); + return -1; + } + } + return 0; } =20 diff --git a/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.a= rgs b/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.args new file mode 100644 index 0000000000..1eed691975 --- /dev/null +++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.args @@ -0,0 +1,29 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-i440fx \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-i440fx/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-i440fx/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-i440fx/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Di440fx,debug-threads=3Don \ +-S \ +-machine pc-i440fx-2.5,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 56f5055c-1b8d-490c-844a-ad646a1caaaa \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-i440fx/monitor.= sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=3Doff \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-enable.er= r b/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-enable.err new file mode 100644 index 0000000000..98211b726f --- /dev/null +++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-enable.err @@ -0,0 +1 @@ +unsupported configuration: setting ACPI hotplug bridge not supported diff --git a/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disable.arg= s b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disable.args new file mode 100644 index 0000000000..6f1e2814bf --- /dev/null +++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disable.args @@ -0,0 +1,29 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-i440fx \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-i440fx/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-i440fx/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-i440fx/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Di440fx,debug-threads=3Don \ +-S \ +-machine pc-i440fx-2.5,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 56f5055c-1b8d-490c-844a-ad646a1caaaa \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-i440fx/monitor.= sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-global PIIX4_PM.acpi-root-pci-hotplug=3Doff \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-enable.err = b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-enable.err new file mode 100644 index 0000000000..c5c9de8389 --- /dev/null +++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-enable.err @@ -0,0 +1 @@ +unsupported configuration: setting ACPI root pci hotplug not supported diff --git a/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args b/= tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args new file mode 100644 index 0000000000..b88dd251b0 --- /dev/null +++ b/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args @@ -0,0 +1,31 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-q35 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-q35/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-q35/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-q35/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dq35,debug-threads=3Don \ +-S \ +-machine pc-q35-2.5,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 56f5055c-1b8d-490c-844a-ad646a1caaaa \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-q35/monitor.soc= k,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=3Doff \ +-device i82801b11-bridge,id=3Dpci.1,bus=3Dpcie.0,addr=3D0x1e \ +-device pci-bridge,chassis_nr=3D2,id=3Dpci.2,bus=3Dpci.1,addr=3D0x0 \ +-device ioh3420,port=3D0x8,chassis=3D3,id=3Dpci.3,bus=3Dpcie.0,addr=3D0x1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.2,addr=3D0x1 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-enable.err b/te= sts/qemuxml2argvdata/q35-acpi-hotplug-bridge-enable.err new file mode 100644 index 0000000000..98211b726f --- /dev/null +++ b/tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-enable.err @@ -0,0 +1 @@ +unsupported configuration: setting ACPI hotplug bridge not supported diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 74af93b08f..6e80b9cedf 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2629,6 +2629,24 @@ mymain(void) QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4); + DO_TEST("q35-acpi-hotplug-bridge-disable", + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, + QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE); + DO_TEST("pc-i440fx-acpi-hotplug-bridge-disable", + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_PIIX_ACPI_HOTPLUG_BRIDGE); + DO_TEST("pc-i440fx-acpi-root-hotplug-disable", + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_PIIX_ACPI_ROOT_PCI_HOTPLUG); + DO_TEST_PARSE_ERROR_NOCAPS("q35-acpi-hotplug-bridge-enable"); + DO_TEST_PARSE_ERROR_NOCAPS("pc-i440fx-acpi-hotplug-bridge-enable"); + DO_TEST_PARSE_ERROR_NOCAPS("pc-i440fx-acpi-root-hotplug-enable"); DO_TEST("q35-usb2", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, --=20 2.25.1