From nobody Mon Feb 9 05:41:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1500132706573772.0990333393243; Sat, 15 Jul 2017 08:31:46 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 535F9C049DFD; Sat, 15 Jul 2017 15:31:45 +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 B8C6E6A455; Sat, 15 Jul 2017 15:31:44 +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 54AF84A492; Sat, 15 Jul 2017 15:31:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6FFVEtq006839 for ; Sat, 15 Jul 2017 11:31:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id A6C3278C14; Sat, 15 Jul 2017 15:31:14 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-62.brq.redhat.com [10.40.204.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 870C7784D9; Sat, 15 Jul 2017 15:31:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 535F9C049DFD Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 535F9C049DFD From: Andrea Bolognani To: libvir-list@redhat.com Date: Sat, 15 Jul 2017 17:30:56 +0200 Message-Id: <1500132659-3658-2-git-send-email-abologna@redhat.com> In-Reply-To: <1500132659-3658-1-git-send-email-abologna@redhat.com> References: <1500132659-3658-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v4 1/4] conf: Introduce isolation groups 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 15 Jul 2017 15:31:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Isolation groups will eventually allow us to make sure certain devices, eg. PCI hostdevs, are assigned to guest PCI buses in a way that guarantees improved isolation, error detection and recovery for machine types and hypervisors that support it, eg. pSeries guest on QEMU. This patch merely defines storage for the new information we're going to need later on and makes sure it is passed from the hypervisor driver (QEMU / bhyve) down to the generic PCI address allocation code. Signed-off-by: Andrea Bolognani Reviewed-by: Laine Stump --- src/bhyve/bhyve_device.c | 4 ++-- src/conf/device_conf.h | 10 ++++++++++ src/conf/domain_addr.c | 17 ++++++++++++----- src/conf/domain_addr.h | 9 ++++++++- src/conf/domain_conf.c | 2 ++ src/qemu/qemu_domain_address.c | 35 ++++++++++++++++++----------------- 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index fdfd512..03aa6c9 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -57,7 +57,7 @@ bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUS= ED, } =20 if (virDomainPCIAddressReserveAddr(addrs, addr, - VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < = 0) { + VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0)= < 0) { goto cleanup; } =20 @@ -100,7 +100,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def, lpc_addr.slot =3D 0x1; =20 if (virDomainPCIAddressReserveAddr(addrs, &lpc_addr, - VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < = 0) { + VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0)= < 0) { goto error; } =20 diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 14be2e3..68615f6 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -164,6 +164,16 @@ struct _virDomainDeviceInfo { */ int pciConnectFlags; /* enum virDomainPCIConnectFlags */ char *loadparm; + + /* PCI devices will only be automatically placed on a PCI bus + * that shares the same isolation group */ + unsigned int isolationGroup; + + /* Usually, PCI buses will take on the same isolation group + * as the first device that is plugged into them, but in some + * cases we might want to prevent that from happening by + * locking the isolation group */ + bool isolationGroupLocked; }; =20 =20 diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 362e996..bb095a3 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -548,6 +548,7 @@ static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) virDomainPCIAddressReserveAddrInternal(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags, + unsigned int isolationGroup ATTRIBU= TE_UNUSED, bool fromConfig) { int ret =3D -1; @@ -600,9 +601,11 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAdd= ressSetPtr addrs, int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr, - virDomainPCIConnectFlags flags) + virDomainPCIConnectFlags flags, + unsigned int isolationGroup) { - return virDomainPCIAddressReserveAddrInternal(addrs, addr, flags, true= ); + return virDomainPCIAddressReserveAddrInternal(addrs, addr, flags, + isolationGroup, true); } =20 int @@ -638,7 +641,8 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr= addrs, goto cleanup; =20 ret =3D virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.p= ci, - flags, true); + flags, dev->isolation= Group, + true); } else { ret =3D virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1); } @@ -759,6 +763,7 @@ static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr next_addr, virDomainPCIConnectFlags flags, + unsigned int isolationGroup ATTRIBUTE_UNUSE= D, int function) { virPCIDeviceAddress a =3D { 0 }; @@ -839,10 +844,12 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddres= sSetPtr addrs, { virPCIDeviceAddress addr; =20 - if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags, function) < 0) + if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags, + dev->isolationGroup, function) < 0) return -1; =20 - if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags, false)= < 0) + if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags, + dev->isolationGroup, false)= < 0) return -1; =20 if (!addrs->dryRun) { diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index c53dceb..ac6d64f 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -100,6 +100,12 @@ typedef struct { * bit is set, that function is in use by a device. */ virDomainPCIAddressSlot slot[VIR_PCI_ADDRESS_SLOT_LAST + 1]; + + /* See virDomainDeviceInfo::isolationGroup */ + unsigned int isolationGroup; + + /* See virDomainDeviceInfo::isolationGroupLocked */ + bool isolationGroupLocked; } virDomainPCIAddressBus; typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr; =20 @@ -142,7 +148,8 @@ bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSe= tPtr addrs, =20 int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr, - virDomainPCIConnectFlags flags) + virDomainPCIConnectFlags flags, + unsigned int isolationGroup) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3feeccb..9320794 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3670,6 +3670,8 @@ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr = info) info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; VIR_FREE(info->romfile); VIR_FREE(info->loadparm); + info->isolationGroup =3D 0; + info->isolationGroupLocked =3D false; } =20 =20 diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 44d0a5b..b247c85 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1037,7 +1037,8 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRI= BUTE_UNUSED, } =20 if (virDomainPCIAddressReserveAddr(addrs, addr, - info->pciConnectFlags) < 0) { + info->pciConnectFlags, + info->isolationGroup) < 0) { goto cleanup; } =20 @@ -1082,6 +1083,10 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def, if (virDomainPCIAddressBusSetModel(&addrs->buses[idx], cont->model= ) < 0) goto error; =20 + /* Forward the information about isolation groups */ + addrs->buses[idx].isolationGroup =3D cont->info.isolationGroup; + addrs->buses[idx].isolationGroupLocked =3D cont->info.isolationGro= upLocked; + if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) hasPCIeRoot =3D true; } @@ -1198,7 +1203,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, if (addrs->nbuses) { memset(&tmp_addr, 0, sizeof(tmp_addr)); tmp_addr.slot =3D 1; - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) goto cleanup; } =20 @@ -1233,7 +1238,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, goto cleanup; } } else { - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= ) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0) < 0) goto cleanup; primaryVideo->info.addr.pci =3D tmp_addr; primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; @@ -1258,7 +1263,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, VIR_DEBUG("PCI address 0:0:2.0 in use, future addition of a vi= deo" " device will not be possible without manual" " intervention"); - } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags)= < 0) { + } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0) < 0) { goto cleanup; } } @@ -1334,10 +1339,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr = def, assign =3D true; } if (assign) { - if (virDomainPCIAddressReserveAddr(addrs, - &tmp_addr, flags) <= 0) { + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0) < 0) goto cleanup; - } =20 cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; cont->info.addr.pci.domain =3D 0; @@ -1359,10 +1362,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr = def, memset(&tmp_addr, 0, sizeof(tmp_addr)); tmp_addr.slot =3D 0x1E; if (!virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { - if (virDomainPCIAddressReserveAddr(addrs, - &tmp_addr, flags) <= 0) { + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0) < 0) goto cleanup; - } =20 cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; cont->info.addr.pci.domain =3D 0; @@ -1385,12 +1386,12 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr= def, tmp_addr.slot =3D 0x1F; tmp_addr.function =3D 0; tmp_addr.multi =3D VIR_TRISTATE_SWITCH_ON; - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) goto cleanup; =20 tmp_addr.function =3D 3; tmp_addr.multi =3D VIR_TRISTATE_SWITCH_ABSENT; - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) goto cleanup; } =20 @@ -1424,7 +1425,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, goto cleanup; } } else { - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= ) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0) < 0) goto cleanup; primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; primaryVideo->info.addr.pci =3D tmp_addr; @@ -1450,8 +1451,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, " device will not be possible without manual" " intervention"); virResetLastError(); - } else if (virDomainPCIAddressReserveAddr(addrs, - &tmp_addr, flags) < 0) { + } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0) < 0) { goto cleanup; } } @@ -1472,7 +1472,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, !virDeviceInfoPCIAddressWanted(&sound->info)) { continue; } - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags) < = 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0)= < 0) goto cleanup; =20 sound->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1676,7 +1676,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, if (foundAddr) { /* Reserve this function on the slot we found */ if (virDomainPCIAddressReserveAddr(addrs, &addr, - cont->info.pciConnectFl= ags) < 0) { + cont->info.pciConnectFl= ags, + cont->info.isolationGro= up) < 0) { goto error; } =20 --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list