From nobody Sun Feb 8 01:34:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1576503406; cv=none; d=zohomail.com; s=zohoarc; b=ZeVJuHv9rv88W1yyLZEV8UknMNFeCFVBGY9uJE2IXkuy3latKqcWsOiuRYGK0hyewOyr4/2ChT2ytMcPw5uw1PBPG6Qq6R2SUVBOdY9JbqBBmkzWYuOK1vvy6YE8u4KKX4D1OunGGxU9+46+qFd277OaiwP+xphxfe0xWh/AF1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576503406; h=Content-Type:Content-Transfer-Encoding:Cc: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=PVQwWrnSMkC0IGoAuyJ3MNl/xca75WW/JRKHlPMBvDo=; b=h3FenyDO1ejKS6EEAfAyEclK0KQmKkPXB2x5RnZl6DwrbQaCET2b9Wnem3hNGSLIamLMX7bzQ93rjL6xSsSYXQKyh81SMev7ULYjWJUukMNDR7fMWlCZc130qal334OPz/BZ96O+AftX+k9q9/TQszQYgcbXgYOroI34ll8ZSwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576503406955712.2160377600319; Mon, 16 Dec 2019 05:36:46 -0800 (PST) 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-359-G5EOFyhYMVi0EKL8hcvDcg-1; Mon, 16 Dec 2019 08:36:43 -0500 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 3E172106BC09; Mon, 16 Dec 2019 13:36:37 +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 1367A5C28C; Mon, 16 Dec 2019 13:36:37 +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 BD2FF18089CF; Mon, 16 Dec 2019 13:36:36 +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 xBGDaPCR007549 for ; Mon, 16 Dec 2019 08:36:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27BDB1005401; Mon, 16 Dec 2019 13:36:25 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E28410BBCC4 for ; Mon, 16 Dec 2019 13:36:23 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3C3F85A333 for ; Mon, 16 Dec 2019 13:36:22 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-43Oq9yAQO0C2uRnoIz9udw-1; Mon, 16 Dec 2019 08:36:19 -0500 Received: by mail-qk1-f195.google.com with SMTP id z76so2182068qka.2; Mon, 16 Dec 2019 05:36:19 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:2f19:a73a:b6c3:c24a:90f3]) by smtp.gmail.com with ESMTPSA id r12sm2414002qkm.94.2019.12.16.05.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2019 05:36:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576503405; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=PVQwWrnSMkC0IGoAuyJ3MNl/xca75WW/JRKHlPMBvDo=; b=P6hGAxWrbDCOJgZ7FCKaLBXMm7hgMUN8DrxYfZcmoAD7PXgqadx2TB3ek2c2/OxdKKyMQR wDpCFA/0/xtUtFr1YY4MEyl+0DlFqoTX6mZPJQHpKxIxXwEmshrTw7dJOrhQLizbxPuOS1 1ilLcEAtpgTKRiSLCu4BUgG4aesCIwY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5FWpY9oh2Q5aOFqcRfaYBd4a1QsG+6tE3JLpfpXfx5I=; b=OZFNyV09G/S1GLg4t8mgmbOwAGrFbTQpWDk3x3YNx0cjbWzD0C1EDUKrHZG+dAS686 QaHSw0dWb4DRmYJkJxsUIr4XqIK5WCmYSRFF2OY6ZqFtzUsqJ1D9W1t2hub2JV0dm5Ke od3gSh7ZgSXZCHt6amLffzXbfLATMEwdYJ4mJqOBJjQulpOCoyzUUO8ducNKTF/2l3k0 cOYdasfYHRn/PN0CV0aafNmnSwYDpuijof9sS+5ck5Wym+yjTMNHXCEOcxuTH3an++uU oG3RcXYxflNtPT8osCcVswa7Pt7lcb+CM3b1JYJRA1kVXOHkk1MNwCmP6JI/CLDix3qM EodA== X-Gm-Message-State: APjAAAWy8wImHnYkeWtaqTXVc18aq0q+aqoY1X/V3Bm7mcvPhlC0hKd2 Ccq7zKD6/VJRyuUnJsuidXSdHyLM X-Google-Smtp-Source: APXvYqx248wUlLNddonvSC+SEQTNUd9oTHQC0a5bT9dbF/KPtFJ72w6xYYwAkiSJXFH/YM7WiqU7+Q== X-Received: by 2002:a37:a18b:: with SMTP id k133mr27157858qke.83.1576503378385; Mon, 16 Dec 2019 05:36:18 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 16 Dec 2019 10:36:03 -0300 Message-Id: <20191216133607.3055202-2-danielhb413@gmail.com> In-Reply-To: <20191216133607.3055202-1-danielhb413@gmail.com> References: <20191216133607.3055202-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: 43Oq9yAQO0C2uRnoIz9udw-1 X-MC-Unique: G5EOFyhYMVi0EKL8hcvDcg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xBGDaPCR007549 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , laine@laine.org, darkstego@gmail.com, crobinso@redhat.com Subject: [libvirt] [PATCH v4 1/5] Introducing new address type='unassigned' for PCI hostdevs 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 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Today, to use a PCI hostdev "A" in a domain, all PCI devices that belongs to the same IOMMU group must also be declared in the domain XML, meaning that all IOMMU devices are detached from the host and all of them are visible to the guest. The result is that the guest will have access to all devices, but this is not necessarily what the administrator wanted. If only the hostdev "A" was intended for guest usage, but hostdevs "B" and "C" happened to be in the same IOMMU group of "A", the guest will gain access to all 3 devices. This makes the administrator rely on alternative solutions, such as use all hostdevs with un-managed mode and detached all the IOMMU before the guest starts. If use un-managed mode is not an option, the only alternative left is an ACS patch to deny guest access to "B" and "C". This patch introduces a new address type called "unassigned" to handle this situation where a hostdev will be owned by a domain, but not visible to the guest OS. This allows the administrator to declare all the IOMMU while also choosing which hostdevs will be usable by the guest. This new mechanic applies to all PCI hostdevs, regardless of whether they are a PCI multifunction hostdev or not. Using
in any case other than a PCI hostdev will result in error. Next patch will use this new address type in the QEMU driver to avoid adding unassigned devices to the QEMU launch command line. Signed-off-by: Daniel Henrique Barboza --- docs/schemas/domaincommon.rng | 5 ++ src/conf/device_conf.c | 2 + src/conf/device_conf.h | 1 + src/conf/domain_conf.c | 7 ++- src/qemu/qemu_command.c | 1 + src/qemu/qemu_domain.c | 1 + src/qemu/qemu_domain_address.c | 5 ++ .../hostdev-pci-address-unassigned.xml | 42 ++++++++++++++ .../hostdev-pci-address-unassigned.xml | 58 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 10 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-unassigned.x= ml create mode 100644 tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned= .xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f5b51d20ad..372d248f25 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5470,6 +5470,11 @@ + + + unassigned + + diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 4c57f0995f..4dbd5c1ac9 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -45,6 +45,7 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, "virtio-mmio", "isa", "dimm", + "unassigned", ); =20 static int @@ -120,6 +121,7 @@ virDomainDeviceInfoAddressIsEqual(const virDomainDevice= Info *a, /* address types below don't have any specific data */ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index d98fae775c..e091d7cfe2 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -45,6 +45,7 @@ typedef enum { VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED, =20 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST } virDomainDeviceAddressType; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cfec86a24d..454eb63be6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6338,9 +6338,11 @@ virDomainHostdevDefValidate(const virDomainHostdevDe= f *hostdev) switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (hostdev->info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NO= NE && + hostdev->info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UN= ASSIGNED && hostdev->info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PC= I) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("PCI host devices must use 'pci' address = type")); + _("PCI host devices must use 'pci' or " + "'unassigned' address type")); return -1; } break; @@ -7357,6 +7359,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf, =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: break; } @@ -7557,6 +7560,7 @@ virDomainDeviceAddressParseXML(xmlNodePtr address, break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: break; } @@ -21871,6 +21875,7 @@ virDomainDeviceInfoCheckABIStability(virDomainDevic= eInfoPtr src, case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: break; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 49a0dad8d4..5d12ef3d63 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -461,6 +461,7 @@ qemuBuildVirtioDevStr(virBufferPtr buf, return -1; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: default: virReportEnumRangeError(virDomainDeviceAddressType, info->type); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index df21065e84..b3df2c4a7a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7456,6 +7456,7 @@ qemuDomainDeviceDefValidateAddress(const virDomainDev= iceDef *dev, case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: /* No validation for these address types yet */ break; =20 diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 605984f80f..b077240899 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2313,6 +2313,11 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, continue; } =20 + /* do not reserve address for info->type=3D'unassigned' */ + if (def->hostdevs[i]->info->type =3D=3D + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED) + continue; + if (qemuDomainPCIAddressReserveNextAddr(addrs, def->hostdevs[i]->info) < = 0) goto error; diff --git a/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml b/te= sts/qemuxml2argvdata/hostdev-pci-address-unassigned.xml new file mode 100644 index 0000000000..9a2685ca0e --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml @@ -0,0 +1,42 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 4 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + + +
+ +
+ + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.xml b/= tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.xml new file mode 100644 index 0000000000..2341e8432b --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.xml @@ -0,0 +1,58 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 262144 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 50b43e01d4..c02791c660 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -431,6 +431,7 @@ mymain(void) =20 DO_TEST("hostdev-usb-address", NONE); DO_TEST("hostdev-pci-address", NONE); + DO_TEST("hostdev-pci-address-unassigned", NONE); DO_TEST("hostdev-pci-multifunction", NONE); DO_TEST("hostdev-vfio", NONE); DO_TEST("hostdev-vfio-zpci", --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list