From nobody Thu Apr 18 06:10:22 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1570482847; cv=none; d=zoho.com; s=zohoarc; b=UpSaxGWz91fOm+COZMwFju0RKkocWPIabDqS1lefd3ufb9yCne8diEcCay3cH1g9JBnun79nrzLzdFIGIr3A3pJt4ADV6yCUNHWCPFnh4zO7oFquZJKOpMWsJPFiSJnMRU2YGeF9JRyURSMza8r1KhOUTfuPTFslGyaFhEnjxxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570482847; 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:ARC-Authentication-Results; bh=BjXXcIwYObE/W6dbiZg6hAPLpuwITs/I8he9uzyoBoM=; b=mNbCnwny0A7lrjiJ0P+gJZfjp/8rWK4KUABpXjZnIdACJrHKvexyRxe6S0o5sJswqY5k9UNkOU8QJRbSt7sx6os63TEuB3lB9PA8xqBL1Mzkq6wWX9Bs1bFJeHpKJazk1yyC2dmk/aTCrim9StN/j9PGSM1iU7eTJkG6jfJrowc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570482847513661.5399534498669; Mon, 7 Oct 2019 14:14:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3563691761; Mon, 7 Oct 2019 21:14:05 +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 06DF2600CE; Mon, 7 Oct 2019 21:14: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 A1358180B536; Mon, 7 Oct 2019 21:14:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LBqrt012204 for ; Mon, 7 Oct 2019 17:11:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9291A6012A; Mon, 7 Oct 2019 21:11:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AA5D600C1 for ; Mon, 7 Oct 2019 21:11:50 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CED081F2F for ; Mon, 7 Oct 2019 21:11:49 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id c21so21335378qtj.12 for ; Mon, 07 Oct 2019 14:11:49 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:e8e7:3739:3e28:be31:8030]) by smtp.gmail.com with ESMTPSA id i30sm11333409qte.27.2019.10.07.14.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 14:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gP8/NjWHKJYaDf7hqgEQJmjuLY6XtonMxiZqz7u+7rE=; b=AQAVPvYMXqjFX+4yyxIseZdn3PaLdn/e9SDy8+LgiovNYMCB+zlXB6bfjVso/8accW 8Qek7ooH8vxhgw2WhqMQd4Jpxm9s6qgRnsu/yB+1oTCcRXV/Ey70salqdjOmmXXjuf+t zaWNkBPZjS0w6+pQEj4/vps85JamUC7OHbSFg2jYsuFcOkciYZv9hvIQPr6MB8v/5BO0 WONVtyTl3sdYoP/1w9JYLqJIr6jtZ/RDNII8D8E5TXP6PX4JX4eFY4itKt3+1xaQ2DnF Dr95nBU395fs+8cY1BwsMlTIZCdnbC5sXpRj8Dl8vrT5xrQnIKMT7zTRCT/PsprXcq8o lflg== 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=gP8/NjWHKJYaDf7hqgEQJmjuLY6XtonMxiZqz7u+7rE=; b=UuFz0bdAik2sD4A/n6X6SRseWtFEdYp/LxPGB5ukc+Kq3jNo7aas30Do9GociHTNQ8 6HNUYWsk/XDDnvySZ28WaUuu8zwYCjcrCXZd8oOa22qvLBP4OOp4Y6q5UDGiuW/rJZaQ M5YIpbab1C4cQwzs+wS509ALxlqpQHz3kmkJ7HlQuEzNY1bzBw6H559ZREIhlTRw8/ho UHMOULUS0UPwN9/aTjgOLdIMSGA/Ze9GmqpvWf6F1U//MwKq4sbv+GfDvM5ZhHlS6TL/ vlZ139/E3oJVOfMp1ZzGrIMIP1nmHq0PYI0ZabL0qqFVpUjqSzkQxlylZ829Ye3XfMCV xktw== X-Gm-Message-State: APjAAAXeDEfuOuqIMNddVZqBQpWentoN51vbnWZuajciV5fn58knkovq OajBuBV8LXvxTpWGq16+XF4e+9N2 X-Google-Smtp-Source: APXvYqyVi9suib8R7+ABPfTKJX56IcsxajhqkPLSyVeg3CU/kQuEPxAu1Es7oomnNrWCFp2qSaPg/w== X-Received: by 2002:ac8:2738:: with SMTP id g53mr31914958qtg.296.1570482708714; Mon, 07 Oct 2019 14:11:48 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 18:11:33 -0300 Message-Id: <20191007211136.16730-2-danielhb413@gmail.com> In-Reply-To: <20191007211136.16730-1-danielhb413@gmail.com> References: <20191007211136.16730-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Oct 2019 21:11:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Oct 2019 21:11:49 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.153 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH 1/4] utils: introducing PCI multifunction detection helpers 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Oct 2019 21:14:06 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch introduces two helpers that will be used in the next patches. One is virpci.c:virPCIDeviceIsMultifunction(), and the other is virhostdev.c:virHostdevIsPCIMultifunctionDevice(). As the name suggests, the idea is to detect if a given dev/hostdev is a PCI multifunction device. Signed-off-by: Daniel Henrique Barboza --- src/libvirt_private.syms | 2 ++ src/util/virhostdev.c | 24 ++++++++++++++++++++++++ src/util/virhostdev.h | 3 +++ src/util/virpci.c | 15 +++++++++++++++ src/util/virpci.h | 2 ++ 5 files changed, 46 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index eeab820eca..1c611ea8f4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2106,6 +2106,7 @@ virHostCPUStatsAssign; # util/virhostdev.h virHostdevFindUSBDevice; virHostdevIsMdevDevice; +virHostdevIsPCIMultifunctionDevice; virHostdevIsSCSIDevice; virHostdevManagerGetDefault; virHostdevPCINodeDeviceDetach; @@ -2684,6 +2685,7 @@ virPCIDeviceGetUnbindFromStub; virPCIDeviceGetUsedBy; virPCIDeviceHasPCIExpressLink; virPCIDeviceIsAssignable; +virPCIDeviceIsMultifunction; virPCIDeviceIsPCIExpress; virPCIDeviceListAdd; virPCIDeviceListAddCopy; diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 41fcab7222..1aa8e9729d 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -2191,3 +2191,27 @@ virHostdevUpdateActiveDomainDevices(virHostdevManage= rPtr mgr, =20 return 0; } + +bool +virHostdevIsPCIMultifunctionDevice(virDomainHostdevDefPtr hostdev) +{ + VIR_AUTOPTR(virPCIDevice) pciDev =3D NULL; + virDomainHostdevSubsysPCIPtr pcisrc =3D &hostdev->source.subsys.u.pci; + + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PC= I) + return false; + + /* Libvirt should be able to perform all the operations in + * virPCIDeviceNew() even if it's running unprivileged, so if this + * fails, the device apparently doesn't currently exist on the host. + * Since we can't speculate, assume this device is not multifunction. + */ + pciDev =3D virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus, + pcisrc->addr.slot, pcisrc->addr.function); + + if (!pciDev) + return false; + + return virPCIDeviceIsMultifunction(pciDev); +} diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index 88501e2743..63a1d7367b 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -190,6 +190,9 @@ virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev) bool virHostdevIsMdevDevice(virDomainHostdevDefPtr hostdev) ATTRIBUTE_NONNULL(1); +bool +virHostdevIsPCIMultifunctionDevice(virDomainHostdevDefPtr hostdev) + ATTRIBUTE_NONNULL(1); =20 /* functions used by NodeDevDetach/Reattach/Reset */ int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr, diff --git a/src/util/virpci.c b/src/util/virpci.c index ee78151e74..778e47ea08 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2863,6 +2863,21 @@ int virPCIGetHeaderType(virPCIDevicePtr dev, int *hd= rType) return 0; } =20 +bool +virPCIDeviceIsMultifunction(virPCIDevicePtr dev) +{ + int fd; + uint8_t type; + + if ((fd =3D virPCIDeviceConfigOpen(dev)) < 0) + return -1; + + type =3D virPCIDeviceRead8(dev, fd, PCI_HEADER_TYPE); + + virPCIDeviceConfigClose(dev, fd); + + return type & PCI_HEADER_TYPE_MULTI; +} =20 void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev) diff --git a/src/util/virpci.h b/src/util/virpci.h index dc20f91710..7199882d6b 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -264,6 +264,8 @@ int virPCIDeviceGetLinkCapSta(virPCIDevicePtr dev, =20 int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdrType); =20 +bool virPCIDeviceIsMultifunction(virPCIDevicePtr dev); + void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev); =20 ssize_t virPCIGetMdevTypes(const char *sysfspath, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 06:10:22 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1570482724; cv=none; d=zoho.com; s=zohoarc; b=PfKm+kKKxcVQ5+mW9BhdXdoJsATZBrwdLv/yt04Y/R2E+9OFxtbU6qrCGFPWu2pJ7TgZBj7V5MdtABhGDCpTAgyUjwwvmaa3k9TwmRt0taCXaubueSpatqMe+58eRqL37guCSht7fRpWLKv15673smqZQykXrYxzMu/z4t70zPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570482724; 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:ARC-Authentication-Results; bh=3Fm75UVUDKJbwGiwlsRCbNFOlnWt7TsfMChYATPtajU=; b=aDaAKlQ/18wfhgXx06Yd7oCpd19citYjDezeyu/Yvf+IFxU8tGYazFzs8Cu44/MkZ6lsVeMUDBV4VXh1g9BTpA+WHw9W6U695gysKD3t8McDVsnCnaSfUyRCZc9lUUY44+w6oEPfepkrZcIlQm8DZbkp+oPAQpUb+npcsrcVbAI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570482724660977.4013699676547; Mon, 7 Oct 2019 14:12:04 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 71EF6308624A; Mon, 7 Oct 2019 21:12:01 +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 4A95360A9F; Mon, 7 Oct 2019 21:12:01 +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 9680A4EE6A; Mon, 7 Oct 2019 21:11:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LBt78012219 for ; Mon, 7 Oct 2019 17:11:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82E005DA8C; Mon, 7 Oct 2019 21:11:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D3975D9CD for ; Mon, 7 Oct 2019 21:11:53 +0000 (UTC) Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0F613086258 for ; Mon, 7 Oct 2019 21:11:51 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id i26so4382856qtm.8 for ; Mon, 07 Oct 2019 14:11:51 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:e8e7:3739:3e28:be31:8030]) by smtp.gmail.com with ESMTPSA id i30sm11333409qte.27.2019.10.07.14.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 14:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nexZithRkBdruu7W25yRYIGliv6sRCVvCMSEyNiFteE=; b=GL8VQX3FB9ig6IcBz19TmNbBebHUrSnt798XaiSQoxNMKpjlO2qdTQojqS65xMT5Ne HiGwdLxxR/W5s83J893OmqfLxsyf/oyi3sI4bU5AdEcDKLhSnI8d8h1WfRQ+TDo3tN9F ba2jInqsRZHTctCuBF5U9DR7qNv67Ji+Njd19nD9VBHHJqDf69DbzLlvWftrNJAyFmph kCT3hJmtu+aZ4wE8bJ0ZbiV1gLazOEuRYr3q7IajWODYfsr5Qmjk4Trad71CcdnsmQPA 3p94AHli4MNIiyOjcfeqxFtKAPvoA4irhQgN93By0OuAM1QLbNL4NJJN4h0goelFozha HH6g== 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=nexZithRkBdruu7W25yRYIGliv6sRCVvCMSEyNiFteE=; b=KP7Mb4oGYSGcKwjtO7lAQ+WkRz0IJNms5yNdMHFCmYLGPFfwVPUHzFVIetYAM+n27D 3dLiXerWz5QAFrhYuWSBFlXdS6FRZbMjcGRMRaEDAjRH9NxJg81dzzUhKv8KMb4/5JE4 CDqScA+kbIicePaWj7+hM586UtLdVj80ttRwkHGYsyIhhAH0BqbayYZd7l2/HmtftuWi 9buN2XLOTDdBdAAn+Sov/picsmehXOdtXRJ+NahExQCIDbeTWTl/PVLkbbzp498PwLnT 3Uq8zo8qD/uZm9Ruwez8SdOr5O5LxnIRl/v5lhdgOrjE0ZvGz/zbErd/VyNLO6TqwpOT n5ew== X-Gm-Message-State: APjAAAXWr90322F4h5nceav9cie4IEbf8ncK6ssUqFV14MGVt6FJl9OS 56nIlBderIo52Q5uS3JTRzm98mnv X-Google-Smtp-Source: APXvYqyvkMldyc2PQF3bW3fhCxCudiC5mEQEX9tMLuupiW1HgBixS98w8ScBNHR7QWtoa94NQ+SVTg== X-Received: by 2002:ac8:43cc:: with SMTP id w12mr22758494qtn.301.1570482710466; Mon, 07 Oct 2019 14:11:50 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 18:11:34 -0300 Message-Id: <20191007211136.16730-3-danielhb413@gmail.com> In-Reply-To: <20191007211136.16730-1-danielhb413@gmail.com> References: <20191007211136.16730-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:11:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:11:52 +0000 (UTC) for IP:'209.85.160.176' DOMAIN:'mail-qt1-f176.google.com' HELO:'mail-qt1-f176.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.160.176 mail-qt1-f176.google.com 209.85.160.176 mail-qt1-f176.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH 2/4] Introducing assigned='yes|no' hostdev attribute 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: , 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:12:02 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The idea of having an attribute that declares that a hostdev is not to be assigned to the guest seems counterintuitive, but it has a niche use with multifunction PCI devices. The current use of this kind of device in Libvirt is to declare all of the functions in the XML. This is not ideal though - some devices might have functions that are security sensitive to be shared to guests, but at the same time the user might want to passthrough the other functions to a guest. This is what we call 'partial assignment'. Libvirt does not have proper support for this scenario: when using managed=3D'yes', this partial assignment will cause the code inside virhostdev.c to not detach all the IOMMU devices - given that we do not want all of them in the guest - and then we face a QEMU error because we didn't detached the whole IOMMU. An idea was discussed in [1] where Libvirt would automatically detach all the IOMMU devices in case any multifunction PCI hostdev is used in the guest, but this idea was discarded because removing user agency in this case is undesirable. The user must be aware of all the functions that are going to be detached from the host, even if they're not being assigned to the guest, to avoid scenarios in which Libvirt "all of a sudden" detaches something that the user didn't want to. This patch implements a new attribute called 'assigned' that indicates whether a hostdev is going to be assigned to the guest or not. To keep its use less intrusive for every other hostdev that does not need such control, the attribute can only be set by PCI multifunction devices. For existing domains prior to this change, assign=3D'yes' will be implied. If the user decides not to assign a specific function to the guest using assign=3D'no', the
field becomes unavailable and throws a parsing error if used. In the next patch we'll use this attribute to avoid assigning an assigned=3D'no' device to QEMU at boot. Signed-off-by: Daniel Henrique Barboza --- Note: the changes in the .config files were done because the existing .config data files weren't being recognized as multifunction PCI devices after we started reading the PCI header. docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 36 +++++++++++++++++- src/conf/domain_conf.h | 1 + .../hostdev-pci-multifunction.args | 7 ++-- .../hostdev-pci-multifunction.xml | 6 +++ .../hostdev-pci-multifunction.xml | 23 +++++++---- .../qemuxml2xmloutdata/pseries-hostdevs-1.xml | 4 +- .../qemuxml2xmloutdata/pseries-hostdevs-2.xml | 4 +- .../qemuxml2xmloutdata/pseries-hostdevs-3.xml | 4 +- tests/virpcitestdata/0005-90-01.1.config | Bin 256 -> 256 bytes tests/virpcitestdata/0005-90-01.2.config | Bin 256 -> 256 bytes tests/virpcitestdata/0005-90-01.3.config | Bin 0 -> 256 bytes tools/virsh-domain.c | 5 +++ 13 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 tests/virpcitestdata/0005-90-01.3.config diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 40eb4a2d75..d1a5c051e3 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4629,6 +4629,11 @@ pci + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a53cd6a725..8d80824a0a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7755,7 +7755,6 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, if (virXMLNodeNameEqual(cur, "address")) { virPCIDeviceAddressPtr addr =3D &def->source.subsys.u.pci.addr; - if (virPCIDeviceAddressParseXML(cur, addr) < 0) goto out; } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && @@ -8147,7 +8146,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virDomainHostdevDefPtr def, unsigned int flags) { - xmlNodePtr sourcenode; + xmlNodePtr sourcenode, addressnode; int backend; virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIPtr scsisrc =3D &def->source.subsys.u.scsi; @@ -8159,6 +8158,8 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, VIR_AUTOFREE(char *) backendStr =3D NULL; VIR_AUTOFREE(char *) model =3D NULL; VIR_AUTOFREE(char *) display =3D NULL; + VIR_AUTOFREE(char *) assigned =3D NULL; + =20 /* @managed can be read from the xml document - it is always an * attribute of the toplevel element, no matter what type of @@ -8289,6 +8290,32 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) <= 0) return -1; =20 + /* @assigned can only be set for multifunction PCI devices. + * In case the attribute is missing, always assume + * assigned =3D true. + */ + def->assigned =3D true; + + if ((assigned =3D virXMLPropString(node, "assigned")) !=3D NULL) { + if (!virHostdevIsPCIMultifunctionDevice(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'assigned' can only be set for multifunc= tion " + "PCI devices")); + return -1; + } + + if (STREQ(assigned, "no")) + def->assigned =3D false; + + if ((addressnode =3D virXPathNode("./address", ctxt)) && + !def->assigned) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unable to set
element " + "for assign=3D'no' hostdev")); + return -1; + } + } + backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT; if ((backendStr =3D virXPathString("string(./driver/@name)", ctxt)= ) && (((backend =3D virDomainHostdevSubsysPCIBackendTypeFromString(= backendStr)) < 0) || @@ -27254,6 +27281,11 @@ virDomainHostdevDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " managed=3D'%s'", def->managed ? "yes" : "no"); =20 + if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI && + virHostdevIsPCIMultifunctionDevice(def)) + virBufferAsprintf(buf, " assigned=3D'%s'", + def->assigned ? "yes" : "no"); + if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= SCSI && scsisrc->sgio) virBufferAsprintf(buf, " sgio=3D'%s'", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2884af49d8..e2f6f640b9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -343,6 +343,7 @@ struct _virDomainHostdevDef { bool missing; bool readonly; bool shareable; + bool assigned; union { virDomainHostdevSubsys subsys; virDomainHostdevCaps caps; diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.args b/tests/= qemuxml2argvdata/hostdev-pci-multifunction.args index d8690c010b..3cef177c00 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-multifunction.args +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.args @@ -30,6 +30,7 @@ server,nowait \ -device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev2,bus=3Dpci.0,addr=3D0x5 \ -device vfio-pci,host=3D0005:90:01.2,id=3Dhostdev3,bus=3Dpci.0,addr=3D0x6 \ -device vfio-pci,host=3D0005:90:01.3,id=3Dhostdev4,bus=3Dpci.0,addr=3D0x7 \ --device vfio-pci,host=3D0000:06:12.1,id=3Dhostdev5,bus=3Dpci.0,addr=3D0x8 \ --device vfio-pci,host=3D0000:06:12.2,id=3Dhostdev6,bus=3Dpci.0,addr=3D0x9 \ --device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0xa +-device vfio-pci,host=3D0000:06:12.0,id=3Dhostdev5,bus=3Dpci.0,addr=3D0x8 \ +-device vfio-pci,host=3D0000:06:12.1,id=3Dhostdev6,bus=3Dpci.0,addr=3D0x9 \ +-device vfio-pci,host=3D0000:06:12.2,id=3Dhostdev7,bus=3Dpci.0,addr=3D0xa \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0xb diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml b/tests/q= emuxml2argvdata/hostdev-pci-multifunction.xml index 06c889c64d..f4813961b3 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml @@ -43,6 +43,12 @@
+ + + +
+ + diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml b/tests= /qemuxml2xmloutdata/hostdev-pci-multifunction.xml index 52ed86e305..079e0513c1 100644 --- a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml +++ b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml @@ -23,35 +23,35 @@ - +
- +
- +
- +
- +
@@ -61,19 +61,26 @@ -
+
-
+
- + + + +
+
+ + +
diff --git a/tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml b/tests/qemuxm= l2xmloutdata/pseries-hostdevs-1.xml index e77a060a38..94472b38e4 100644 --- a/tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml +++ b/tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml @@ -35,14 +35,14 @@
- +
- +
diff --git a/tests/qemuxml2xmloutdata/pseries-hostdevs-2.xml b/tests/qemuxm= l2xmloutdata/pseries-hostdevs-2.xml index cfa395b001..f2fe94d2fb 100644 --- a/tests/qemuxml2xmloutdata/pseries-hostdevs-2.xml +++ b/tests/qemuxml2xmloutdata/pseries-hostdevs-2.xml @@ -30,14 +30,14 @@ - +
- +
diff --git a/tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml b/tests/qemuxm= l2xmloutdata/pseries-hostdevs-3.xml index f91959b805..0893ecd887 100644 --- a/tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml +++ b/tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml @@ -27,14 +27,14 @@ - +
- +
diff --git a/tests/virpcitestdata/0005-90-01.1.config b/tests/virpcitestdat= a/0005-90-01.1.config index beee76534041a7020c08ae9ac03d9a349c6ea12e..a60599bd342d3ebcdc7b8367ca3= 6ad337f602fde 100644 GIT binary patch delta 44 ycmZo*YG4vE7BFRCV-R3+7GUOK;Amg~f~JXq5)*X<85t+qEn;Cc-jFjfPzC^<7YL>R delta 39 ucmZo*YG4vE7BFRCV-R3+7GUOK;9y{25MXGU7$`AON05CJ=3D!Q7z5RUfCHEW5{!&mj0{Y5Fz#TaS&cX3;ByxM DCDjDB literal 256 zcmXpOc)-BMAi%_;z|6zo!oa|wz|aIFu>xbDS`csmlR$!5K#7rosSd`)Mk^@TV-u#E T7_0Gy9FS#<5E~CbCCJ=3D!Q7z5RUfCHEW5{!&mj0{Y5Fz#TaS&cX3;ByxM DCDjDB literal 0 HcmV?d00001 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index fbfdc09c0d..1453d7f024 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -858,6 +858,11 @@ static const vshCmdOptDef opts_attach_interface[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("libvirt will automatically detach/attach the device fro= m/to host") }, + {.name =3D "assigned", + .type =3D VSH_OT_BOOL, + .help =3D N_("hostdev virtual function will be assigned to the guest " + "(multifunction PCI device only)") + }, {.name =3D NULL} }; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 06:10:22 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1570482737; cv=none; d=zoho.com; s=zohoarc; b=OfUBd9NqPCGqqHSzetMa/Zp1vJFLvgT0GICYJo8DEm/dh0LP370G3yN/jZYkObduT0qIInXgmd7UzPPy8xe++K74Es7bPs0q1wYnSjRMfi2Lgm46KYvVYEWLSCtJ+59n+LSdu86/6Cxua1bIi2M6xENAEDvIecetR+FxOb/2wtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570482737; 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:ARC-Authentication-Results; bh=2AKQty3+WF1HKxcIQBWJ6eADLV4VpU5+LUBlo91BCUQ=; b=UfRv3wbkVWX7U8Rw1AM1/uMDAfcR17nqtOZ2dVFvELvEm8CEZemXDHJaxPYhSGgDOQGI+rELRzRb3+5x9J4aJAs7O4ae6Bc0SKbcgDeTLSLtnJp7tgccLZJ6ihTz5qLkQIVxUv1cwhEvGtaRwBAu4YHwaFohdsKzUOE80/csRew= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15704827370591.744835018533763; Mon, 7 Oct 2019 14:12:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34DF5302C08A; Mon, 7 Oct 2019 21:12:15 +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 0E718600C1; Mon, 7 Oct 2019 21:12:15 +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 BCF694EE68; Mon, 7 Oct 2019 21:12:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LBv3Z012229 for ; Mon, 7 Oct 2019 17:11:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61A2719C68; Mon, 7 Oct 2019 21:11:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BD6E19C69 for ; Mon, 7 Oct 2019 21:11:55 +0000 (UTC) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12D10308FC22 for ; Mon, 7 Oct 2019 21:11:53 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id w2so14126278qkf.2 for ; Mon, 07 Oct 2019 14:11:53 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:e8e7:3739:3e28:be31:8030]) by smtp.gmail.com with ESMTPSA id i30sm11333409qte.27.2019.10.07.14.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 14:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dB+xYqo1vLOuT1r4246Whp741oXEbUAXavZdTetyOHk=; b=Kj9d8jNxjzypCY1Boahikx8zPXgisdwEwElKwccMCVb5B0m8HvcbCbJY5skQ17MQt4 54BgQ2rmuUJkgabAR2eHu1fXJ2/kjCVrK/AdCvEVEPUv/BSFKnj5fRYWXq9AWpS9xFRi d5j3b6Xh1IjjkSW1/KLAhIp2BiKwKcfytSwnc0iOgVE6E9BCXJhf7d+wrLOmIqV240Fj z/sUPvo+BXuL/uwJby+6r8wHRkTmf2XnckPJSgS+Y9yltQ8xXlh77fK66S+OrksmyMPJ FfNcARiQ0EvbowMbtr0rQmhr1TLfcfgyZWGyIZA//IsnuC9fgM7iaCK23bHbJQQeDo7q BNOw== 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=dB+xYqo1vLOuT1r4246Whp741oXEbUAXavZdTetyOHk=; b=QHw70rBssvNUgmXDQffvUgd0Oz9IBuxyJKbCGvzyDJbgmbAg3HdeTivPOFWuqc4/vV CYgTW5Ns3sIOoGN8SVHXjwcpMd4O4jY5CQUm1YcH4UOCh6wddTcTf741/Eafs7jPv8wA K8FC6iHn3g6nyGEzjW3JUjmk0G/p5+5/gC7JHqnvyIGmtYhxQN5TtYuLXZ67l8GOWzWh Ax0TiOqRlzIlgdwp/J721pzV+ewahSlBxmhvjXIsuNSk6mMbGaCsQeiTFycNYe1r3U2F vqdrrpEZgwTHgCb0wmzffLnfERJ7VhfO25qYz0PgAQ4F1BuD3SfSL9qgBgySpYO90HfT ovHg== X-Gm-Message-State: APjAAAVhUTNvXewuvzYD8g/N46aPBouRmZp3DRp5N9Bp6f1XNY7u31WD NlCrw23V417z+AKehypDpCws5ked X-Google-Smtp-Source: APXvYqzg2mOqWPji+4Zr48659G4cWFZdNMB8FoDcwddlsrZjyfLRw4K5B8gfsqvIy2iHLNaelIqNAA== X-Received: by 2002:a37:7fc7:: with SMTP id a190mr25717456qkd.351.1570482711984; Mon, 07 Oct 2019 14:11:51 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 18:11:35 -0300 Message-Id: <20191007211136.16730-4-danielhb413@gmail.com> In-Reply-To: <20191007211136.16730-1-danielhb413@gmail.com> References: <20191007211136.16730-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 21:11:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 21:11:53 +0000 (UTC) for IP:'209.85.222.193' DOMAIN:'mail-qk1-f193.google.com' HELO:'mail-qk1-f193.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.193 mail-qk1-f193.google.com 209.85.222.193 mail-qk1-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH 3/4] qemu_command: ignore non-assigned PCI multifunction 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 07 Oct 2019 21:12:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Bulding up in the new attribute introduced by the previous patch, let's not assign a hostdev to a QEMU domain by avoiding the '-device' line to be created at all inside qemu_command.c. Since the device isn't going to be guest visible, makes little sense to assign alias and address to it, so let's also prevent that. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_alias.c | 8 +++ src/qemu/qemu_command.c | 5 ++ src/qemu/qemu_domain_address.c | 7 +++ .../hostdev-pci-multifunction-partial.args | 31 ++++++++++ .../hostdev-pci-multifunction-partial.xml | 41 +++++++++++++ tests/qemuxml2argvtest.c | 4 ++ .../hostdev-pci-multifunction-partial.xml | 57 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 8 files changed, 154 insertions(+) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction-partia= l.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction-partia= l.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-pci-multifunction-part= ial.xml diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index d294963d35..f1705a9a47 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -602,6 +602,14 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCa= psPtr qemuCaps) return -1; } for (i =3D 0; i < def->nhostdevs; i++) { + /* do not assign alias for PCI multifunction hostdevs that + * will not be assigned to the guest. + */ + + if (virHostdevIsPCIMultifunctionDevice(def->hostdevs[i]) && + !def->hostdevs[i]->assigned) + continue; + /* we can't start assigning at 0, since netdevs may have used * up some hostdevN entries already. Also if the HostdevDef is * linked to a NetDef, they will share an info and the alias diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cbf25d5f07..1e12550e9b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5490,6 +5490,11 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, } } =20 + /* Ignore 'noAssign' devices + */ + if (!hostdev->assigned) + continue; + unsigned int bootIndex =3D hostdev->info->bootIndex; =20 /* bootNet will be non-0 if boot order was set and no other diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 4f5671f458..71711e22d2 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2319,6 +2319,13 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, continue; } =20 + /* Do not assign an address to a hostdev that will not + * be assigned to the guest. + */ + if (virHostdevIsPCIMultifunctionDevice(def->hostdevs[i]) && + !def->hostdevs[i]->assigned) + continue; + if (qemuDomainPCIAddressReserveNextAddr(addrs, def->hostdevs[i]->info) < = 0) goto error; diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.args = b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.args new file mode 100644 index 0000000000..4074968c84 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.args @@ -0,0 +1,31 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-delete \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-delete/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-delete/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-delete/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name delete \ +-S \ +-machine pc,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ +-m 256 \ +-realtime mlock=3Doff \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-delete/monitor.= sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-device vfio-pci,host=3D0005:90:01.0,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0005:90:01.1,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4 \ +-device vfio-pci,host=3D0005:90:01.3,id=3Dhostdev2,bus=3Dpci.0,addr=3D0x5 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x6 diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.xml b= /tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.xml new file mode 100644 index 0000000000..e87dfcdcff --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial.xml @@ -0,0 +1,41 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 4 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db79301f0e..434e01308c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1357,6 +1357,10 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_VFIO_PCI); =20 + DO_TEST("hostdev-pci-multifunction-partial", + QEMU_CAPS_KVM, + QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV_FILE_APPEND, QEMU_CAPS_DEVICE_ISA_SERIAL, diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction-partial.xml= b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction-partial.xml new file mode 100644 index 0000000000..aa8da25ccd --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction-partial.xml @@ -0,0 +1,57 @@ + + 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 d5c66d8791..5e0fa6af86 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -441,6 +441,7 @@ mymain(void) DO_TEST("hostdev-usb-address", NONE); DO_TEST("hostdev-pci-address", NONE); DO_TEST("hostdev-pci-multifunction", NONE); + DO_TEST("hostdev-pci-multifunction-partial", NONE); DO_TEST("hostdev-vfio", NONE); DO_TEST("hostdev-vfio-zpci", QEMU_CAPS_DEVICE_ZPCI, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 06:10:22 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1570482852; cv=none; d=zoho.com; s=zohoarc; b=S64gRRnqmVClo/Y6g8uywP7nDf+eO1kYI0SegLYX+xdMm/WETwPxSvHqW2McpRWxPxkyOMJNWAOhTGVAinvxMmxzaIE86ojggL/UDtb9FJtBPdYOmqNOQvoCBNayUoyyQC2uPrmJskAk+JRXvE3xkquvfVCYxqwTS7INciPkRmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570482852; 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:ARC-Authentication-Results; bh=xtUd5MBWU6jKW+vwJYgXs8SDNyxJWSgmaNf7ZfhqG5s=; b=MbvCoKlSCOHCQ36yx4eryafKFvYm1EczDltBg4ZVYICjveogNJRU8kKe1Cc7hQXzFinCKWhBC1+Z/VBBXGBM7MezG4bR9fc1EfbMMXio63Gi8Xfw1t5MqmVwo6mnombeII6PspOXcdX/K4lOw9rRo9gkSQHgNzPUPEyvvatyq10= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570482852015569.1591435072257; Mon, 7 Oct 2019 14:14:12 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 16E08302245A; Mon, 7 Oct 2019 21:14:10 +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 E568A60C5E; Mon, 7 Oct 2019 21:14:09 +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 A342E1803B48; Mon, 7 Oct 2019 21:14:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LBvmf012234 for ; Mon, 7 Oct 2019 17:11:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF9535EE1D; Mon, 7 Oct 2019 21:11:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E97BD5D772 for ; Mon, 7 Oct 2019 21:11:55 +0000 (UTC) Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5CDC5302245A for ; Mon, 7 Oct 2019 21:11:54 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id h126so14081030qke.10 for ; Mon, 07 Oct 2019 14:11:54 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:e8e7:3739:3e28:be31:8030]) by smtp.gmail.com with ESMTPSA id i30sm11333409qte.27.2019.10.07.14.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 14:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4eeHXQ75aFKz3EuSJMlNDQnpPrNjQcyheeXaKroYmLo=; b=jeJ8FdB06I0jm6ej1Oe9uo2QizEL/Wy2w4p5mxNOOMKoq6RO02uu5/Otp+zsas4chq CNAQgFQpTcPiFTtuRsg+ADOnzcwwmle6LfcdbnExcjwRAXbrX3Gshd7r0a9A1nb0WI4S oJbKb3fHqSuUqY+lKRHkQGTkLCBZDVhLy0GFCBMzfM+LxrMzuwUTV33LE+vTR2+AoJjP OqGH7zsP26w3/sWlqxktb2zxGX7DdjU/Th60LmiLijVfpojrQ8GRsamyl9YpvQ6HeugJ mS/2GRyi6CgSC6LoZwq+WhmDbdfSnFXfdP3Vi4VwnR/WFo0ualcR8mHdtutBiGqw7XnC 0QLg== 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=4eeHXQ75aFKz3EuSJMlNDQnpPrNjQcyheeXaKroYmLo=; b=dthcQYxqi/eNKNhRkrPrvz1pCYIit/UCgeTdHJbN1g3+zB74rstLi0EBiPa2f7H2Rj tn5tEyI4/JcgzcH8LJi0rEZiXOyyDTnovr2SVm165ywzA3YnffanEkb/dxExYfSZHSnD ObQq5gU92cIMe6xDuIju8IRpnia3SD4ioqiMIo4j2EVLn9CAor2l8HqO7wBTQwrbqYUg oevLl3+nkpZElMhMuhDmSdOSy0/D4H/BfYLyetWPdHVymFLnoBWxy5OaCz6hP1R/9ox5 OelDe4i3NUoj7yGEgQljml0zTe2ft2bjDy5Sl7aRtAV5NW0NsgGYMGHAz5Lv3G09RsUp NeMw== X-Gm-Message-State: APjAAAXcS0yuf3EDjZ6XpUs+3HgUeYeprLm6BKnKK6ZpJYZxcka0NWbA KJVHf3Di4XQ7Iul3SK2tfYjnpUOl X-Google-Smtp-Source: APXvYqz9uIICTX5OrKOs3dBsPO2XNu26yRJN0w2sk++LYRQyTi4M2jIWxTQ3a1XZjKLbWz/90mTOVg== X-Received: by 2002:a37:a849:: with SMTP id r70mr25508400qke.37.1570482713345; Mon, 07 Oct 2019 14:11:53 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 18:11:36 -0300 Message-Id: <20191007211136.16730-5-danielhb413@gmail.com> In-Reply-To: <20191007211136.16730-1-danielhb413@gmail.com> References: <20191007211136.16730-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:11:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:11:54 +0000 (UTC) for IP:'209.85.222.176' DOMAIN:'mail-qk1-f176.google.com' HELO:'mail-qk1-f176.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.176 mail-qk1-f176.google.com 209.85.222.176 mail-qk1-f176.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH 4/4] virhostdev: all functions of a PCI multifunction dev must be added 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:14:10 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is the last piece for a full fledged PCI multifunction partial assignment support. Now that we have a defined XML format and QEMU is ignoring the existence of the hostdev that isn't being assigned, let's enforce that all functions must be declared in the domain XML for such devices. This will make sure that we'll always detach/re-attach the whole IOMMU and will force the user to be aware of what is going to be detached from the host. Signed-off-by: Daniel Henrique Barboza --- src/util/virhostdev.c | 64 ++++++++++++++++++- ...ostdev-pci-multifunction-partial-fail.args | 31 +++++++++ ...hostdev-pci-multifunction-partial-fail.xml | 35 ++++++++++ tests/qemuxml2argvtest.c | 4 ++ 4 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction-partia= l-fail.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction-partia= l-fail.xml diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 1aa8e9729d..a85860b34f 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -56,6 +56,13 @@ struct virHostdevIsPCINodeDeviceUsedData { bool usesVFIO; }; =20 +struct virHostdevIsAllIOMMUGroupUsedData { + virPCIDeviceListPtr pcidevs; + const char *domainName; + const char *deviceName; +}; + + /* This module makes heavy use of bookkeeping lists contained inside a * virHostdevManager instance to keep track of the devices' status. To make * it easy to spot potential ownership errors when moving devices from one @@ -114,6 +121,26 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceA= ddressPtr devAddr, void *o return ret; } =20 +static int virHostdevIsAllIOMMUGroupUsed(virPCIDeviceAddressPtr devAddr, v= oid *opaque) +{ + struct virHostdevIsAllIOMMUGroupUsedData *helperData =3D opaque; + virPCIDevicePtr actual; + + actual =3D virPCIDeviceListFindByIDs(helperData->pcidevs, + devAddr->domain, devAddr->bus, + devAddr->slot, devAddr->function); + if (actual) { + return 0; + } else { + virReportError(VIR_ERR_OPERATION_INVALID, + _("All devices of the same IOMMU group as the " + "multifunction PCI device %s must belong to " + "domain %s"), + helperData->deviceName, helperData->domainName); + return -1; + } +} + static int virHostdevManagerOnceInit(void) { if (!VIR_CLASS_NEW(virHostdevManager, virClassForObject())) @@ -714,9 +741,10 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, unsigned int flags) { VIR_AUTOUNREF(virPCIDeviceListPtr) pcidevs =3D NULL; + VIR_AUTOFREE(unsigned int *) searchedIOMMUs =3D NULL; int last_processed_hostdev_vf =3D -1; - size_t i; - int ret =3D -1; + size_t i, j; + int ret =3D -1, nSearchedIOMMUs =3D 0; virPCIDeviceAddressPtr devAddr =3D NULL; =20 if (!nhostdevs) @@ -725,6 +753,9 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, if (!(pcidevs =3D virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) return -1; =20 + if (VIR_ALLOC_N(searchedIOMMUs, virPCIDeviceListCount(pcidevs))) + return -1; + virObjectLock(mgr->activePCIHostdevs); virObjectLock(mgr->inactivePCIHostdevs); =20 @@ -767,6 +798,35 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, if (virHostdevIsPCINodeDeviceUsed(devAddr, &data)) goto cleanup; =20 + /* Multifunction PCI devices are more restrict than regular + * VFIO devices, since it requires *all* devices from the same + * IOMMU to belong to the same domain - even if not all of + * them are assigned to the guest. + */ + if (virPCIDeviceIsMultifunction(pci)) { + struct virHostdevIsAllIOMMUGroupUsedData helper =3D { + pcidevs, dom_name, virPCIDeviceGetName(pci)}; + int devIOMMUGroup =3D virPCIDeviceAddressGetIOMMUGroupNum(devA= ddr); + bool alreadySearched =3D false; + + for (j =3D 0; j < nSearchedIOMMUs; j++) { + if (devIOMMUGroup =3D=3D searchedIOMMUs[j]) { + alreadySearched =3D true; + break; + } + } + + if (alreadySearched) + continue; + + if (virPCIDeviceAddressIOMMUGroupIterate( + devAddr, virHostdevIsAllIOMMUGroupUsed, &helper) < 0) + goto cleanup; + + searchedIOMMUs[nSearchedIOMMUs++] =3D devIOMMUGroup; + continue; + } + /* VFIO devices belonging to same IOMMU group can't be * shared across guests. Check if that's the case. */ if (usesVFIO) { diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial-fail.= args b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial-fail.args new file mode 100644 index 0000000000..4074968c84 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial-fail.args @@ -0,0 +1,31 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-delete \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-delete/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-delete/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-delete/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name delete \ +-S \ +-machine pc,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ +-m 256 \ +-realtime mlock=3Doff \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-delete/monitor.= sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-device vfio-pci,host=3D0005:90:01.0,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0005:90:01.1,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4 \ +-device vfio-pci,host=3D0005:90:01.3,id=3Dhostdev2,bus=3Dpci.0,addr=3D0x5 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x6 diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial-fail.= xml b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial-fail.xml new file mode 100644 index 0000000000..fc3e3bb520 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction-partial-fail.xml @@ -0,0 +1,35 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 4 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 434e01308c..462852c690 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1361,6 +1361,10 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_VFIO_PCI); =20 + DO_TEST("hostdev-pci-multifunction-partial-fail", + QEMU_CAPS_KVM, + QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV_FILE_APPEND, QEMU_CAPS_DEVICE_ISA_SERIAL, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list