From nobody Wed May 8 19:43:38 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=1567106363; cv=none; d=zoho.com; s=zohoarc; b=YNoNoocOe2XC0jr1PLPs0KZt3x5b3phtnSSRSmLXqCbhd7O7Z+wz55h/Li5jap+/I0ZO+1ZNAnPjoc9rhKZqLmu+BmtC47M9ICOk/kio2L2xhWiV/2mmPFNx154iluSxHrO6hAfKOMe7wC6LiqpbMWtR3j7Fw1HZsXOomCy6g88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567106363; 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=9LwwHTaZqJyRVIFZqxl46JEkLBelfs49nsrQng/5d7o=; b=P3zgUaR7+mOtzQbd2YdGX7Wuij4km5REuvaAFYkcYU8Q9svbwR7ieG2mP9ntd1KgQDsCU4JRyCgoQBggB074JDBm1/NFLv54hghMLETsE+CJO9HOLrcmT8ENlSLXHFSR9DoQtrGPRRQvpMBwXiNPN24If6Sb3Fn7ZHhjQw/yuw8= 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 1567106363719132.0245737505353; Thu, 29 Aug 2019 12:19:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A415218001AD; Thu, 29 Aug 2019 19:19:20 +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 1744E19D7A; Thu, 29 Aug 2019 19:19:20 +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 A2B5424F32; Thu, 29 Aug 2019 19:19:17 +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 x7TJJG4D023544 for ; Thu, 29 Aug 2019 15:19:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06F1D196B2; Thu, 29 Aug 2019 19:19:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECF7F9D4F; Thu, 29 Aug 2019 19:19:15 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (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 A65DA308212A; Thu, 29 Aug 2019 19:19:14 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id k13so4923047qtm.12; Thu, 29 Aug 2019 12:19:14 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:9589:1351:c7eb:87b:c9d5]) by smtp.gmail.com with ESMTPSA id m19sm1827976qke.22.2019.08.29.12.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 12:19:12 -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=/aO/tozzYJFIgcsnvVu2fR3ECXvNUuvqD1omkkavOi8=; b=omIxBUsqZPagWFmYkbLCI3z66fAUT19x/tRLX1MUj6zHOAc5nJBy+bFJ3RRPT2lUZJ JRe590qNHbgWtr1TTFCAfH8FVVOZp7V8FxvhaXustnhNM/9lmNEmTShvmkChEBFTouJP QVfH9ie5uPsi0xGBF/QgvXnRdJjJpSuzct6kBBxfA8i1MZ07vL4LHG92BZtV2BBi6Ag9 gD2Erjd8OrGhcZ3CmE2Zh2d1agUqCUnigG/BSUBUM0DgCqBKW/TxxsHJQbWVnGFFutUh jMEfL4xlJMUCo53daN+Ub3UyO+/HHdX+Kbh59nz+4mLvdNrDwpCDV5bBcBlDsHkHvzgc zY5A== 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=/aO/tozzYJFIgcsnvVu2fR3ECXvNUuvqD1omkkavOi8=; b=HPDUrsbipkd0MFlQE92NxBqBCF5liTb3sradg7rFCkxI1rj6cFne8xYF9hgT15BHTl FS+4RE5nYsHzsHeY6jlRhthBvyD5Xmsf/rqcPEb3MKaKHMYlLyz6g+EFVzIv0QGmXhMJ /NRYSjw8pYl7Rx/KeAZVkMPSJTTUV2ZAREhBcVlM41LdZiDKfmTMKHlWycjatCCZl76V TLvNGKunznsiC/+k0NvqKz0UmrEZTKhAAqozs+Gh/H+4aUQ6n2Zdr51H6k1GP6UCvHbN oYK3Ys4TSZrUke1By7g0VanShepfVwz+k8RtLaB95mo3XIFKeFkBrNP3OtNK8othG0+t 4xgw== X-Gm-Message-State: APjAAAXgPUPULaYi4gPa6Btz90qdTXHg57VdhDj+Xceoy0kRsyiNnvis iIIoh0P6yhnKdCDHhN6dM7nS7j++ X-Google-Smtp-Source: APXvYqwHI9j/xIeVeoOK0KNgJeF6SvT2qCJ5xiTnlpY/Pm5SvRtidKrBhJRHWtMOc3k8QVmd/u1Inw== X-Received: by 2002:ac8:1488:: with SMTP id l8mr11689816qtj.50.1567106353585; Thu, 29 Aug 2019 12:19:13 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 16:18:58 -0300 Message-Id: <20190829191902.10084-2-danielhb413@gmail.com> In-Reply-To: <20190829191902.10084-1-danielhb413@gmail.com> References: <20190829191902.10084-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.42]); Thu, 29 Aug 2019 19:19:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 29 Aug 2019 19:19:14 +0000 (UTC) for IP:'209.85.160.195' DOMAIN:'mail-qt1-f195.google.com' HELO:'mail-qt1-f195.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.151 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.160.195 mail-qt1-f195.google.com 209.85.160.195 mail-qt1-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza Subject: [libvirt] [PATCH v3 1/5] virpcimock.c: mock /dev/vfio 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 29 Aug 2019 19:19:22 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch adds mock of the /dev/vfio path, needed for proper implementation of the support for multifunction/multiple devices per iommu groups. To do that, the existing bind and unbind operations were adapted to operate with the mocked filesystem as well. Signed-off-by: Daniel Henrique Barboza --- tests/virpcimock.c | 159 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 143 insertions(+), 16 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index a5045ed97c..e9440e7910 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -47,6 +47,7 @@ char *fakerootdir; =20 # define SYSFS_PCI_PREFIX "/sys/bus/pci/" =20 + # define STDERR(...) \ fprintf(stderr, "%s %zu: ", __FUNCTION__, (size_t) __LINE__); \ fprintf(stderr, __VA_ARGS__); \ @@ -105,6 +106,11 @@ struct pciDriver { size_t len; /* @len is used for both @vendor and @device */ }; =20 +struct pciIommuGroup { + int iommu; + size_t nDevicesBoundToVFIO; /* Indicates the devices in the group */ +}; + struct pciDeviceAddress { unsigned int domain; unsigned int bus; @@ -133,6 +139,9 @@ size_t nPCIDevices =3D 0; struct pciDriver **pciDrivers =3D NULL; size_t nPCIDrivers =3D 0; =20 +struct pciIommuGroup **pciIommuGroups =3D NULL; +size_t npciIommuGroups =3D 0; + struct fdCallback *callbacks =3D NULL; size_t nCallbacks =3D 0; =20 @@ -254,6 +263,15 @@ getrealpath(char **newpath, errno =3D ENOMEM; return -1; } + } else if (STRPREFIX(path, "/sys/kernel/") || + STRPREFIX(path, "/dev/vfio/")) { + + if (virAsprintfQuiet(newpath, "%s/%s", + fakerootdir, + path) < 0) { + errno =3D ENOMEM; + return -1; + } } else { if (VIR_STRDUP_QUIET(*newpath, path) < 0) return -1; @@ -389,8 +407,10 @@ static void pci_device_create_iommu(const struct pciDevice *dev, const char *devid) { + struct pciIommuGroup *iommuGroup; VIR_AUTOFREE(char *) iommuPath =3D NULL; char tmp[256]; + size_t i; =20 if (virAsprintfQuiet(&iommuPath, "%s/sys/kernel/iommu_groups/%d/device= s/", fakerootdir, dev->iommuGroup) < 0) @@ -406,6 +426,23 @@ pci_device_create_iommu(const struct pciDevice *dev, } =20 make_symlink(iommuPath, devid, tmp); + + /* pci_device_create_iommu can be called more than one for the + * same iommuGroup. Bail out here if the iommuGroup was already + * created beforehand. */ + for (i =3D 0; i < npciIommuGroups; i++) + if (pciIommuGroups[i]->iommu =3D=3D dev->iommuGroup) + return; + + if (VIR_ALLOC_QUIET(iommuGroup) < 0) + ABORT_OOM(); + + iommuGroup->iommu =3D dev->iommuGroup; + iommuGroup->nDevicesBoundToVFIO =3D 0; /* No device bound to VFIO by d= efault */ + + if (VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, + iommuGroup) < 0) + ABORT_OOM(); } =20 =20 @@ -558,6 +595,77 @@ pci_device_autobind(struct pciDevice *dev) return pci_driver_bind(driver, dev); } =20 +static int +pci_vfio_release_iommu(struct pciDevice *device) +{ + VIR_AUTOFREE(char *) vfiopath =3D NULL; + int ret =3D -1; + size_t i =3D 0; + + for (i =3D 0; i < npciIommuGroups; i++) { + if (pciIommuGroups[i]->iommu =3D=3D device->iommuGroup) { + + if (pciIommuGroups[i]->nDevicesBoundToVFIO =3D=3D 0) { + ret =3D 0; + goto cleanup; + } + + pciIommuGroups[i]->nDevicesBoundToVFIO--; + + if (!pciIommuGroups[i]->nDevicesBoundToVFIO) { + + if (virAsprintfQuiet(&vfiopath, "%s/dev/vfio/%d", + fakerootdir, + device->iommuGroup) < 0) { + errno =3D ENOMEM; + goto cleanup; + } + + if (unlink(vfiopath) < 0) + goto cleanup; + } + break; + } + } + + ret =3D 0; + + cleanup: + return ret; +} + +static int +pci_vfio_lock_iommu(struct pciDevice *device) +{ + VIR_AUTOFREE(char *) vfiopath =3D NULL; + int ret =3D -1; + size_t i =3D 0; + int fd =3D -1; + + for (i =3D 0; i < npciIommuGroups; i++) { + if (pciIommuGroups[i]->iommu =3D=3D device->iommuGroup) { + if (!pciIommuGroups[i]->nDevicesBoundToVFIO) { + if (virAsprintfQuiet(&vfiopath, "%s/dev/vfio/%d", + fakerootdir, + device->iommuGroup) < 0) { + errno =3D ENOMEM; + goto cleanup; + } + if ((fd =3D real_open(vfiopath, O_CREAT)) < 0) + goto cleanup; + + pciIommuGroups[i]->nDevicesBoundToVFIO++; + } + break; + } + } + + ret =3D 0; + + cleanup: + real_close(fd); + return ret; +} =20 /* * PCI Driver functions @@ -719,6 +827,10 @@ pci_driver_bind(struct pciDriver *driver, if (symlink(devpath, driverpath) < 0) return -1; =20 + if (STREQ(driver->name, "vfio-pci")) + if (pci_vfio_lock_iommu(dev) < 0) + return -1; + dev->driver =3D driver; return 0; } @@ -749,6 +861,10 @@ pci_driver_unbind(struct pciDriver *driver, unlink(driverpath) < 0) return -1; =20 + if (STREQ(driver->name, "vfio-pci")) + if (pci_vfio_release_iommu(dev) < 0) + return -1; + dev->driver =3D NULL; return 0; } @@ -865,6 +981,15 @@ init_env(void) make_dir(tmp, "drivers"); make_file(tmp, "drivers_probe", NULL, -1); =20 + /* Create /dev/vfio/ dir and /dev/vfio/vfio file */ + if (virAsprintfQuiet(&tmp, "%s/dev/vfio", fakerootdir) < 0) + ABORT_OOM(); + + if (virFileMakePath(tmp) < 0) + ABORT("Unable to create: %s", tmp); + + make_file(tmp, "vfio", NULL, -1); + # define MAKE_PCI_DRIVER(name, ...) \ pci_driver_new(name, __VA_ARGS__, -1, -1) =20 @@ -872,29 +997,31 @@ init_env(void) MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); MAKE_PCI_DRIVER("vfio-pci", -1, -1); =20 -# define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ +# define MAKE_PCI_DEVICE(Id, Vendor, Device, IommuGroup, ...) \ do { \ struct pciDevice dev =3D {.vendor =3D Vendor, \ - .device =3D Device, __VA_ARGS__}; \ + .device =3D Device, \ + .iommuGroup =3D IommuGroup, __VA_ARGS__}; \ if (pci_address_parse(&dev.addr, Id) < 0) \ ABORT("Unable to parse PCI address " Id); \ pci_device_new_from_stub(&dev); \ } while (0) =20 - MAKE_PCI_DEVICE("0000:00:00.0", 0x8086, 0x0044); - MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044); - MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046); - MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048); - MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, .klass =3D 0x060400); - MAKE_PCI_DEVICE("0001:01:00.0", 0x8086, 0x105e, .iommuGroup =3D 0); - MAKE_PCI_DEVICE("0001:01:00.1", 0x8086, 0x105e, .iommuGroup =3D 0); - MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, .klass =3D 0x060400); - MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035, .iommuGroup =3D 1); - MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035, .iommuGroup =3D 1); - MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0, .iommuGroup =3D 1); - MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047); - MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048); - MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048); + MAKE_PCI_DEVICE("0000:00:00.0", 0x8086, 0x0044, 0); + MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044, 1); + MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046, 2); + MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048, 3); + MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, 4, .klass =3D 0x060400= ); + MAKE_PCI_DEVICE("0001:01:00.0", 0x8086, 0x105e, 5); + MAKE_PCI_DEVICE("0001:01:00.1", 0x8086, 0x105e, 5); + MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, 6, .klass =3D 0x060400= ); + MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035, 7); + MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035, 7); + MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0, 7); + MAKE_PCI_DEVICE("0005:90:01.3", 0x1033, 0x00e0, 7); + MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, 8); + MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, 8); + MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, 8); } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 19:43:38 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=1567106376; cv=none; d=zoho.com; s=zohoarc; b=Nj32aVItbHCTSJ/JKuTwJNPSZX07cCePXslDD8xLV/uwgvlarhpadcaydgHtk3CkhA+KmvszN1MTawShe+fILUQo76uMAA94MaKH1ADyxguwGx/cfEma8tMBYoIpM73SsSqdeWtu+clpSk7YPt9Qz1hGIrvvmmyPhjXF1apkZHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567106376; 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=f2RjLw0gs40zfTARoTG1nBpeBtZH4AwHW1nUBNIQgao=; b=RpFVPug3rvX7xIMMDjbnCqh+5YEHQlcVeTtkpGhbg2P+qP/05iWTTqjXQwauQ3TEs6zgWzAy46/t3xr65f7XDnE96mnRDaC7H6VkCLb0gPdNHi/dakIRkuRT0STECzXdNjrzJARfTTBbtF84eBgGEpDPHi/ZJD/Wj1sSX1R9JPA= 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 1567106376660191.972135378825; Thu, 29 Aug 2019 12:19:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F03EB652; Thu, 29 Aug 2019 19:19:35 +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 F03C05D9D3; Thu, 29 Aug 2019 19:19:34 +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 B183F180B536; Thu, 29 Aug 2019 19:19:34 +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 x7TJJKaj023565 for ; Thu, 29 Aug 2019 15:19:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id BED3F60E3E; Thu, 29 Aug 2019 19:19:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 240E960BEC; Thu, 29 Aug 2019 19:19:17 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (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 67AC66412B; Thu, 29 Aug 2019 19:19:16 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id n7so4961468qtb.6; Thu, 29 Aug 2019 12:19:16 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:9589:1351:c7eb:87b:c9d5]) by smtp.gmail.com with ESMTPSA id m19sm1827976qke.22.2019.08.29.12.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 12:19:15 -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=NDzMnutmDy6V/a3a19ZaujfyOeyJ4oPLfwvW70331W4=; b=q93LklvUNHctIK//py0dIR7q0BN25EaNAAnoa4vSQLt/0tLXqzwfmFkUB5fM4rxcVv NlECSCFP6Wr4LaIw4uTqVpax7mas8sKJLEmNSciCv0vKNKVv87yV3qyvEqSlse2ZcQqL kuD2RTnV8FM1p/X/T/j3Z/bcgieVUuLQxr9obaGuMXfYi2qocX6j9H4LFjCQCFSgZHlW IUEsPPxsDI/GHDtwUYTvkS1iMBBDL1RDrkfeeWFzcBSKT67aBXpoNnMSBF6zXz/rwxvB 8kjrlV+d+xJDSpmKo9hthz/2UNHIM10lbF+kiRSlBR5uMlOO6xlcZMZRELRhEp9wZCOg XicA== 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=NDzMnutmDy6V/a3a19ZaujfyOeyJ4oPLfwvW70331W4=; b=dfpZofeoTBmoJv1Vk3N16iL9nh+Ig6U3xjePWBvngaxnG1p4rXDmaFKIfQqwluQNzp ORjy0QUQX3oplBRsQyhRTbNYXTrTlrFWCVI2gmMjnvFwlReAkElbf2Baw7coJfmOdWFn FVGOTGjBSM11p/+I3oaeM6rLUJRkCVdYwIleE2ytR3pnbbkqw2BB3P9pKqcGx9K+4qWe H30d7bd/eLBXbJY0Xp/j/KyFt5/YPg/5Dbk4osLiEdd22+rX/RKlmg8oDDRRiHkBqQAd O/VZU4PIIrIAMaPh+1Otgz+SChcFdjGNeoNqzz5HIOqNyCDU4AO12w81UEGLdanR10ht FICA== X-Gm-Message-State: APjAAAW5tWduUWfgzBylt3EKyKUHnuGw+TJyCadBGtMmKTTpzu+AWGRu //kRIZZWkyIukup80RPyCDxlxyip X-Google-Smtp-Source: APXvYqwGF5cZ1mkkV1Q7/ugT6yUFmyqikadWhIgyHWi3MwFgK5jKSxi8+7ZWrJohCKOIgZRpG8Fhgg== X-Received: by 2002:ac8:48c3:: with SMTP id l3mr11513894qtr.281.1567106355436; Thu, 29 Aug 2019 12:19:15 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 16:18:59 -0300 Message-Id: <20190829191902.10084-3-danielhb413@gmail.com> In-Reply-To: <20190829191902.10084-1-danielhb413@gmail.com> References: <20190829191902.10084-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.39]); Thu, 29 Aug 2019 19:19:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 29 Aug 2019 19:19:16 +0000 (UTC) for IP:'209.85.160.195' DOMAIN:'mail-qt1-f195.google.com' HELO:'mail-qt1-f195.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.151 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.160.195 mail-qt1-f195.google.com 209.85.160.195 mail-qt1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza Subject: [libvirt] [PATCH v3 2/5] virpcimock: Mock the SRIOV Virtual functions 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 29 Aug 2019 19:19:35 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat The softlink to physfn is the way to know if the device is VF or not. So, the patch softlinks 'physfn' to the parent function. The multifunction PCI devices dont have 'physfn' softlinks. The patch adds few Virtual functions to the mock environment and changes the existing VFIO test xmls using the VFs to use the newly added VFs for their use case. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- .../hostdev-vfio-multidomain.args | 2 +- .../hostdev-vfio-multidomain.xml | 2 +- tests/qemuxml2argvdata/hostdev-vfio.args | 2 +- tests/qemuxml2argvdata/hostdev-vfio.xml | 2 +- tests/qemuxml2argvdata/net-hostdev-fail.xml | 2 +- tests/qemuxml2argvdata/net-hostdev-vfio.args | 2 +- tests/qemuxml2argvdata/net-hostdev-vfio.xml | 2 +- tests/qemuxml2xmloutdata/hostdev-vfio.xml | 2 +- tests/qemuxml2xmloutdata/net-hostdev-vfio.xml | 2 +- tests/virpcimock.c | 19 ++++++++++++++++++ tests/virpcitestdata/0000-06-12.0.config | Bin 0 -> 256 bytes tests/virpcitestdata/0000-06-12.1.config | Bin 0 -> 256 bytes tests/virpcitestdata/0000-06-12.2.config | Bin 0 -> 256 bytes 13 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 tests/virpcitestdata/0000-06-12.0.config create mode 100644 tests/virpcitestdata/0000-06-12.1.config create mode 100644 tests/virpcitestdata/0000-06-12.2.config diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args b/tests/q= emuxml2argvdata/hostdev-vfio-multidomain.args index d098bff356..959d2a8888 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args +++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args @@ -27,5 +27,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --device vfio-pci,host=3D55aa:20:0f.3,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0021:de:1f.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml b/tests/qe= muxml2argvdata/hostdev-vfio-multidomain.xml index 832458125b..7c34b65c7f 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml @@ -25,7 +25,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/hostdev-vfio.args b/tests/qemuxml2argvd= ata/hostdev-vfio.args index 79654f44bb..f2025afcd4 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio.args +++ b/tests/qemuxml2argvdata/hostdev-vfio.args @@ -27,5 +27,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --device vfio-pci,host=3D0000:06:12.5,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0000:06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/hostdev-vfio.xml b/tests/qemuxml2argvda= ta/hostdev-vfio.xml index 4d96b9f732..b2e6c62e7e 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio.xml @@ -27,7 +27,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/net-hostdev-fail.xml b/tests/qemuxml2ar= gvdata/net-hostdev-fail.xml index c815d68bd9..50b102c658 100644 --- a/tests/qemuxml2argvdata/net-hostdev-fail.xml +++ b/tests/qemuxml2argvdata/net-hostdev-fail.xml @@ -25,7 +25,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.args b/tests/qemuxml2a= rgvdata/net-hostdev-vfio.args index aa9e91db82..b0178a81bb 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio.args +++ b/tests/qemuxml2argvdata/net-hostdev-vfio.args @@ -27,5 +27,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --device vfio-pci,host=3D0000:03:07.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0000:06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.xml b/tests/qemuxml2ar= gvdata/net-hostdev-vfio.xml index 24034cad8b..aff681c0fb 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/net-hostdev-vfio.xml @@ -26,7 +26,7 @@ -
+
diff --git a/tests/qemuxml2xmloutdata/hostdev-vfio.xml b/tests/qemuxml2xmlo= utdata/hostdev-vfio.xml index 77bd62a129..15a845f4d1 100644 --- a/tests/qemuxml2xmloutdata/hostdev-vfio.xml +++ b/tests/qemuxml2xmloutdata/hostdev-vfio.xml @@ -32,7 +32,7 @@ -
+
diff --git a/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml b/tests/qemuxml2= xmloutdata/net-hostdev-vfio.xml index 0523cd8d3b..3f057a8249 100644 --- a/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml +++ b/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml @@ -31,7 +31,7 @@ -
+
diff --git a/tests/virpcimock.c b/tests/virpcimock.c index e9440e7910..b1651617a6 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -125,6 +125,7 @@ struct pciDevice { int device; int klass; int iommuGroup; + const char *physfn; struct pciDriver *driver; /* Driver attached. NULL if attached to no= driver */ }; =20 @@ -545,6 +546,15 @@ pci_device_new_from_stub(const struct pciDevice *data) =20 make_symlink(devsympath, devid, tmp); =20 + if (dev->physfn) { + if (snprintf(tmp, sizeof(tmp), + "%s%s/devices/%s", fakerootdir, + SYSFS_PCI_PREFIX, dev->physfn) < 0) { + ABORT("@tmp overflow"); + } + make_symlink(devpath, "physfn", tmp); + } + if (pci_device_autobind(dev) < 0) ABORT("Unable to bind: %s", devid); =20 @@ -1022,6 +1032,15 @@ init_env(void) MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, 8); MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, 8); MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, 8); + MAKE_PCI_DEVICE("0000:06:12.0", 0x8086, 0x0047, 9); + MAKE_PCI_DEVICE("0000:06:12.1", 0x8086, 0x0047, 10, + .physfn =3D "0000:06:12.0"); /* Virtual Function */ + MAKE_PCI_DEVICE("0000:06:12.2", 0x8086, 0x0047, 11, + .physfn =3D "0000:06:12.0"); /* Virtual Function */ + MAKE_PCI_DEVICE("0021:de:1f.0", 0x8086, 0x0047, 12); + MAKE_PCI_DEVICE("0021:de:1f.1", 0x8086, 0x0047, 13, + .physfn =3D "0021:de:1f.0"); /* Virtual Function */ + } =20 =20 diff --git a/tests/virpcitestdata/0000-06-12.0.config b/tests/virpcitestdat= a/0000-06-12.0.config new file mode 100644 index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03= d9a349c6ea12e GIT binary patch literal 256 ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S literal 0 HcmV?d00001 diff --git a/tests/virpcitestdata/0000-06-12.1.config b/tests/virpcitestdat= a/0000-06-12.1.config new file mode 100644 index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03= d9a349c6ea12e GIT binary patch literal 256 ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S literal 0 HcmV?d00001 diff --git a/tests/virpcitestdata/0000-06-12.2.config b/tests/virpcitestdat= a/0000-06-12.2.config new file mode 100644 index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03= d9a349c6ea12e GIT binary patch literal 256 ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S literal 0 HcmV?d00001 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 19:43:38 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=1567106380; cv=none; d=zoho.com; s=zohoarc; b=jN9//UH1v5gjJ/U463OnozgVM1vhGUvGfFdpVv1v8zwYa0pocvYKKhmy/IyJR7PA4vpqJYcA+WnDv2Wc4osBLyhE4mbQk/I5uZgYlqHkYWWxKTpivl2T6WmzMiuM9jrKQDZDsrlpLEeTSEHP2cBBiTzjSMeeOHRwkHESyIVOJZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567106380; 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=5Bxcj6rDGQg9kMZrLtURnu6AxP3QHoX7AjEhg4smefY=; b=Ysv4817r3stcH9uYIwaqWLs5u+iM3XbYwLg2LHxXtk/OBogPjvpQCeygGvQlgBEY+vxN5gqJDlFIj+QZbidkQPyVkGapvg6HZLwYRiP1r++saC9AeXCR8oSIWl9lPNFraFZK43//5ZdwAN9DOwQsRuHmrmaS6XFAY+rJgxK1vro= 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 1567106380106514.1663723370497; Thu, 29 Aug 2019 12:19:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4AE018C426B; Thu, 29 Aug 2019 19:19:38 +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 A62BE5D9E5; Thu, 29 Aug 2019 19:19:38 +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 6B075180221E; Thu, 29 Aug 2019 19:19:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7TJJPRn023585 for ; Thu, 29 Aug 2019 15:19:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EE1860605; Thu, 29 Aug 2019 19:19:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx23.extmail.prod.ext.phx2.redhat.com [10.5.110.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3811C60610; Thu, 29 Aug 2019 19:19:20 +0000 (UTC) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 DDF6B10576DD; Thu, 29 Aug 2019 19:19:18 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id i4so4955394qtj.8; Thu, 29 Aug 2019 12:19:18 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:9589:1351:c7eb:87b:c9d5]) by smtp.gmail.com with ESMTPSA id m19sm1827976qke.22.2019.08.29.12.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 12:19:17 -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=AyWyTM8k7ZCqrxk52G8pQCc9OZo3gvRHaoWAfbzNhTA=; b=PNkoWzqZTZASQSnT/o+dfr+1y/nwzZJERt8gv8q3+OD8UqftlypJqK8a9Lg7W6rP6T Fp1CT0Fa7RBZtr3+Uilj6MRiUbA3l4xUbGwiANDKCHGZYaaJpGSPBGnvemybtushAsAo t1Y0v7xMCGLsqyk+TCTaTtHuB49S1WhiplbSbhkD3wlRdUysPAfy2sQAIZiQxZ4R3WbY Rn01ewJILygfp9Jk7+pU+O0ay49yBae5QGg2t5mDI3fXizy8a/uT+a1c1MnQVw7KO/iD qet/qguN/5zSCzTCYzP08FlQVQywp7hChUO8A/tpsNikTv6DQk9Jomenar4XdvYmv4b0 8mzQ== 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=AyWyTM8k7ZCqrxk52G8pQCc9OZo3gvRHaoWAfbzNhTA=; b=gY6OvI4muAerOxFxfFx/zb98zH1LeDB9MWUJBJRWgo2m1H1T+X414LBYfAd8DIzwn/ suOn+KGEJ2uY0Rso1sB5tmNUESk+0Ud8nCdVkmVTGXolGqdfSlRUzjbZDibwF4LOZ+Gz PBXMlhVBvdW5kbiszs7XVaWIl53srlPHUz9sETg5yOci6ojDxBE/DsB5k7XEvdYqA/G1 s1ga4dG7zJLY+sAw7cSexwv95Hvtqf+uSrN3oR45xz/nzpuwXBQOhoUoe3q/r8IldiCS OBNgSIw3PIR0rdJ071uIiebPEFpWVr1tGn3+Tye9vabYl54rwtYpFlmur52g9Alx35K/ c0LA== X-Gm-Message-State: APjAAAUqO+bdy3FsNhCAzMUxi+MGGNc/5cQI4HCrJ330Ya1etJUoILrC PWV9RoBBUCu2sDT9K0WmyDSobt7YSQc= X-Google-Smtp-Source: APXvYqxTRporsOK2RwqXoGP1K3gPB8h19yBzbUt1USd1oRdrNI82i5NcWyQalueEcLl4C3OQtD17eA== X-Received: by 2002:ad4:496b:: with SMTP id p11mr3975682qvy.29.1567106357790; Thu, 29 Aug 2019 12:19:17 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 16:19:00 -0300 Message-Id: <20190829191902.10084-4-danielhb413@gmail.com> In-Reply-To: <20190829191902.10084-1-danielhb413@gmail.com> References: <20190829191902.10084-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Thu, 29 Aug 2019 19:19:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Thu, 29 Aug 2019 19:19:19 +0000 (UTC) for IP:'209.85.160.171' DOMAIN:'mail-qt1-f171.google.com' HELO:'mail-qt1-f171.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.171 mail-qt1-f171.google.com 209.85.160.171 mail-qt1-f171.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.64 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza Subject: [libvirt] [PATCH v3 3/5] tests: Add test case for QEMU pci-hostdev hotplug 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Thu, 29 Aug 2019 19:19:39 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat This patch adds hostdev test cases in qemuhotplugtest.c. Note: the small tweak inside virpcimock.c was needed because the new tests added a code path in which virHostHasIOMMU() (virutil.c) started being called, and the mocked '/sys/kernel/' prefix that is mocked in virpcimock.c wasn't being considered in the opendir() mock. An alternative to avoid these situations in virpcimock.c is implemented in the next patch. Reviewed-by: Michal Privoznik Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/util/virprocess.h | 2 +- tests/Makefile.am | 7 +++ tests/qemuhotplugtest.c | 40 ++++++++++++- .../qemuhotplug-hostdev-pci.xml | 6 ++ .../qemuhotplug-base-live+hostdev-pci.xml | 58 +++++++++++++++++++ ...uhotplug-pseries-base-live+hostdev-pci.xml | 51 ++++++++++++++++ .../qemuhotplug-pseries-base-live.xml | 43 ++++++++++++++ tests/virpcimock.c | 3 +- tests/virprocessmock.c | 28 +++++++++ 9 files changed, 235 insertions(+), 3 deletions(-) create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+host= dev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-l= ive+hostdev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-l= ive.xml create mode 100644 tests/virprocessmock.c diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 003ba1edf4..4806c592da 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -75,7 +75,7 @@ int virProcessGetNamespaces(pid_t pid, int virProcessSetNamespaces(size_t nfdlist, int *fdlist); =20 -int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes); +int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes) ATTRIBUTE= _NOINLINE; int virProcessSetMaxProcesses(pid_t pid, unsigned int procs); int virProcessSetMaxFiles(pid_t pid, unsigned int files); int virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes); diff --git a/tests/Makefile.am b/tests/Makefile.am index f92710db43..8c343857a5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -216,6 +216,7 @@ test_libraries =3D libshunload.la \ libvirpcimock.la \ libvirnetdevmock.la \ libvirrandommock.la \ + libvirprocessmock.la \ libvirhostcpumock.la \ libdomaincapsmock.la \ libvirfilecachemock.la \ @@ -1196,6 +1197,12 @@ libvirrandommock_la_SOURCES =3D \ libvirrandommock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) libvirrandommock_la_LIBADD =3D $(MOCKLIBS_LIBS) =20 +libvirprocessmock_la_SOURCES =3D \ + virprocessmock.c +libvirprocessmock_la_CFLAGS =3D $(AM_CFLAGS) +libvirprocessmock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) +libvirprocessmock_la_LIBADD =3D $(MOCKLIBS_LIBS) + libvirhostcpumock_la_SOURCES =3D \ virhostcpumock.c libvirhostcpumock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index b6aad330a9..3c177c6622 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -28,6 +28,7 @@ #include "testutils.h" #include "testutilsqemu.h" #include "testutilsqemuschema.h" +#include "virhostdev.h" #include "virerror.h" #include "virstring.h" #include "virthread.h" @@ -79,6 +80,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_SCSI_DISK_WWN); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); =20 if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0) goto cleanup; @@ -130,6 +133,9 @@ testQemuHotplugAttach(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_WATCHDOG: ret =3D qemuDomainAttachWatchdog(&driver, vm, dev->data.watchdog); break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + ret =3D qemuDomainAttachHostDevice(&driver, vm, dev->data.hostdev); + break; default: VIR_TEST_VERBOSE("device type '%s' cannot be attached", virDomainDeviceTypeToString(dev->type)); @@ -151,6 +157,7 @@ testQemuHotplugDetach(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_HOSTDEV: ret =3D qemuDomainDetachDeviceLive(vm, dev, &driver, async); break; default: @@ -578,6 +585,7 @@ testQemuHotplugCpuIndividual(const void *opaque) return ret; } =20 +#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" =20 =20 static int @@ -587,6 +595,19 @@ mymain(void) int ret =3D 0; struct qemuHotplugTestData data =3D {0}; struct testQemuHotplugCpuParams cpudata; + char *fakerootdir; + + if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { + fprintf(stderr, "Out of memory\n"); + abort(); + } + + if (!mkdtemp(fakerootdir)) { + fprintf(stderr, "Cannot create fakerootdir"); + abort(); + } + + setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 #if !WITH_YAJL fputs("libvirt not compiled with JSON support, skipping this test\n", = stderr); @@ -621,6 +642,8 @@ mymain(void) if (!driver.lockManager) return EXIT_FAILURE; =20 + driver.hostdevMgr =3D virHostdevManagerGetDefault(); + /* wait only 100ms for DEVICE_DELETED event */ qemuDomainRemoveDeviceWaitTime =3D 100; =20 @@ -789,6 +812,15 @@ mymain(void) "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); =20 + DO_TEST_ATTACH("base-live", "hostdev-pci", false, true, + "device_add", QMP_OK); + DO_TEST_DETACH("base-live", "hostdev-pci", false, false, + "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK); + DO_TEST_ATTACH("pseries-base-live", "hostdev-pci", false, true, + "device_add", QMP_OK); + DO_TEST_DETACH("pseries-base-live", "hostdev-pci", false, false, + "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK); + DO_TEST_ATTACH("base-live", "watchdog", false, true, "watchdog-set-action", QMP_OK, "device_add", QMP_OK); @@ -846,9 +878,15 @@ mymain(void) DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-22", true, true,= true); DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "17", true, true, tr= ue); =20 + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) + virFileDeleteTree(fakerootdir); + VIR_FREE(fakerootdir); + qemuTestDriverFree(&driver); virObjectUnref(data.vm); return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, + VIR_TEST_MOCK("virpci"), + VIR_TEST_MOCK("virprocess")); diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml b/tes= ts/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml new file mode 100644 index 0000000000..6f7c99c943 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci= .xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci.xml new file mode 100644 index 0000000000..40dcc33595 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci.xml @@ -0,0 +1,58 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + +
+ + +
+ + + + + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+hos= tdev-pci.xml b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+h= ostdev-pci.xml new file mode 100644 index 0000000000..483cb5d8f0 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+hostdev-pc= i.xml @@ -0,0 +1,51 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + +
+ + +
+ + + + + + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml= b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml new file mode 100644 index 0000000000..1dcc35f626 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml @@ -0,0 +1,43 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + + diff --git a/tests/virpcimock.c b/tests/virpcimock.c index b1651617a6..e362121899 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -1150,7 +1150,8 @@ opendir(const char *path) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && + if ((STRPREFIX(path, SYSFS_PCI_PREFIX) || + STRPREFIX(path, "/sys/kernel/")) && getrealpath(&newpath, path) < 0) return NULL; =20 diff --git a/tests/virprocessmock.c b/tests/virprocessmock.c new file mode 100644 index 0000000000..79af1e8064 --- /dev/null +++ b/tests/virprocessmock.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2019 Red Hat, Inc. + * Copyright (C) 2019 IBM Corp. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#include +#include "virprocess.h" + +int +virProcessSetMaxMemLock(pid_t pid ATTRIBUTE_UNUSED, unsigned long long byt= es ATTRIBUTE_UNUSED) +{ + return 0; +} --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 19:43:38 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=1567106376; cv=none; d=zoho.com; s=zohoarc; b=Yh47elDhsLYgnhidMdL//+NyWoE9ti8SYpNCEmxNHuD4co/yLsBieChufo9AGFqZ24KG3s2oFn6HA3zl+RmwOUuPTOgGHh15dyammGdpgEmATz+GV3x8idn/krlTNY6U6ao4QCQNMeWT0T+6LB79zkev2Jgn6GvQ8JnbRB1ZzdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567106376; 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=/aDNEL6gd4ahyp22cIvqz5KkGUW3TN9YAKpSRbcVPe8=; b=CoFViEQ6uVbXVQYtN7wtR9kIvV16Fsnqd8AiLsVaUft+N1UxBmKV+5Mwdb7KEHJj8GCChcrBGQtEcefubR+c9lp7B13QsvGhPeKaQ4uXleBrLg/rS4kfs23CNRYWoXQrX3XW2GyXL3YMVt7ySvyiEUIhkY470H+6t4cKX6QVDEE= 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 1567106376526820.1977719268685; Thu, 29 Aug 2019 12:19:36 -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 33268693F3; Thu, 29 Aug 2019 19:19:35 +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 0C82160872; Thu, 29 Aug 2019 19:19:35 +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 C260724F30; Thu, 29 Aug 2019 19:19:34 +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 x7TJJL3u023570 for ; Thu, 29 Aug 2019 15:19:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE9864118; Thu, 29 Aug 2019 19:19:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8A693DA6; Thu, 29 Aug 2019 19:19:21 +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 85FB13086208; Thu, 29 Aug 2019 19:19:20 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id j15so4907342qtl.13; Thu, 29 Aug 2019 12:19:20 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:9589:1351:c7eb:87b:c9d5]) by smtp.gmail.com with ESMTPSA id m19sm1827976qke.22.2019.08.29.12.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 12:19:19 -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=pFTZXBxaVeuVsHeNgjb7jnziGq0sFmvrZzLNK1VR8HU=; b=ALEwL5fyxeQNsYNLhLJtXS/IKmv5JKhf1fvpdPV11ZSQ6AQo5cdZzVTr5LgH6Jgobr GX1QVfh80tNlKU8x3w72X8+hfUZb6QJgyuRF2lwSmy5/YH1SZQ6rVTePE1EDkGjAf/j/ yd2Eh1ml1KSOjnvtVewahIa9eNeguox7l90YzsVdX63edAGR/u3wcCpwm7CqFWUJ3I0i LfOzP8gmad3gSU7cPwpuu6ZpMcYav85UrsewioKtWV3bl1PMjBuf6bdQLV84d7S/w92D iuldYFqXp1ZKaYXqz8lfthJlWuqiG95FY0DNQI2KOuaesxCitliF+1LfPg272yb4iSFJ Oxgg== 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=pFTZXBxaVeuVsHeNgjb7jnziGq0sFmvrZzLNK1VR8HU=; b=kc4yl9UKqfs0pACifQBtOe6RuhiedW/Q2DByEM5AbAd8Ely0pvwVRI2W44i2gcM/B5 MllGd2oY1o1oi++KQQzyGWZdd/YhbB6OfSTsXSmlXRDkQEYakJYqdEytdAvpM5rDEZOY hT8ETNmqitFXo7ffVmEWoubMhG0xpcOgQTpwLjS5qiJmdZBIGVUzXMiWHY5dOjLFQ0ey kZrxN8yiPo+x3FsXEEGUVydqRY076XE9+9iVvs4NwHSthQV7Cp5Uy/RP9hnOmcwJnqEX v5bFLvNHQ4PG7mttT7OInN9jwNwJiYb4yoPhb61V0zFsOOX2IPbD0n+bMB6WlKwgQpFV zHqQ== X-Gm-Message-State: APjAAAXiHcl8JK04AQsav//8TDddzAw4xbD2eyCQbubX3YKY3h1Rb87S O7zPET1E6+1gIS74Rn34Y6uTCrOklJU= X-Google-Smtp-Source: APXvYqwsY8Tgik3/BHiZaiFgcKHY/GN0jMCjrBV9IsOhwalqRKnUYYQ1HLuzPUiJvoyttjOBDU9xSA== X-Received: by 2002:aed:27d4:: with SMTP id m20mr10898662qtg.334.1567106359569; Thu, 29 Aug 2019 12:19:19 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 16:19:01 -0300 Message-Id: <20190829191902.10084-5-danielhb413@gmail.com> In-Reply-To: <20190829191902.10084-1-danielhb413@gmail.com> References: <20190829191902.10084-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.42]); Thu, 29 Aug 2019 19:19:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 29 Aug 2019 19:19:20 +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.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza Subject: [libvirt] [PATCH v3 4/5] virpcimock.c: simplify getrealpath() usage 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.25]); Thu, 29 Aug 2019 19:19:35 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Previous patch had to add '/sys/kernel/' prefix in opendir() because the path, which is being mocked, wasn't being considered due to an 'if SYSFS_PCI_PREFIX' guarding the call to getrealpath(). In fact, all current getrealpath() callers are guarding it with a conditional to ensure that the function will never be called with a non-mocked path. In this case, an extra non-NULL verification is needed for the 'newpath' string to use the variable - which is counterintuitive, given that getrealpath() will always write the 'newpath' string in any non-error conditon. However, simply removing the guard of all getrealpath() instances causes an abort in init_env(). This happens because tests will execute access() to non-mocked paths even before the LIBVIRT_FAKE_ROOT_DIR variable is declared in the test files. We don't need 'fakerootdir' to be created at this point though. This patch does the following changes to simplify getrealpath() usage: - getrealpath() will now guard the init_env() call by checking if both fakeroot isn't created and the required path is being mocked. This ensures that we're not failing inside init_env() because we're too early and LIBVIRT_FAKE_ROOT_DIR wasn't defined yet; - remove all conditional guards to call getrealpath() from access(), virMockStatRedirect(), open(), open_2(), opendir() and virFileCanonicalizePath(). As a bonus, remove all ternary conditionals with 'newpath'; - a new 'pathPrefixIsMocked()' helper to aggregate all the prefixes we're mocking, making it easier to add/remove them. If a prefix is added inside this function, we can be sure that all functions are mocking them. Signed-off-by: Daniel Henrique Barboza --- tests/virpcimock.c | 63 +++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index e362121899..69ee360e4c 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -45,8 +45,16 @@ static char *(*real_virFileCanonicalizePath)(const char = *path); */ char *fakerootdir; =20 +/* To add a new mocked prefix in virpcimock: + * - add the prefix here as a define to make it easier to track what we + * are mocking; + * - add it to the 'pathPrefixIsMocked()' helper; + * - (optional) edit 'getrealpath()' if you need the resulting mocked + * path to be different than /path + */ # define SYSFS_PCI_PREFIX "/sys/bus/pci/" - +# define SYSFS_KERNEL_PREFIX "/sys/kernel/" +# define DEV_VFIO_PREFIX "/dev/vfio/" =20 # define STDERR(...) \ fprintf(stderr, "%s %zu: ", __FUNCTION__, (size_t) __LINE__); \ @@ -251,11 +259,20 @@ pci_read_file(const char *path, return ret; } =20 +static bool +pathPrefixIsMocked(const char *path) +{ + return STRPREFIX(path, SYSFS_PCI_PREFIX) || + STRPREFIX(path, SYSFS_KERNEL_PREFIX) || + STRPREFIX(path, DEV_VFIO_PREFIX); +} + static int getrealpath(char **newpath, const char *path) { - init_env(); + if (!fakerootdir && pathPrefixIsMocked(path)) + init_env(); =20 if (STRPREFIX(path, SYSFS_PCI_PREFIX)) { if (virAsprintfQuiet(newpath, "%s/sys/bus/pci/%s", @@ -264,9 +281,7 @@ getrealpath(char **newpath, errno =3D ENOMEM; return -1; } - } else if (STRPREFIX(path, "/sys/kernel/") || - STRPREFIX(path, "/dev/vfio/")) { - + } else if (pathPrefixIsMocked(path)) { if (virAsprintfQuiet(newpath, "%s/%s", fakerootdir, path) < 0) { @@ -974,9 +989,6 @@ init_env(void) { VIR_AUTOFREE(char *) tmp =3D NULL; =20 - if (fakerootdir) - return; - if (!(fakerootdir =3D getenv("LIBVIRT_FAKE_ROOT_DIR"))) ABORT("Missing LIBVIRT_FAKE_ROOT_DIR env variable\n"); =20 @@ -1057,21 +1069,19 @@ access(const char *path, int mode) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && - getrealpath(&newpath, path) < 0) + if (getrealpath(&newpath, path) < 0) return -1; =20 - return real_access(newpath ? newpath : path, mode); + return real_access(newpath, mode); } =20 =20 static int virMockStatRedirect(const char *path, char **newpath) { - if (STRPREFIX(path, SYSFS_PCI_PREFIX)) { - if (getrealpath(newpath, path) < 0) - return -1; - } + if (getrealpath(newpath, path) < 0) + return -1; + return 0; } =20 @@ -1084,8 +1094,7 @@ open(const char *path, int flags, ...) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && - getrealpath(&newpath, path) < 0) + if (getrealpath(&newpath, path) < 0) return -1; =20 if (flags & O_CREAT) { @@ -1094,9 +1103,9 @@ open(const char *path, int flags, ...) va_start(ap, flags); mode =3D (mode_t) va_arg(ap, int); va_end(ap); - ret =3D real_open(newpath ? newpath : path, flags, mode); + ret =3D real_open(newpath, flags, mode); } else { - ret =3D real_open(newpath ? newpath : path, flags); + ret =3D real_open(newpath, flags); } =20 /* Catch both: /sys/bus/pci/drivers/... and @@ -1125,11 +1134,10 @@ __open_2(const char *path, int flags) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && - getrealpath(&newpath, path) < 0) + if (getrealpath(&newpath, path) < 0) return -1; =20 - ret =3D real___open_2(newpath ? newpath : path, flags); + ret =3D real___open_2(newpath, flags); =20 /* Catch both: /sys/bus/pci/drivers/... and * /sys/bus/pci/device/.../driver/... */ @@ -1150,12 +1158,10 @@ opendir(const char *path) =20 init_syms(); =20 - if ((STRPREFIX(path, SYSFS_PCI_PREFIX) || - STRPREFIX(path, "/sys/kernel/")) && - getrealpath(&newpath, path) < 0) + if (getrealpath(&newpath, path) < 0) return NULL; =20 - return real_opendir(newpath ? newpath : path); + return real_opendir(newpath); } =20 int @@ -1173,11 +1179,10 @@ virFileCanonicalizePath(const char *path) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && - getrealpath(&newpath, path) < 0) + if (getrealpath(&newpath, path) < 0) return NULL; =20 - return real_virFileCanonicalizePath(newpath ? newpath : path); + return real_virFileCanonicalizePath(newpath); } =20 # include "virmockstathelpers.c" --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 19:43:38 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=1567106383; cv=none; d=zoho.com; s=zohoarc; b=Z0lt0497kzitb4C31w/xonhSfsQFDO5aWWpFdzxHiBwxFta42VCSe01iG30F2+Ya6PGEPxlzE6lCSA33rIvCQ9pbk6yZZwXs7+wwct53HhArLG/icsHvXCyFL6pG8BMZn6w0tgw55pyR4OdoFUfv6+Gw7xppaeaXQIIJ3yZq5og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567106383; 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=rCDiIZvWBze1gQ1QjhYr5lUDK7vIWJ64j05VoCsOLBY=; b=S9YL+vNXKe44rveVSYuuS/y9sGbrgyQgfgfPCGAx5UtARftdT+ma94+OZVQUrEbbYQM8yx8Sl0iCu6zVeKuBz6VK1Hm/BNlD9NLNuUrfzVNxkp8PGkYg/ie5nAADQwqT6Z9+sfkq1IWedSg0KOHdUId5tNAedyue/9uowRZ/KVo= 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 1567106383316433.3300529140114; Thu, 29 Aug 2019 12:19:43 -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 1A6053175285; Thu, 29 Aug 2019 19:19:42 +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 E2BFA5C29A; Thu, 29 Aug 2019 19:19:41 +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 A8D75180B536; Thu, 29 Aug 2019 19:19:41 +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 x7TJJQcS023593 for ; Thu, 29 Aug 2019 15:19:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25EFA6012D; Thu, 29 Aug 2019 19:19:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx25.extmail.prod.ext.phx2.redhat.com [10.5.110.66]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1ADD561350; Thu, 29 Aug 2019 19:19:23 +0000 (UTC) Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) (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 3A5AD10F23EE; Thu, 29 Aug 2019 19:19:22 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id m10so4036238qkk.1; Thu, 29 Aug 2019 12:19:22 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:9589:1351:c7eb:87b:c9d5]) by smtp.gmail.com with ESMTPSA id m19sm1827976qke.22.2019.08.29.12.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 12:19:20 -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=+wNh4yxBVsrRrCq6uSfuPESUjMeTYSfo1WEVoiT1Oq8=; b=mtUFfPg/XN8abClnFgLDrg/rvMUFagw9cXiHv3EQW3SqeMVj4GUUS8V9+g9HYPibfU uxyvaoMv++dUBNjlMbHSQQ201MylK22KKSpSjJ5BL3VNFdjISx0qG74qREkb7w1j7QIq gdmc20ROAO/7OsyXMVKy17t+t1Uz2mfTJyP/nU2doKuy5vXaAESJTJZSKaOqxWKMypGg 86rFZ9SY2ueGo2f2PuPxzXAtFPe2/MX6F+6GW10Hs3FWIjPxI1seoOqfaWagvDCkedSI UQsisz/IVkXJyFUX4KJvi6N2yPIdkI46pLLElJ1gv4N9iHhuaQe34IR0sNRmnqoCZ2/w xnOg== 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=+wNh4yxBVsrRrCq6uSfuPESUjMeTYSfo1WEVoiT1Oq8=; b=IVRVgi2WpdZHgZxnMlno3WM/KXxQ2ezmuG3ej9zRH2TImmaR9ZOXxV976vx6iN/Dwb rNDFuszfcED0HpL+B/6bVPwCM3/ZEzTqvovFOYjKl3gQ8y7yJrgV1NifYiwYAhI6+0Z6 qtx16ydfDX3SCeO+xHDd97zFQmj9/W1hq1XZyFK2v3wSlMCYHb/DSApi/h9DuFlf6i7+ uIBpIEgNcQWmAQ0k//6VLrppHrgtpqjc9dTnUC8LRzfjOl19LLTYWpHUyi0mR+Uf5Au6 1SGYycqc6C0bMkNKkB7coXkQO+3nF2qOWDs+t84UvkcudBzMbhblH5nUeqKknQwU7LTi BGQQ== X-Gm-Message-State: APjAAAVJvqbzmKf+JnU/n9TC5Bq51tyTVqSdfF/lncyIGMvTaOsNZdtq Ws/muxrovpN4JlaAUfettmoAU4zxH58= X-Google-Smtp-Source: APXvYqwJtJVSKF9LAdz3TNZjQEJkGK0saVy1Gl24f3wFVH17MV7Pmd2+iDpfz/M7BSgeVjWKsDcKpQ== X-Received: by 2002:ae9:e411:: with SMTP id q17mr11056819qkc.465.1567106361271; Thu, 29 Aug 2019 12:19:21 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 16:19:02 -0300 Message-Id: <20190829191902.10084-6-danielhb413@gmail.com> In-Reply-To: <20190829191902.10084-1-danielhb413@gmail.com> References: <20190829191902.10084-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Thu, 29 Aug 2019 19:19:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Thu, 29 Aug 2019 19:19:22 +0000 (UTC) for IP:'209.85.222.194' DOMAIN:'mail-qk1-f194.google.com' HELO:'mail-qk1-f194.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.194 mail-qk1-f194.google.com 209.85.222.194 mail-qk1-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.66 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza Subject: [libvirt] [PATCH v3 5/5] tests: Add a baseline test for multifunction pci device use case 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 29 Aug 2019 19:19:42 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat There are already good number of test cases with hostdevices, few have multifunction devices but none having more than one than one multifunction cards. This patch adds a case where there are two multifunction cards and two Virtual functions part of the same XML. 0001:01:00.X & 0005:09:00.X - are Multifunction PCI cards. 0000:06:12.[5|6] - are SRIOV Virtual functions Future commits will improve on automatically detecting the multifunction cards and auto-assinging the addresses appropriately. Reviewed-by: Michal Privoznik Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- .../hostdev-pci-multifunction.args | 35 ++++++++ .../hostdev-pci-multifunction.xml | 59 ++++++++++++++ tests/qemuxml2argvtest.c | 3 + .../hostdev-pci-multifunction.xml | 79 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 177 insertions(+) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.args b/tests/= qemuxml2argvdata/hostdev-pci-multifunction.args new file mode 100644 index 0000000000..d8690c010b --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.args @@ -0,0 +1,35 @@ +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=3D0001:01:00.1,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4 \ +-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 diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml b/tests/q= emuxml2argvdata/hostdev-pci-multifunction.xml new file mode 100644 index 0000000000..06c889c64d --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml @@ -0,0 +1,59 @@ + + 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 9395cc19a2..d11a31b836 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1317,6 +1317,9 @@ mymain(void) DO_TEST_FAILURE("net-hostdev-fail", QEMU_CAPS_DEVICE_VFIO_PCI); =20 + DO_TEST("hostdev-pci-multifunction", + QEMU_CAPS_KVM, + QEMU_CAPS_DEVICE_VFIO_PCI); =20 DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV_FILE_APPEND, diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml b/tests= /qemuxml2xmloutdata/hostdev-pci-multifunction.xml new file mode 100644 index 0000000000..52ed86e305 --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml @@ -0,0 +1,79 @@ + + 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 5f6a3618cd..c4bc05e679 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -439,6 +439,7 @@ mymain(void) =20 DO_TEST("hostdev-usb-address", NONE); DO_TEST("hostdev-pci-address", NONE); + DO_TEST("hostdev-pci-multifunction", 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