From nobody Tue Feb 10 01:19:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1586181117; cv=none; d=zohomail.com; s=zohoarc; b=KM7fsVPWL+tBUgQ0RB1bjJN/1xsdzE2wUfI4tewQxQY5EBANy8kJ9G2ObU/jAT19l/0GE6cT1A+pALAtdzM2kQtkkx1iuRew15hxXk4iq/BNj/Vs3P41IwQkZ270OZmeFfnxy6WI2u7Ktwh8MbgmeIv9bgOzTwYIJn1t9FUhDx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586181117; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6rFhLfrgq8Kmp37ifeNO10YmpWELXdWwlXpKSO+7+vo=; b=LTAHXGI/Q3OQwkeCQhVVb7albWb4IkzkWOyCetsE4JN4ciqpzbTihjEI4xW8qH8epU8a0asHLTq9muZOYgGox3yiOqpVGaep9eBv5wGgyOP1XinuIfpK0UgAWcWiZUiY076FbkCzXjfWrVzebnoSpMjhRcRqZfw4x9f7jt93UTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1586181117179297.38601828300875; Mon, 6 Apr 2020 06:51:57 -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-96-wtKFt3JKNCusrawImj09Yg-1; Mon, 06 Apr 2020 09:51:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F072E107ACC7; Mon, 6 Apr 2020 13:51:46 +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 7559092FA6; Mon, 6 Apr 2020 13:51:45 +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 B4DD993A63; Mon, 6 Apr 2020 13:51:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 036Dpf5l018344 for ; Mon, 6 Apr 2020 09:51:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 53C815C28F; Mon, 6 Apr 2020 13:51:41 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-243.phx2.redhat.com [10.3.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 054A15C1B0 for ; Mon, 6 Apr 2020 13:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586181115; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6rFhLfrgq8Kmp37ifeNO10YmpWELXdWwlXpKSO+7+vo=; b=ZPsdfGoNqyzp6//WEw0uIyI88R53T3rh9Zfis6NpReyc6tK5MALlFhvXhmnshp5AMkdA9W v4yeJKKVk9MCyEKTtKGGKEczJ5OnV6vBkzgSFqWIv1M5JPK2wefeSbHEc5ez7u/JFgwT/k k4Yb49p+M4UST+FnW2WuwR5RSEsOazM= X-MC-Unique: wtKFt3JKNCusrawImj09Yg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 03/10] qemu: hook up pcie-root-port hotplug='off' option Date: Mon, 6 Apr 2020 09:51:23 -0400 Message-Id: <20200406135130.3080946-4-laine@redhat.com> In-Reply-To: <20200406135130.3080946-1-laine@redhat.com> References: <20200406135130.3080946-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If a pcie-root-port or pcie-downstream-port has hotplug=3D'off' in its subelement, and if the qemu binary supports the hotplug=3Dfalse option, then it will be added to the commandline for the pcie controller. This controller will then not allow any hotplug/unplug of devices while the guest is running (and the hotplug capability won't be advertised to the guest OS, so the guest OS also won't present unplugging of PCI devices as an option). For any PCI controllers other than pcie-downstream-port and pcie-root-port, of for qemu binaries that don't support the hotplug commandline option, an error will be logged during validation. Signed-off-by: Laine Stump --- src/qemu/qemu_command.c | 4 ++ src/qemu/qemu_validate.c | 31 +++++++++++++++ .../pcie-root-port-nohotplug.args | 39 +++++++++++++++++++ tests/qemuxml2argvtest.c | 7 ++++ 4 files changed, 81 insertions(+) create mode 100644 tests/qemuxml2argvdata/pcie-root-port-nohotplug.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index df90f5edf5..f619ef32be 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3016,6 +3016,10 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, virBufferAsprintf(&buf, "%s,port=3D0x%x,chassis=3D%d,id=3D%s", modelName, pciopts->port, pciopts->chassis, def->info.alias); + if (pciopts->hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&buf, ",hotplug=3D%s", + virTristateSwitchTypeToString(pciopts->h= otplug)); + } break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: virBufferAsprintf(&buf, "%s,index=3D%d,id=3D%s", diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6f94361b52..49f9af69db 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2637,6 +2637,37 @@ qemuValidateDomainDeviceDefControllerPCI(const virDo= mainControllerDef *cont, virReportEnumRangeError(virDomainControllerModelPCI, cont->model); } =20 + /* hotplug */ + if (pciopts->hotplug !=3D VIR_TRISTATE_SWITCH_ABSENT) { + switch ((virDomainControllerModelPCI) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIE_ROOT_PORT_HOTPLUG= )) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("setting the hotplug property on a '%s' d= evice is not supported by this QEMU binary"), + modelName); + return -1; + } + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE: + virReportControllerInvalidOption(cont, model, modelName, "hotp= lug"); + return -1; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + default: + virReportEnumRangeError(virDomainControllerModelPCI, cont->mod= el); + } + } + /* QEMU device availability */ if (cap < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/tests/qemuxml2argvdata/pcie-root-port-nohotplug.args b/tests/q= emuxml2argvdata/pcie-root-port-nohotplug.args new file mode 100644 index 0000000000..3a4904c24f --- /dev/null +++ b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.args @@ -0,0 +1,39 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-guest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-guest/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-guest/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-guest/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest \ +-S \ +-machine q35,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 2048 \ +-realtime mlock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-guest/monitor.s= ock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-device pcie-root-port,port=3D0x10,chassis=3D1,id=3Dpci.1,bus=3Dpcie.0,\ +multifunction=3Don,addr=3D0x2 \ +-device pcie-root-port,port=3D0x11,chassis=3D2,id=3Dpci.2,hotplug=3Doff,bu= s=3Dpcie.0,\ +addr=3D0x2.0x1 \ +-device ioh3420,port=3D0x12,chassis=3D3,id=3Dpci.3,hotplug=3Doff,bus=3Dpci= e.0,\ +addr=3D0x2.0x2 \ +-device x3130-upstream,id=3Dpci.4,bus=3Dpci.1,addr=3D0x0 \ +-device xio3130-downstream,port=3D0x0,chassis=3D5,id=3Dpci.5,hotplug=3Doff= ,bus=3Dpci.4,\ +addr=3D0x0 \ +-device xio3130-downstream,port=3D0x1,chassis=3D6,id=3Dpci.6,hotplug=3Don,= bus=3Dpci.4,\ +addr=3D0x1 \ +-device xio3130-downstream,port=3D0x2,chassis=3D7,id=3Dpci.7,bus=3Dpci.4,a= ddr=3D0x2 \ +-device xio3130-downstream,port=3D0x27,chassis=3D30,id=3Dpci.8,bus=3Dpci.4= ,addr=3D0x3 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fdeb3c2e65..9a10528251 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2436,6 +2436,13 @@ mymain(void) DO_TEST("pcie-root-port-model-ioh3420", QEMU_CAPS_DEVICE_IOH3420); =20 + DO_TEST("pcie-root-port-nohotplug", + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_DEVICE_X3130_UPSTREAM, + QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM, + QEMU_CAPS_PCIE_ROOT_PORT_HOTPLUG); + DO_TEST("autoindex", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, --=20 2.25.2