From nobody Tue Feb 10 11:23:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 163279585422147.49378775675541; Mon, 27 Sep 2021 19:24:14 -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-321-kb8oFiXOOXKgZGbzkmiKlQ-1; Mon, 27 Sep 2021 22:24:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5ADEA40C2; Tue, 28 Sep 2021 02:24:05 +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 B5E93794A2; Tue, 28 Sep 2021 02:24:05 +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 564924EA2A; Tue, 28 Sep 2021 02:24:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18S2KFXM013361 for ; Mon, 27 Sep 2021 22:20:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DD1A1134CB8; Tue, 28 Sep 2021 02:20:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39B4110009FC for ; Tue, 28 Sep 2021 02:20:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 14526800B29 for ; Tue, 28 Sep 2021 02:20:09 +0000 (UTC) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-vpqG2hywOxqQmxrTLAHwKw-1; Mon, 27 Sep 2021 22:20:07 -0400 Received: by mail-pj1-f43.google.com with SMTP id r7so13283533pjo.3 for ; Mon, 27 Sep 2021 19:20:06 -0700 (PDT) Received: from anisinha-lenovo.ba.nuagenetworks.net ([115.96.155.236]) by smtp.googlemail.com with ESMTPSA id w1sm514344pjy.49.2021.09.27.19.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:20:03 -0700 (PDT) X-MC-Unique: kb8oFiXOOXKgZGbzkmiKlQ-1 X-MC-Unique: vpqG2hywOxqQmxrTLAHwKw-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=mfB7HBG9yOOYyhEcFi7aH5S1yHGDBCNAQ8tvKHnJ3eo=; b=70e9zkPbqqUCe595PU+D3xS3z0G64smu18bdcDeFEl7zsc9/bJ3kFyigOcxQL7Dpof sBu+ObsBajxlN4bt/dV5UytJwS72SwJ3OiyoR2VDc2lJbV4FJFDwXS1sQfT1dWzcMxmv kxBu0SJrobI4m9KQFO1rItjz2T0WVS7FvSZP7E/+RZJ5hXaX2DjcKng0LsQ0dwNmwxG8 3cAUEY0Q6aKUQSXzKHI9LEOxvUARBQmiTYwggIIs51xdP+qKso5T6XxPuPNHlXWb3iPB XCapevvWrGEpVxOM435Tzi+5E/CL+Wrrk6v4si/ixFQa4B3FVixD3pnsutbYd2cOmfny wXPg== X-Gm-Message-State: AOAM532ZfyT0EefNerXksx9oXfu9N1kVCJ2ROEANGoH3fdHLLcHDysXj Q5woyIXvwPoI0pnm4meH1dcWBF5JByfEFQ== X-Google-Smtp-Source: ABdhPJys+wgpITl0/4xcM2egUAwUvNPEkGJd3TnGzIgXAK/arBz63SgCqcvag/JbsmVhlfXReYtk+A== X-Received: by 2002:a17:90a:f193:: with SMTP id bv19mr2586088pjb.18.1632795604229; Mon, 27 Sep 2021 19:20:04 -0700 (PDT) From: Ani Sinha To: libvir-list@redhat.com Subject: [PATCH v6 3/4] qemu: command: add support to enable/disable hotplug on pci-root controller Date: Tue, 28 Sep 2021 07:49:41 +0530 Message-Id: <20210928021942.450247-4-ani@anisinha.ca> In-Reply-To: <20210928021942.450247-1-ani@anisinha.ca> References: <20210928021942.450247-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.3 X-loop: libvir-list@redhat.com Cc: Ani Sinha , 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.79 on 10.5.11.16 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: 1632795854735100001 Content-Type: text/plain; charset="utf-8" This change adds qemu backend command line support for enabling or disabling hotplug on the pci-root controller using the 'target' sub-element of the pci-root controller as shown below: '' is only valid for pc (x86) machines and turn= s on the following command line option that is passed 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. Unit tests have also been added to test qemu capabi= lity validation checks. Signed-off-by: Ani Sinha --- src/qemu/qemu_command.c | 17 ++++++++++ .../pc-i440fx-acpi-root-hotplug-disable.args | 31 +++++++++++++++++++ .../pc-i440fx-acpi-root-hotplug-disable.err | 1 + tests/qemuxml2argvtest.c | 3 ++ 4 files changed, 52 insertions(+) create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disa= ble.args create mode 100644 tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disa= ble.err diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b60ee1192b..a8775bca24 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2645,6 +2645,20 @@ qemuBuildSkipController(const virDomainControllerDef= *controller, return false; } =20 +static int +qemuBuildPMPCIRootHotplugCommandLine(virCommand *cmd, + const virDomainControllerDef *controller) +{ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && + controller->idx =3D=3D 0 && + controller->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "PIIX4_PM.acpi-root-pci-hotplug=3D= %s", + virTristateSwitchTypeToString(controlle= r->opts.pciopts.hotplug)); + } + return 0; +} =20 static int qemuBuildControllersByTypeCommandLine(virCommand *cmd, @@ -2661,6 +2675,9 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd, if (cont->type !=3D type) continue; =20 + if (qemuBuildPMPCIRootHotplugCommandLine(cmd, cont)) + continue; + if (qemuBuildSkipController(cont, def)) continue; =20 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..dd8ea503fc --- /dev/null +++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disable.args @@ -0,0 +1,31 @@ +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 \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-i440= fx/master-key.aes \ +-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 \ +-boot strict=3Don \ +-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-disable.err= b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disable.err new file mode 100644 index 0000000000..b507f1f8bc --- /dev/null +++ b/tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-disable.err @@ -0,0 +1 @@ +unsupported configuration: setting the hotplug property on a 'pci-root' de= vice is not supported by this QEMU binary diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 13e387df3f..d5ddd60182 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2571,6 +2571,9 @@ 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("pc-i440fx-acpi-root-hotplug-disable", + QEMU_CAPS_PIIX_ACPI_ROOT_PCI_HOTPLUG); + DO_TEST_PARSE_ERROR_NOCAPS("pc-i440fx-acpi-root-hotplug-disable"); DO_TEST("q35-usb2", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, --=20 2.25.1