From nobody Mon Feb 9 12:43:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1586181153; cv=none; d=zohomail.com; s=zohoarc; b=CK9A2Q1S09jOy0pbGrTG7terezlT28X/xZZtVs6yE+Dc/gTQRmTk28qnIc7M0evX+56WOXw2eJcD9T0xUof8we1VIbUR7v1t8jQPsHocFMDlQzseiCKXcoCGC/wQgQOwOYCPTpVcoSlmb6A+I7tsZqbr3hiHsZbm7YXR9pKpYXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586181153; 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=j1sooogH6Col6kfbFsZoE+r0QI1LmqvQ6aYJ1XpcpE4=; b=kN/jHGNP0MzmnD3Wq6yf/+wAhD+kzPcmq6UrvLVgCQqllCrViWRcVj/ZXKJx+gm+eWfb1OloAnjvbZZvhDCWjRzgtKD0Iev2CymwCAb91sBnMjx/m7PgrIrCKlzD6tynOVgz3cdwpYSVKt++1zZfzg/1PI2mXkjRA6kfL6DAfls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1586181153884725.5718586780481; Mon, 6 Apr 2020 06:52:33 -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-430-LaisnrMYMiejVlQL-PcVTQ-1; Mon, 06 Apr 2020 09:52:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4DE618B9FD9; Mon, 6 Apr 2020 13:52:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A331560C84; Mon, 6 Apr 2020 13:52: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 5C65118089D0; Mon, 6 Apr 2020 13:52:22 +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 036Dphp6018379 for ; Mon, 6 Apr 2020 09:51:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4ADC5C1BB; Mon, 6 Apr 2020 13:51:43 +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 8A9975C1B0 for ; Mon, 6 Apr 2020 13:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586181152; 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=j1sooogH6Col6kfbFsZoE+r0QI1LmqvQ6aYJ1XpcpE4=; b=cwrNFJ9fc/71pd85LG1YbTe/bUHqEJJXFf0oay3JlhHtaaNhUYc/H9b7uqDKEQHPa7llcn 7nO4cf7kxFaWkMRPkDstm6zFEP4UUfc0qP4f/144SyCC3T2l0Y17jhkjy6lqxaHcLaHA67 /WYBBpCt2K9FJkCpEft3dbcsvBpJWiM= X-MC-Unique: LaisnrMYMiejVlQL-PcVTQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 08/10] qemu/conf: set HOTPLUGGABLE connect flag during PCI address set init Date: Mon, 6 Apr 2020 09:51:28 -0400 Message-Id: <20200406135130.3080946-9-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.12 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" virDomainPCIAddressBusSetModel() is called for each PCI controller when building an address set prior to assiging PCI addresses to devices. This patch adds a new argument, allowHotplug, to that function that can be set to false if we know for certain that a particular controller won't support hotplug The most interesting case is in qemuDomainPCIAddressSetCreate(), where the config of each existing controller is available while building the address set, so we can appropriately set allowHotplug =3D false when the user has "hotplug=3D'off'" in the config of a controller that normally would support hotplug. In all other cases, it is set to true or false in accordance with the capability of the controller model. So far we aren't doing anything with this bus flag in the address set. Signed-off-by: Laine Stump --- src/conf/domain_addr.c | 31 +++++++++++++++++++++---------- src/conf/domain_addr.h | 3 ++- src/qemu/qemu_domain_address.c | 10 +++++++--- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 429550e970..b58989ac8b 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -495,31 +495,40 @@ virDomainPCIAddressValidate(virDomainPCIAddressSetPtr= addrs, =20 int virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - virDomainControllerModelPCI model) + virDomainControllerModelPCI model, + bool allowHotplug) { /* set flags for what can be connected *downstream* from each * bus. */ + virDomainPCIConnectFlags hotplugFlag =3D 0; + + if (allowHotplug) + hotplugFlag =3D VIR_PCI_CONNECT_HOTPLUGGABLE; + switch (model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: bus->flags =3D (VIR_PCI_CONNECT_AUTOASSIGN | VIR_PCI_CONNECT_TYPE_PCI_DEVICE | VIR_PCI_CONNECT_TYPE_PCI_BRIDGE | - VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS); + VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS | + hotplugFlag); bus->minSlot =3D 1; bus->maxSlot =3D VIR_PCI_ADDRESS_SLOT_LAST; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: bus->flags =3D (VIR_PCI_CONNECT_AUTOASSIGN | VIR_PCI_CONNECT_TYPE_PCI_DEVICE | - VIR_PCI_CONNECT_TYPE_PCI_BRIDGE); + VIR_PCI_CONNECT_TYPE_PCI_BRIDGE | + hotplugFlag); bus->minSlot =3D 1; bus->maxSlot =3D VIR_PCI_ADDRESS_SLOT_LAST; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: bus->flags =3D (VIR_PCI_CONNECT_AUTOASSIGN | VIR_PCI_CONNECT_TYPE_PCI_DEVICE | - VIR_PCI_CONNECT_TYPE_PCI_BRIDGE); + VIR_PCI_CONNECT_TYPE_PCI_BRIDGE | + hotplugFlag); bus->minSlot =3D 0; bus->maxSlot =3D VIR_PCI_ADDRESS_SLOT_LAST; break; @@ -550,7 +559,8 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPt= r bus, * the first of which is not usable because of the SHPC */ bus->flags =3D (VIR_PCI_CONNECT_AUTOASSIGN | VIR_PCI_CONNECT_TYPE_PCI_DEVICE | - VIR_PCI_CONNECT_TYPE_PCI_BRIDGE); + VIR_PCI_CONNECT_TYPE_PCI_BRIDGE | + hotplugFlag); bus->minSlot =3D 1; bus->maxSlot =3D VIR_PCI_ADDRESS_SLOT_LAST; break; @@ -562,7 +572,8 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPt= r bus, bus->flags =3D (VIR_PCI_CONNECT_AUTOASSIGN | VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | - VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE); + VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE | + hotplugFlag); bus->minSlot =3D 0; bus->maxSlot =3D 0; break; @@ -759,7 +770,7 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr ad= drs, * rest are of the requested type */ if (virDomainPCIAddressBusSetModel(&addrs->buses[i++], - VIR_DOMAIN_CONTROLLER_MODEL_DMI= _TO_PCI_BRIDGE) < 0) { + VIR_DOMAIN_CONTROLLER_MODEL_DMI= _TO_PCI_BRIDGE, false) < 0) { return -1; } } @@ -776,20 +787,20 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr = addrs, * will be allocated for the dummy PCIe device later on. */ if (virDomainPCIAddressBusSetModel(&addrs->buses[i], - VIR_DOMAIN_CONTROLLER_MODEL_PCI= E_ROOT_PORT) < 0) { + VIR_DOMAIN_CONTROLLER_MODEL_PCI= E_ROOT_PORT, true) < 0) { return -1; } addrs->buses[i].flags =3D VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE; i++; =20 if (virDomainPCIAddressBusSetModel(&addrs->buses[i++], - VIR_DOMAIN_CONTROLLER_MODEL_PCI= E_TO_PCI_BRIDGE) < 0) { + VIR_DOMAIN_CONTROLLER_MODEL_PCI= E_TO_PCI_BRIDGE, true) < 0) { return -1; } } =20 for (; i < addrs->nbuses; i++) { - if (virDomainPCIAddressBusSetModel(&addrs->buses[i], model) < 0) + if (virDomainPCIAddressBusSetModel(&addrs->buses[i], model, true) = < 0) return -1; } =20 diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 40738ddb72..c1363c1490 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -148,7 +148,8 @@ bool virDomainPCIAddressValidate(virDomainPCIAddressSet= Ptr addrs, =20 =20 int virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - virDomainControllerModelPCI model) + virDomainControllerModelPCI model, + bool allowHotplug) ATTRIBUTE_NONNULL(1); =20 bool virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index f853d2003d..07431343ed 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1652,6 +1652,7 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def, for (i =3D 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont =3D def->controllers[i]; size_t idx =3D cont->idx; + bool allowHotplug =3D false; =20 if (cont->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) continue; @@ -1663,7 +1664,10 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def, goto error; } =20 - if (virDomainPCIAddressBusSetModel(&addrs->buses[idx], cont->model= ) < 0) + if (cont->opts.pciopts.hotplug !=3D VIR_TRISTATE_SWITCH_OFF) + allowHotplug =3D true; + + if (virDomainPCIAddressBusSetModel(&addrs->buses[idx], cont->model= , allowHotplug) < 0) goto error; =20 /* Forward the information about isolation groups */ @@ -1681,7 +1685,7 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def, * assigning addresses to devices. */ if (virDomainPCIAddressBusSetModel(&addrs->buses[0], - VIR_DOMAIN_CONTROLLER_MODEL_PCI= _ROOT) < 0) + VIR_DOMAIN_CONTROLLER_MODEL_PCI= _ROOT, true) < 0) goto error; } =20 @@ -1703,7 +1707,7 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def, if (addrs->buses[i].model) continue; =20 - if (virDomainPCIAddressBusSetModel(&addrs->buses[i], defaultModel)= < 0) + if (virDomainPCIAddressBusSetModel(&addrs->buses[i], defaultModel,= true) < 0) goto error; =20 VIR_DEBUG("Auto-adding ", --=20 2.25.2