From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099102105153.46645395037524; Thu, 15 Mar 2018 00:31:42 -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 C01E041A20; Thu, 15 Mar 2018 07:31:40 +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 4AA255D9C7; Thu, 15 Mar 2018 07:31:40 +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 E198B4CAA2; Thu, 15 Mar 2018 07:31:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHFQvM023996 for ; Wed, 14 Mar 2018 13:15:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C3ED5F735; Wed, 14 Mar 2018 17:15:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41E6D61781 for ; Wed, 14 Mar 2018 17:15:18 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0027723E6F4 for ; Wed, 14 Mar 2018 17:15:18 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHEA6B058031 for ; Wed, 14 Mar 2018 13:15:17 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq5bd01ys-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:15:17 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:15:15 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:15:13 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHFD6s64291036 for ; Wed, 14 Mar 2018 17:15:13 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B16B511C04A for ; Wed, 14 Mar 2018 17:07:51 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11C5C11C054 for ; Wed, 14 Mar 2018 17:07:51 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:07:50 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:45:11 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0020-0000-0000-000004047ABE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0021-0000-0000-000042987FC4 Message-Id: <152104767838.10112.3451155929280359052.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 14 Mar 2018 17:15:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 14 Mar 2018 17:15:18 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 01/28] tests: Fix the iommu group path in mock pci 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.30]); Thu, 15 Mar 2018 07:31:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The mocked path falls into /sys/bus/kernel/iommu_groups instead of /sys/kernel/iommu_groups. Needed for adding some new test cases. Signed-off-by: Shivaprasad G Bhat --- tests/virpcimock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 176c64d654..2a7e9216b2 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -404,7 +404,7 @@ pci_device_new_from_stub(const struct pciDevice *data) make_file(devpath, "class", tmp, -1); =20 if (snprintf(tmp, sizeof(tmp), - "%s/../../../kernel/iommu_groups/%d", + "%s/../../../../kernel/iommu_groups/%d", devpath, dev->iommuGroup) < 0) { ABORT("@tmp overflow"); } @@ -412,7 +412,7 @@ pci_device_new_from_stub(const struct pciDevice *data) ABORT("Unable to create %s", tmp); =20 if (snprintf(tmp, sizeof(tmp), - "../../../kernel/iommu_groups/%d", dev->iommuGroup) < 0) { + "../../../../kernel/iommu_groups/%d", dev->iommuGroup) < = 0) { ABORT("@tmp overflow"); } make_symlink(devpath, "iommu_group", tmp); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099425568868.8941083996256; Thu, 15 Mar 2018 00:37:05 -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 3A87F7FDD2; Thu, 15 Mar 2018 07:37:04 +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 0ADF45D72B; Thu, 15 Mar 2018 07:37:04 +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 C575D4CAB4; Thu, 15 Mar 2018 07:37:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHGJZV024059 for ; Wed, 14 Mar 2018 13:16:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE98D5C1AB; Wed, 14 Mar 2018 17:16:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6E4F5C25E for ; Wed, 14 Mar 2018 17:16:17 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 223D27E9D4 for ; Wed, 14 Mar 2018 17:16:16 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHFwXg142876 for ; Wed, 14 Mar 2018 13:16:15 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq44ukw9r-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:16:15 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:16:13 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:16:11 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHGBql655676 for ; Wed, 14 Mar 2018 17:16:11 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB4DBAE045 for ; Wed, 14 Mar 2018 17:06:37 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34073AE059 for ; Wed, 14 Mar 2018 17:06:37 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:06:36 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:46:09 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD78D8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707E92 Message-Id: <152104771883.10112.2463440741770922800.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 14 Mar 2018 17:16:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 14 Mar 2018 17:16:16 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 02/28] util: move hostdev passthrough support functions to utility 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.27]); Thu, 15 Mar 2018 07:37:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is some duplicity of code here. Move them to common place. Signed-off-by: Shivaprasad G Bhat --- src/libvirt_private.syms | 2 + src/qemu/qemu_capabilities.c | 5 +-- src/qemu/qemu_driver.c | 5 +-- src/qemu/qemu_hostdev.c | 70 ++------------------------------------= ---- src/qemu/qemu_hostdev.h | 3 -- src/util/virhostdev.c | 63 ++++++++++++++++++++++++++++++++++++++ src/util/virhostdev.h | 3 ++ tests/virhostdevtest.c | 31 ------------------- 8 files changed, 75 insertions(+), 107 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c67bce7389..e1bdaa127e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1915,6 +1915,8 @@ virHostCPUStatsAssign; =20 # util/virhostdev.h virHostdevFindUSBDevice; +virHostdevHostSupportsPassthroughKVM; +virHostdevHostSupportsPassthroughVFIO; virHostdevIsSCSIDevice; virHostdevManagerGetDefault; virHostdevPCINodeDeviceDetach; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3eb5ed6d1a..943e92a3d3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -42,7 +42,6 @@ #include "virhostcpu.h" #include "qemu_monitor.h" #include "virstring.h" -#include "qemu_hostdev.h" #include "qemu_domain.h" #define __QEMU_CAPSPRIV_H_ALLOW__ #include "qemu_capspriv.h" @@ -5725,8 +5724,8 @@ static int virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceHostdevPtr hostd= ev) { - bool supportsPassthroughKVM =3D qemuHostdevHostSupportsPassthroughLega= cy(); - bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); + bool supportsPassthroughKVM =3D virHostdevHostSupportsPassthroughKVM(); + bool supportsPassthroughVFIO =3D virHostdevHostSupportsPassthroughVFIO= (); =20 hostdev->supported =3D true; /* VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES is for containers only */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8c872c1f08..0ade86d6a9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -52,7 +52,6 @@ #include "qemu_command.h" #include "qemu_parse_command.h" #include "qemu_cgroup.h" -#include "qemu_hostdev.h" #include "qemu_hotplug.h" #include "qemu_monitor.h" #include "qemu_process.h" @@ -12963,8 +12962,8 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, int ret =3D -1; virNodeDeviceDefPtr def =3D NULL; char *xml =3D NULL; - bool legacy =3D qemuHostdevHostSupportsPassthroughLegacy(); - bool vfio =3D qemuHostdevHostSupportsPassthroughVFIO(); + bool legacy =3D virHostdevHostSupportsPassthroughKVM(); + bool vfio =3D virHostdevHostSupportsPassthroughVFIO(); virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; =20 virCheckFlags(0, -1); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 73d26f4c63..c110cf7816 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -121,78 +121,14 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr= driver, return 0; } =20 -bool -qemuHostdevHostSupportsPassthroughVFIO(void) -{ - DIR *iommuDir =3D NULL; - struct dirent *iommuGroup =3D NULL; - bool ret =3D false; - int direrr; - - /* condition 1 - /sys/kernel/iommu_groups/ contains entries */ - if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0) - goto cleanup; - - while ((direrr =3D virDirRead(iommuDir, &iommuGroup, NULL)) > 0) { - /* assume we found a group */ - break; - } - - if (direrr < 0 || !iommuGroup) - goto cleanup; - /* okay, iommu is on and recognizes groups */ - - /* condition 2 - /dev/vfio/vfio exists */ - if (!virFileExists("/dev/vfio/vfio")) - goto cleanup; - - ret =3D true; - - cleanup: - VIR_DIR_CLOSE(iommuDir); - return ret; -} - - -#if HAVE_LINUX_KVM_H -# include -bool -qemuHostdevHostSupportsPassthroughLegacy(void) -{ - int kvmfd =3D -1; - bool ret =3D false; - - if ((kvmfd =3D open("/dev/kvm", O_RDONLY)) < 0) - goto cleanup; - -# ifdef KVM_CAP_IOMMU - if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <=3D 0) - goto cleanup; - - ret =3D true; -# endif - - cleanup: - VIR_FORCE_CLOSE(kvmfd); - - return ret; -} -#else -bool -qemuHostdevHostSupportsPassthroughLegacy(void) -{ - return false; -} -#endif - =20 static bool qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, size_t nhostdevs, virQEMUCapsPtr qemuCaps) { - bool supportsPassthroughKVM =3D qemuHostdevHostSupportsPassthroughLega= cy(); - bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); + bool supportsPassthroughKVM =3D virHostdevHostSupportsPassthroughKVM(); + bool supportsPassthroughVFIO =3D virHostdevHostSupportsPassthroughVFIO= (); size_t i; =20 /* assign defaults for hostdev passthrough */ @@ -330,7 +266,7 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr driv= er, int nhostdevs) { virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; - bool supportsVFIO =3D qemuHostdevHostSupportsPassthroughVFIO(); + bool supportsVFIO =3D virHostdevHostSupportsPassthroughVFIO(); size_t i; =20 for (i =3D 0; i < nhostdevs; i++) { diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index 9a7c7f143c..bdc51f9d9e 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -27,9 +27,6 @@ # include "qemu_conf.h" # include "domain_conf.h" =20 -bool qemuHostdevHostSupportsPassthroughLegacy(void); -bool qemuHostdevHostSupportsPassthroughVFIO(void); - int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver, virDomainDefPtr def); int qemuHostdevUpdateActivePCIDevices(virQEMUDriverPtr driver, diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index a12224c58f..e0133cdeec 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -2299,3 +2299,66 @@ virHostdevUpdateActiveDomainDevices(virHostdevManage= rPtr mgr, =20 return 0; } + +bool +virHostdevHostSupportsPassthroughVFIO(void) +{ + DIR *iommuDir =3D NULL; + struct dirent *iommuGroup =3D NULL; + bool ret =3D false; + int direrr; + + /* condition 1 - /sys/kernel/iommu_groups/ contains entries */ + if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0) + goto cleanup; + + while ((direrr =3D virDirRead(iommuDir, &iommuGroup, NULL)) > 0) { + /* assume we found a group */ + break; + } + + if (direrr < 0 || !iommuGroup) + goto cleanup; + /* okay, iommu is on and recognizes groups */ + + /* condition 2 - /dev/vfio/vfio exists */ + if (!virFileExists("/dev/vfio/vfio")) + goto cleanup; + + ret =3D true; + + cleanup: + VIR_DIR_CLOSE(iommuDir); + return ret; +} + +#if HAVE_LINUX_KVM_H +# include +bool +virHostdevHostSupportsPassthroughKVM(void) +{ + int kvmfd =3D -1; + bool ret =3D false; + + if ((kvmfd =3D open("/dev/kvm", O_RDONLY)) < 0) + goto cleanup; + +# ifdef KVM_CAP_IOMMU + if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <=3D 0) + goto cleanup; + + ret =3D true; +# endif + + cleanup: + VIR_FORCE_CLOSE(kvmfd); + + return ret; +} +#else +bool +virHostdevHostSupportsPassthroughKVM(void) +{ + return false; +} +#endif diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index 54e1c66be3..d5efffbac2 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -203,4 +203,7 @@ int virHostdevPCINodeDeviceReset(virHostdevManagerPtr m= gr, virPCIDevicePtr pci) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +bool virHostdevHostSupportsPassthroughKVM(void); +bool virHostdevHostSupportsPassthroughVFIO(void); + #endif /* __VIR_HOSTDEV_H__ */ diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 5b03cb6aee..e4fee567a2 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -130,37 +130,6 @@ myInit(void) return -1; } =20 -# if HAVE_LINUX_KVM_H -# include -static bool -virHostdevHostSupportsPassthroughKVM(void) -{ - int kvmfd =3D -1; - bool ret =3D false; - - if ((kvmfd =3D open("/dev/kvm", O_RDONLY)) < 0) - goto cleanup; - -# ifdef KVM_CAP_IOMMU - if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <=3D 0) - goto cleanup; - - ret =3D true; -# endif - - cleanup: - VIR_FORCE_CLOSE(kvmfd); - - return ret; -} -# else -static bool -virHostdevHostSupportsPassthroughKVM(void) -{ - return false; -} -# endif - static int testVirHostdevPreparePCIHostdevs_unmanaged(void) { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099435858927.0152499873662; Thu, 15 Mar 2018 00:37:15 -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 676253DBED; Thu, 15 Mar 2018 07:37:14 +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 32E1E17243; Thu, 15 Mar 2018 07:37:14 +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 F06044CAB8; Thu, 15 Mar 2018 07:37:13 +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 w2EHGadb024085 for ; Wed, 14 Mar 2018 13:16:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB71A60A98; Wed, 14 Mar 2018 17:16:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD8C06090B for ; Wed, 14 Mar 2018 17:16:33 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21BF9C0528C2 for ; Wed, 14 Mar 2018 17:16:32 +0000 (UTC) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHFwfe060368 for ; Wed, 14 Mar 2018 13:16:31 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq6y3ax97-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:16:30 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:16:28 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:16:26 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHGP0M59506866 for ; Wed, 14 Mar 2018 17:16:25 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A47CAAE053 for ; Wed, 14 Mar 2018 17:06:52 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E995CAE057 for ; Wed, 14 Mar 2018 17:06:51 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:06:51 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:46:23 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-00000420797D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000026237EE4 Message-Id: <152104777699.10112.15553401507045394764.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Mar 2018 17:16:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Mar 2018 17:16:32 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 03/28] tests: pci: Mock the iommu groups and 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.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.30]); Thu, 15 Mar 2018 07:37:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The iommu group, /dev/vfio/ behaviours of the host are mocked. This patch implments support for multifunction/multiple devices per iommu groups and emulates the /dev/vfio/ file correctly. This code helps adding necessary testcases for pci-hotplug code. Signed-off-by: Shivaprasad G Bhat --- tests/virpcimock.c | 178 ++++++++++++++++++++++++++= +--- tests/virpcitestdata/0005-90-01.1.config | Bin tests/virpcitestdata/0005-90-01.2.config | Bin tests/virpcitestdata/0005-90-01.3.config | Bin 4 files changed, 162 insertions(+), 16 deletions(-) create mode 100644 tests/virpcitestdata/0005-90-01.3.config diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 2a7e9216b2..22adc740b8 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -51,7 +51,13 @@ static DIR * (*real_opendir)(const char *name); char *fakerootdir; char *fakesysfspcidir; =20 +struct pciIommuGroup { + int iommu; + size_t nDevicesBoundToVFIO; /* Indicates the devices in the gro= up */ +}; + # define SYSFS_PCI_PREFIX "/sys/bus/pci/" +# define SYSFS_KERNEL_PREFIX "/sys/kernel/" =20 # define STDERR(...) \ fprintf(stderr, "%s %zu: ", __FUNCTION__, (size_t) __LINE__); \ @@ -142,6 +148,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 @@ -191,7 +200,7 @@ make_file(const char *path, VIR_FREE(filepath); } =20 -static void +static void ATTRIBUTE_UNUSED make_symlink(const char *path, const char *name, const char *target) @@ -255,6 +264,13 @@ getrealpath(char **newpath, errno =3D ENOMEM; return -1; } + } else if (STRPREFIX(path, SYSFS_KERNEL_PREFIX)) { + if (virAsprintfQuiet(newpath, "%s/%s", + fakerootdir, + path) < 0) { + errno =3D ENOMEM; + return -1; + } } else { if (VIR_STRDUP_QUIET(*newpath, path) < 0) return -1; @@ -465,6 +481,101 @@ pci_device_autobind(struct pciDevice *dev) return pci_driver_bind(driver, dev); } =20 +static void +pci_iommu_new(int num) +{ + char *iommupath, *kerneldir; + struct pciIommuGroup *iommuGroup; + + if (VIR_ALLOC_QUIET(iommuGroup) < 0) + ABORT_OOM(); + + iommuGroup->iommu =3D num; + iommuGroup->nDevicesBoundToVFIO =3D 0; /* No device bound to vfio by d= efault */ + + if (virAsprintfQuiet(&kerneldir, "%s%s", + fakerootdir, SYSFS_KERNEL_PREFIX) < 0) + ABORT_OOM(); + + if (virAsprintfQuiet(&iommupath, "%s/iommu_groups/%d/devices", kerneld= ir, num) < 0) + ABORT_OOM(); + VIR_FREE(kerneldir); + + if (virFileMakePath(iommupath) < 0) + ABORT("Unable to create: %s", iommupath); + VIR_FREE(iommupath); + + if (VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, iommuGro= up) < 0) + ABORT_OOM(); +} + +static int +pci_vfio_release_iommu(struct pciDevice *device) +{ + 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) + break; + } + + if (i !=3D npciIommuGroups) { + 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", + fakesysfspcidir, device->iommuGroup) < 0) { + errno =3D ENOMEM; + goto cleanup; + } + if (unlink(vfiopath) < 0) + goto cleanup; + } + } + + ret =3D 0; + cleanup: + VIR_FREE(vfiopath); + return ret; +} + +static int +pci_vfio_lock_iommu(struct pciDevice *device) +{ + 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) + break; + } + + if (i !=3D npciIommuGroups) { + if (!pciIommuGroups[i]->nDevicesBoundToVFIO) { + if (virAsprintfQuiet(&vfiopath, "%s/dev/vfio/%d", + fakesysfspcidir, device->iommuGroup) < 0) { + errno =3D ENOMEM; + goto cleanup; + } + if ((fd =3D real_open(vfiopath, O_CREAT)) < 0) + goto cleanup; + } + pciIommuGroups[i]->nDevicesBoundToVFIO++; + } + + ret =3D 0; + cleanup: + real_close(fd); + VIR_FREE(vfiopath); + return ret; +} =20 /* * PCI Driver functions @@ -588,6 +699,10 @@ pci_driver_bind(struct pciDriver *driver, if (symlink(devpath, driverpath) < 0) goto cleanup; =20 + if (STREQ(driver->name, "vfio-pci")) + if (pci_vfio_lock_iommu(dev) < 0) + goto cleanup; + dev->driver =3D driver; ret =3D 0; cleanup: @@ -622,6 +737,10 @@ pci_driver_unbind(struct pciDriver *driver, unlink(driverpath) < 0) goto cleanup; =20 + if (STREQ(driver->name, "vfio-pci")) + if (pci_vfio_release_iommu(dev) < 0) + goto cleanup; + dev->driver =3D NULL; ret =3D 0; cleanup: @@ -819,6 +938,8 @@ init_syms(void) static void init_env(void) { + char *devvfio; + if (fakerootdir && fakesysfspcidir) return; =20 @@ -833,6 +954,28 @@ init_env(void) ABORT("Unable to create: %s", fakesysfspcidir); =20 make_file(fakesysfspcidir, "drivers_probe", NULL, -1); + if (virAsprintfQuiet(&devvfio, "%s/dev/vfio", fakesysfspcidir) < 0) + ABORT_OOM(); + + if (virFileMakePath(devvfio) < 0) + ABORT("Unable to create: %s", devvfio); + + /* Create /dev/vfio/vfio file */ + make_file(devvfio, "vfio", NULL, -1); + VIR_FREE(devvfio); + + pci_iommu_new(0); + pci_iommu_new(1); + pci_iommu_new(2); + pci_iommu_new(3); + pci_iommu_new(4); + pci_iommu_new(5); + pci_iommu_new(6); + pci_iommu_new(7); + pci_iommu_new(8); + pci_iommu_new(9); + pci_iommu_new(10); + pci_iommu_new(11); =20 # define MAKE_PCI_DRIVER(name, ...) \ pci_driver_new(name, 0, __VA_ARGS__, -1, -1) @@ -842,6 +985,7 @@ init_env(void) MAKE_PCI_DRIVER("pci-stub", -1, -1); pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); =20 + # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ do { \ struct pciDevice dev =3D {.id =3D (char *)Id, .vendor =3D Vendor, \ @@ -849,20 +993,21 @@ init_env(void) 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, .class =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, .class =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, .iommuGroup =3D 0); + MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044, .iommuGroup =3D 1); + MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046, .iommuGroup =3D 2); + MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048, .iommuGroup =3D 3); + MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, .class =3D 0x060400, .= iommuGroup =3D 4); + MAKE_PCI_DEVICE("0001:01:00.0", 0x8086, 0x105e, .iommuGroup =3D 5); + MAKE_PCI_DEVICE("0001:01:00.1", 0x8086, 0x105e, .iommuGroup =3D 5); + MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, .class =3D 0x060400, .= iommuGroup =3D 6); + MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0005:90:01.3", 0x1033, 0x00e0, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, .iommuGroup =3D 8); + MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, .iommuGroup =3D 8); + MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, .iommuGroup =3D 8); } =20 =20 @@ -1029,7 +1174,8 @@ opendir(const char *path) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && + if ((STRPREFIX(path, SYSFS_PCI_PREFIX) || + STRPREFIX(path, SYSFS_KERNEL_PREFIX)) && getrealpath(&newpath, path) < 0) return NULL; =20 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099419539938.481700011771; Thu, 15 Mar 2018 00:36:59 -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 1435F80083; Thu, 15 Mar 2018 07:36:58 +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 BFFA060A9E; Thu, 15 Mar 2018 07:36:57 +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 859C14CAAF; Thu, 15 Mar 2018 07:36:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHGnNe024289 for ; Wed, 14 Mar 2018 13:17:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id A71CB5C552; Wed, 14 Mar 2018 17:16:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D6CA5C542 for ; Wed, 14 Mar 2018 17:16:47 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9087D3EA6C2 for ; Wed, 14 Mar 2018 17:16:46 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHEBj0032654 for ; Wed, 14 Mar 2018 13:16:46 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq7172ncw-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:16:45 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:16:43 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:16:41 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHGfWq53018706 for ; Wed, 14 Mar 2018 17:16:41 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4524C52043 for ; Wed, 14 Mar 2018 16:08:11 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id AD5BE5203F for ; Wed, 14 Mar 2018 16:08:10 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:46:39 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-0000044078C8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000020E37E90 Message-Id: <152104779126.10112.368308401648522270.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:16:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:16:46 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 04/28] virpcitest: Change the stub driver to vfio from pci-stub 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.28]); Thu, 15 Mar 2018 07:36:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The pci-stub is obsolete for a while now. Upcoming test cases try to test the VFIO hotplug/unplug cases. Change the default test driver to vfio-pci instead of pci-stub, and fail bind for pci-stub instead. Signed-off-by: Shivaprasad G Bhat --- tests/virhostdevtest.c | 8 ++++---- tests/virpcimock.c | 5 ++--- tests/virpcitest.c | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index e4fee567a2..41062ebf3c 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -97,7 +97,7 @@ myInit(void) subsys.u.pci.addr.bus =3D 0; subsys.u.pci.addr.slot =3D i + 1; subsys.u.pci.addr.function =3D 0; - subsys.u.pci.backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; + subsys.u.pci.backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; hostdevs[i]->source.subsys =3D subsys; } =20 @@ -105,7 +105,7 @@ myInit(void) if (!(dev[i] =3D virPCIDeviceNew(0, 0, i + 1, 0))) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_KVM); + virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO); } =20 if (VIR_ALLOC(mgr) < 0) @@ -485,7 +485,7 @@ testVirHostdevRoundtripManaged(const void *opaque ATTRI= BUTE_UNUSED) { int ret =3D -1; =20 - if (virHostdevHostSupportsPassthroughKVM()) { + if (virHostdevHostSupportsPassthroughVFIO()) { if (testVirHostdevPreparePCIHostdevs_managed(false) < 0) goto out; if (testVirHostdevReAttachPCIHostdevs_managed(false) < 0) @@ -517,7 +517,7 @@ testVirHostdevRoundtripMixed(const void *opaque ATTRIBU= TE_UNUSED) =20 if (testVirHostdevDetachPCINodeDevice() < 0) goto out; - if (virHostdevHostSupportsPassthroughKVM()) { + if (virHostdevHostSupportsPassthroughVFIO()) { if (testVirHostdevPreparePCIHostdevs_managed(true) < 0) goto out; if (testVirHostdevReAttachPCIHostdevs_managed(true) < 0) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 22adc740b8..c9b7434c9a 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -982,9 +982,8 @@ init_env(void) =20 MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); - MAKE_PCI_DRIVER("pci-stub", -1, -1); - pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); - + pci_driver_new("pci-stub", PCI_ACTION_BIND, -1, -1); + MAKE_PCI_DRIVER("vfio-pci", -1, -1); =20 # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ do { \ diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 80e994ae52..fa7acb85a2 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -110,12 +110,12 @@ testVirPCIDeviceDetach(const void *opaque ATTRIBUTE_U= NUSED) if (!(dev[i] =3D virPCIDeviceNew(0, 0, i + 1, 0))) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_KVM); + virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO); =20 if (virPCIDeviceDetach(dev[i], activeDevs, inactiveDevs) < 0) goto cleanup; =20 - if (testVirPCIDeviceCheckDriver(dev[i], "pci-stub") < 0) + if (testVirPCIDeviceCheckDriver(dev[i], "vfio-pci") < 0) goto cleanup; =20 CHECK_LIST_COUNT(activeDevs, 0); @@ -249,7 +249,7 @@ testVirPCIDeviceDetachSingle(const void *opaque) if (!dev) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_KVM); + virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_VFIO); =20 if (virPCIDeviceDetach(dev, NULL, NULL) < 0) goto cleanup; @@ -271,7 +271,7 @@ testVirPCIDeviceDetachFail(const void *opaque) if (!dev) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_VFIO); + virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_KVM); =20 if (virPCIDeviceDetach(dev, NULL, NULL) < 0) { if (virTestGetVerbose() || virTestGetDebug()) @@ -282,7 +282,7 @@ testVirPCIDeviceDetachFail(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, "Attaching device %s to %s should have failed", virPCIDeviceGetName(dev), - virPCIStubDriverTypeToString(VIR_PCI_STUB_DRIVER_VF= IO)); + virPCIStubDriverTypeToString(VIR_PCI_STUB_DRIVER_KV= M)); } =20 cleanup: @@ -441,7 +441,7 @@ mymain(void) /* Detach an unbound device */ DO_TEST_PCI_DRIVER(0, 0x0a, 2, 0, NULL); DO_TEST_PCI(testVirPCIDeviceDetachSingle, 0, 0x0a, 2, 0); - DO_TEST_PCI_DRIVER(0, 0x0a, 2, 0, "pci-stub"); + DO_TEST_PCI_DRIVER(0, 0x0a, 2, 0, "vfio-pci"); =20 /* Reattach an unknown unbound device */ DO_TEST_PCI_DRIVER(0, 0x0a, 3, 0, NULL); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099202241179.3130819155583; Thu, 15 Mar 2018 00:33:22 -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 0029E7FEC0; Thu, 15 Mar 2018 07:33:21 +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 CE51518A26; Thu, 15 Mar 2018 07:33: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 65EFE180BADA; Thu, 15 Mar 2018 07:33:20 +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 w2EHH7rm024460 for ; Wed, 14 Mar 2018 13:17:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4559A60476; Wed, 14 Mar 2018 17:17:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E6CD6134A for ; Wed, 14 Mar 2018 17:17:03 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D028D47D2 for ; Wed, 14 Mar 2018 17:17:01 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHF5hE086644 for ; Wed, 14 Mar 2018 13:17:01 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5fk7hte-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:17:00 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:16:59 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:16:58 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHGvQN50462760 for ; Wed, 14 Mar 2018 17:16:57 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C7114204B for ; Wed, 14 Mar 2018 17:09:12 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6D3C42041 for ; Wed, 14 Mar 2018 17:09:10 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:09:10 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:46:55 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0016-0000-0000-000005327906 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0017-0000-0000-0000286F7EB7 Message-Id: <152104780648.10112.13439559210950099731.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:17:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:17:02 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 05/28] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 15 Mar 2018 07:33:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 test xmls using the VFs to use the newly added VFs for their use case. Signed-off-by: Shivaprasad G Bhat --- .../hostdev-pci-address-device.args | 2 +- .../hostdev-pci-address-device.xml | 2 +- tests/qemuxml2argvdata/hostdev-pci-address.args | 2 +- tests/qemuxml2argvdata/hostdev-pci-address.xml | 2 +- .../qemuxml2argvdata/hostdev-vfio-multidomain.args | 2 +- .../qemuxml2argvdata/hostdev-vfio-multidomain.xml | 2 +- tests/qemuxml2argvdata/hostdev-vfio.args | 2 +- tests/qemuxml2argvdata/hostdev-vfio.xml | 2 +- tests/qemuxml2argvdata/net-hostdev-fail.xml | 2 +- .../qemuxml2argvdata/net-hostdev-multidomain.args | 2 +- tests/qemuxml2argvdata/net-hostdev-multidomain.xml | 2 +- tests/qemuxml2argvdata/net-hostdev-vfio.args | 2 +- tests/qemuxml2argvdata/net-hostdev-vfio.xml | 2 +- tests/qemuxml2argvdata/net-hostdev.args | 2 +- tests/qemuxml2argvdata/net-hostdev.xml | 2 +- tests/qemuxml2argvdata/pci-rom.args | 4 ++-- tests/qemuxml2argvdata/pci-rom.xml | 4 ++-- tests/qemuxml2xmloutdata/hostdev-pci-address.xml | 2 +- tests/qemuxml2xmloutdata/hostdev-vfio.xml | 2 +- tests/qemuxml2xmloutdata/net-hostdev-vfio.xml | 2 +- tests/qemuxml2xmloutdata/net-hostdev.xml | 2 +- tests/qemuxml2xmloutdata/pci-rom.xml | 4 ++-- tests/virpcimock.c | 14 ++++++++++++++ tests/virpcitestdata/0000-06-12.0.config | Bin tests/virpcitestdata/0000-06-12.1.config | Bin tests/virpcitestdata/0000-06-12.2.config | Bin 26 files changed, 39 insertions(+), 25 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-pci-address-device.args b/tests= /qemuxml2argvdata/hostdev-pci-address-device.args index a250082e1e..93221b6e9d 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address-device.args +++ b/tests/qemuxml2argvdata/hostdev-pci-address-device.args @@ -22,5 +22,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device pci-assign,host=3D06:12.5,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device pci-assign,host=3D06: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-pci-address-device.xml b/tests/= qemuxml2argvdata/hostdev-pci-address-device.xml index 814fdcc271..492031d5a9 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address-device.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-address-device.xml @@ -20,7 +20,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/hostdev-pci-address.args b/tests/qemuxm= l2argvdata/hostdev-pci-address.args index 1f3a2443bf..728712a1c1 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address.args +++ b/tests/qemuxml2argvdata/hostdev-pci-address.args @@ -21,4 +21,4 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device pci-assign,host=3D06:12.5,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 +-device pci-assign,host=3D06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/hostdev-pci-address.xml b/tests/qemuxml= 2argvdata/hostdev-pci-address.xml index 17968350ff..af7e300c57 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-address.xml @@ -27,7 +27,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args b/tests/q= emuxml2argvdata/hostdev-vfio-multidomain.args index 492e9b35e0..87ea9e7e09 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args +++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args @@ -22,5 +22,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --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 ba54d03e8e..d7cc2b7246 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio.args +++ b/tests/qemuxml2argvdata/hostdev-vfio.args @@ -22,5 +22,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device vfio-pci,host=3D06:12.5,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D06: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-multidomain.args b/tests/qe= muxml2argvdata/net-hostdev-multidomain.args index 7d27964715..58696a4a9c 100644 --- a/tests/qemuxml2argvdata/net-hostdev-multidomain.args +++ b/tests/qemuxml2argvdata/net-hostdev-multidomain.args @@ -22,5 +22,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device pci-assign,host=3D2424:21:1c.6,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x= 3 \ +-device pci-assign,host=3D0021:de:1f.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x= 3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/net-hostdev-multidomain.xml b/tests/qem= uxml2argvdata/net-hostdev-multidomain.xml index 27e5f0f724..71d053a3da 100644 --- a/tests/qemuxml2argvdata/net-hostdev-multidomain.xml +++ b/tests/qemuxml2argvdata/net-hostdev-multidomain.xml @@ -25,7 +25,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.args b/tests/qemuxml2a= rgvdata/net-hostdev-vfio.args index 7247c6c1f2..6dfbe61689 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio.args +++ b/tests/qemuxml2argvdata/net-hostdev-vfio.args @@ -22,5 +22,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device vfio-pci,host=3D03:07.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D06: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/qemuxml2argvdata/net-hostdev.args b/tests/qemuxml2argvda= ta/net-hostdev.args index e137a0a5b1..7663821e53 100644 --- a/tests/qemuxml2argvdata/net-hostdev.args +++ b/tests/qemuxml2argvdata/net-hostdev.args @@ -22,5 +22,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device pci-assign,host=3D03:07.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device pci-assign,host=3D06: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.xml b/tests/qemuxml2argvdat= a/net-hostdev.xml index 829d8b850b..9949e6ef30 100644 --- a/tests/qemuxml2argvdata/net-hostdev.xml +++ b/tests/qemuxml2argvdata/net-hostdev.xml @@ -25,7 +25,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/pci-rom.args b/tests/qemuxml2argvdata/p= ci-rom.args index b50581283e..9451d7613a 100644 --- a/tests/qemuxml2argvdata/pci-rom.args +++ b/tests/qemuxml2argvdata/pci-rom.args @@ -28,7 +28,7 @@ rombar=3D1 \ -device virtio-net-pci,vlan=3D1,id=3Dnet1,mac=3D52:54:00:24:a5:9e,bus=3Dpc= i.0,addr=3D0x4,\ romfile=3D/etc/fake/bootrom.bin \ -net user,vlan=3D1,name=3Dhostnet1 \ --device pci-assign,host=3D06:12.5,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x5,rom= bar=3D0 \ --device pci-assign,host=3D06:12.6,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x6,rom= bar=3D1,\ +-device pci-assign,host=3D06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x5,rom= bar=3D0 \ +-device pci-assign,host=3D06:12.2,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x6,rom= bar=3D1,\ romfile=3D/etc/fake/bootrom.bin \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x7 diff --git a/tests/qemuxml2argvdata/pci-rom.xml b/tests/qemuxml2argvdata/pc= i-rom.xml index 09cafb35a9..048bcd3b59 100644 --- a/tests/qemuxml2argvdata/pci-rom.xml +++ b/tests/qemuxml2argvdata/pci-rom.xml @@ -36,13 +36,13 @@ -
+
-
+
diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-address.xml b/tests/qemux= ml2xmloutdata/hostdev-pci-address.xml index 59cb86e1d5..1e80b9b387 100644 --- a/tests/qemuxml2xmloutdata/hostdev-pci-address.xml +++ b/tests/qemuxml2xmloutdata/hostdev-pci-address.xml @@ -31,7 +31,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/qemuxml2xmloutdata/net-hostdev.xml b/tests/qemuxml2xmlou= tdata/net-hostdev.xml index bede4b034f..0141a0c5a3 100644 --- a/tests/qemuxml2xmloutdata/net-hostdev.xml +++ b/tests/qemuxml2xmloutdata/net-hostdev.xml @@ -30,7 +30,7 @@ -
+
diff --git a/tests/qemuxml2xmloutdata/pci-rom.xml b/tests/qemuxml2xmloutdat= a/pci-rom.xml index 982231fefe..5b5a8b217b 100644 --- a/tests/qemuxml2xmloutdata/pci-rom.xml +++ b/tests/qemuxml2xmloutdata/pci-rom.xml @@ -43,14 +43,14 @@ -
+
-
+
diff --git a/tests/virpcimock.c b/tests/virpcimock.c index c9b7434c9a..abe08a30ea 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -134,6 +134,7 @@ struct pciDevice { int device; int class; int iommuGroup; + const char *physfn; struct pciDriver *driver; /* Driver attached. NULL if attached to no= driver */ }; =20 @@ -433,6 +434,14 @@ pci_device_new_from_stub(const struct pciDevice *data) } make_symlink(devpath, "iommu_group", tmp); =20 + if (dev->physfn) { + if (snprintf(tmp, sizeof(tmp), + "%s/devices/%s", fakesysfspcidir, dev->physfn) < 0) { + ABORT("@tmp overflow"); + } + make_symlink(devpath, "physfn", tmp); + } + if (pci_device_autobind(dev) < 0) ABORT("Unable to bind: %s", data->id); =20 @@ -1007,6 +1016,11 @@ init_env(void) MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, .iommuGroup =3D 8); MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, .iommuGroup =3D 8); MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, .iommuGroup =3D 8); + MAKE_PCI_DEVICE("0000:06:12.0", 0x8086, 0x0047, .iommuGroup =3D 9); + MAKE_PCI_DEVICE("0000:06:12.1", 0x8086, 0x0047, .iommuGroup =3D 10, .p= hysfn =3D "0000:06:12.0"); /* Virtual Function */ + MAKE_PCI_DEVICE("0000:06:12.2", 0x8086, 0x0047, .iommuGroup =3D 11, .p= hysfn =3D "0000:06:12.0"); /* Virtual Function */ + MAKE_PCI_DEVICE("0021:de:1f.0", 0x8086, 0x0047, .iommuGroup =3D 12); + MAKE_PCI_DEVICE("0021:de:1f.1", 0x8086, 0x0047, .iommuGroup =3D 13, .p= hysfn =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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099199201720.9436491900921; Thu, 15 Mar 2018 00:33:19 -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 EFBE9C00F6E7; Thu, 15 Mar 2018 07:33:17 +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 CA54460BB6; Thu, 15 Mar 2018 07:33:17 +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 996964CA9D; Thu, 15 Mar 2018 07:33:17 +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 w2EHHLuk024472 for ; Wed, 14 Mar 2018 13:17:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 416C660240; Wed, 14 Mar 2018 17:17:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A0E260F9B for ; Wed, 14 Mar 2018 17:17:17 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD49AC057FA0 for ; Wed, 14 Mar 2018 17:17:15 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHF8nl086772 for ; Wed, 14 Mar 2018 13:17:15 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5fk7j4n-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:17:14 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:17:13 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:17:10 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHHA2i54657122 for ; Wed, 14 Mar 2018 17:17:10 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8925E11C05C for ; Wed, 14 Mar 2018 17:09:48 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C27F011C052 for ; Wed, 14 Mar 2018 17:09:47 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:09:47 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:47:08 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0016-0000-0000-00000532790A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0017-0000-0000-0000286F7EBB Message-Id: <152104782292.10112.3114978325846422577.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:17:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:17:15 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 06/28] tests: qemu: Add test case for 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 15 Mar 2018 07:33:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/util/virprocess.h | 2 - tests/Makefile.am | 7 ++ tests/qemuhotplugtest.c | 42 ++++++++++++++ .../qemuhotplug-hostdev-pci.xml | 6 ++ .../qemuhotplug-base-live+hostdev-pci.xml | 60 ++++++++++++++++= ++++ .../qemuhotplug-pseries-base-live+hostdev-pci.xml | 53 ++++++++++++++++= ++ .../qemuhotplug-pseries-base-live.xml | 45 +++++++++++++++ tests/virprocessmock.c | 28 +++++++++ 8 files changed, 241 insertions(+), 2 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 3c5a882772..5e68b47744 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -72,7 +72,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 15c8cc8158..9ff78ad382 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -213,6 +213,7 @@ test_libraries =3D libshunload.la \ virpcimock.la \ virnetdevmock.la \ virrandommock.la \ + virprocessmock.la \ virhostcpumock.la \ domaincapsmock.la \ virfilecachemock.la \ @@ -1149,6 +1150,12 @@ virrandommock_la_SOURCES =3D \ virrandommock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) virrandommock_la_LIBADD =3D $(MOCKLIBS_LIBS) =20 +virprocessmock_la_SOURCES =3D \ + virprocessmock.c +virprocessmock_la_CFLAGS =3D $(AM_CFLAGS) +virprocessmock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) +virprocessmock_la_LIBADD =3D $(MOCKLIBS_LIBS) + virhostcpumock_la_SOURCES =3D \ virhostcpumock.c virhostcpumock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index d42f8e12cb..31ce8d43b9 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -26,6 +26,7 @@ #include "qemumonitortestutils.h" #include "testutils.h" #include "testutilsqemu.h" +#include "virhostdev.h" #include "virerror.h" #include "virstring.h" #include "virthread.h" @@ -78,6 +79,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); if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); =20 @@ -131,6 +134,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\n", virDomainDeviceTypeToString(dev->type)); @@ -159,6 +165,9 @@ testQemuHotplugDetach(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_WATCHDOG: ret =3D qemuDomainDetachWatchdog(&driver, vm, dev->data.watchdog); break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + ret =3D qemuDomainDetachHostDevice(&driver, vm, dev); + break; default: VIR_TEST_VERBOSE("device type '%s' cannot be detached\n", virDomainDeviceTypeToString(dev->type)); @@ -579,6 +588,7 @@ testQemuHotplugCpuIndividual(const void *opaque) } =20 =20 +#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" =20 static int mymain(void) @@ -586,6 +596,20 @@ 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); + unsetenv("LD_PRELOAD"); =20 #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); @@ -613,6 +637,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 @@ -821,6 +847,14 @@ mymain(void) "disk-scsi-duplicate-wwn", false, false, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); + DO_TEST_ATTACH_EVENT("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_EVENT("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); =20 DO_TEST_ATTACH("base-live", "watchdog", false, true, "watchdog-set-action", QMP_OK, @@ -873,9 +907,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, + abs_builddir "/.libs/virpcimock.so", + abs_builddir "/.libs/virprocessmock.so"); 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..524fb59dc1 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci.xml @@ -0,0 +1,60 @@ + + 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..fb56aa38d0 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+hostdev-pc= i.xml @@ -0,0 +1,53 @@ + + 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..896c8ae033 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml @@ -0,0 +1,45 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + + + + diff --git a/tests/virprocessmock.c b/tests/virprocessmock.c new file mode 100644 index 0000000000..985562fee1 --- /dev/null +++ b/tests/virprocessmock.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Red Hat, Inc. + * Copyright (C) 2018 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; +} -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099428787591.6141698949804; Thu, 15 Mar 2018 00:37:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 552D3800A3; Thu, 15 Mar 2018 07:37:07 +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 1A35854478; Thu, 15 Mar 2018 07:37:07 +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 CCEF74CAB7; Thu, 15 Mar 2018 07:37:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHHqoe024510 for ; Wed, 14 Mar 2018 13:18:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id C31985F703; Wed, 14 Mar 2018 17:17:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA71B5C552 for ; Wed, 14 Mar 2018 17:17:50 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36E4D20B0B for ; Wed, 14 Mar 2018 17:17:49 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHF5A5086670 for ; Wed, 14 Mar 2018 13:17:48 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5fk7jtm-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:17:48 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:17:46 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:17:45 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHHiij32899176 for ; Wed, 14 Mar 2018 17:17:44 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 365604C040 for ; Wed, 14 Mar 2018 17:10:59 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 882614C044 for ; Wed, 14 Mar 2018 17:10:54 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:10:54 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:47:38 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD78FD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707EB8 Message-Id: <152104783567.10112.10274483786332000733.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:17:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:17:49 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 07/28] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 15 Mar 2018 07:37:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 The next few commits improve on automatically detecting the multifunction cards and auto-assinging the addresses appropriately. Signed-off-by: Shivaprasad G Bhat --- .../hostdev-pci-multifunction.args | 29 +++++++ .../qemuxml2argvdata/hostdev-pci-multifunction.xml | 59 +++++++++++++++ tests/qemuxml2argvtest.c | 5 + .../hostdev-pci-multifunction.xml | 79 ++++++++++++++++= ++++ tests/qemuxml2xmltest.c | 1=20 5 files changed, 173 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..6b57f5713f --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.args @@ -0,0 +1,29 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name delete \ +-S \ +-M pc \ +-m 256 \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-delete/monitor.= sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-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=3D06:12.1,id=3Dhostdev5,bus=3Dpci.0,addr=3D0x8 \ +-device vfio-pci,host=3D06: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 731db9ed52..1e00eb167a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1604,6 +1604,11 @@ mymain(void) DO_TEST("hostdev-vfio-multidomain", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST("hostdev-pci-multifunction", + QEMU_CAPS_KVM, + QEMU_CAPS_DEVICE_VFIO_PCI, + QEMU_CAPS_HOST_PCI_MULTIDOMAIN, + QEMU_CAPS_PCI_MULTIFUNCTION); DO_TEST("hostdev-mdev-precreated", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); 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 28ba46efb2..91e3285109 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -473,6 +473,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-mdev-precreated", NONE); DO_TEST("pci-rom", NONE); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099112517612.1159726878664; Thu, 15 Mar 2018 00:31:52 -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 D3C487F7AF; Thu, 15 Mar 2018 07:31:50 +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 9A86518945; Thu, 15 Mar 2018 07:31:50 +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 5DF66181B9FD; Thu, 15 Mar 2018 07:31:50 +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 w2EHISYk024552 for ; Wed, 14 Mar 2018 13:18:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 58F9754580; Wed, 14 Mar 2018 17:18:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C265608F7 for ; Wed, 14 Mar 2018 17:18:25 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C9088049B for ; Wed, 14 Mar 2018 17:18:24 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHGOTu065395 for ; Wed, 14 Mar 2018 13:18:23 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq5bd05wg-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:18:22 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:18:20 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:18:19 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHIJei56623138 for ; Wed, 14 Mar 2018 17:18:19 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FEAD4C040 for ; Wed, 14 Mar 2018 17:11:33 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DCDF4C044 for ; Wed, 14 Mar 2018 17:11:33 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:11:32 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:48:17 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD7906 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707EC2 Message-Id: <152104786997.10112.1455235497465118846.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 14 Mar 2018 17:18:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 14 Mar 2018 17:18:24 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 08/28] util: virpci: detect if the device is a multifunction device from sysfs 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.28]); Thu, 15 Mar 2018 07:31:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/libvirt_private.syms | 1 + src/node_device/node_device_udev.c | 2 +- src/util/virhostdev.c | 2 +- src/util/virpci.c | 20 ++++++++++++++++++-- src/util/virpci.h | 3 ++- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e1bdaa127e..53e174a223 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2462,6 +2462,7 @@ virPCIDeviceGetUnbindFromStub; virPCIDeviceGetUsedBy; virPCIDeviceHasPCIExpressLink; virPCIDeviceIsAssignable; +virPCIDeviceIsMultifunction; virPCIDeviceIsPCIExpress; virPCIDeviceListAdd; virPCIDeviceListAddCopy; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index e87eb32a85..99b936bb5c 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -455,7 +455,7 @@ udevProcessPCI(struct udev_device *device, =20 /* We need to be root to read PCI device configs */ if (privileged) { - if (virPCIGetHeaderType(pciDev, &pci_dev->hdrType) < 0) + if (virPCIGetHeaderType(pciDev, &pci_dev->hdrType, NULL) < 0) goto cleanup; =20 if (virPCIDeviceIsPCIExpress(pciDev) > 0) { diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index e0133cdeec..807caf567a 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -693,7 +693,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, struct virHostdevIsPCINodeDeviceUsedData data =3D { mgr, dom_name,= usesVFIO }; int hdrType =3D -1; =20 - if (virPCIGetHeaderType(pci, &hdrType) < 0) + if (virPCIGetHeaderType(pci, &hdrType, NULL) < 0) goto cleanup; =20 if (hdrType !=3D VIR_PCI_HEADER_ENDPOINT) { diff --git a/src/util/virpci.c b/src/util/virpci.c index 55e4c3e492..a827b3bc0f 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -936,7 +936,7 @@ virPCIDeviceReset(virPCIDevicePtr dev, int fd =3D -1; int hdrType =3D -1; =20 - if (virPCIGetHeaderType(dev, &hdrType) < 0) + if (virPCIGetHeaderType(dev, &hdrType, NULL) < 0) return -1; =20 if (hdrType !=3D VIR_PCI_HEADER_ENDPOINT) { @@ -3169,6 +3169,18 @@ virPCIGetMdevTypes(const char *sysfspath ATTRIBUTE_U= NUSED, } #endif /* __linux__ */ =20 +bool +virPCIDeviceIsMultifunction(virPCIDevicePtr dev) +{ + bool multifunction =3D false; + int hdrType =3D -1; + + if (virPCIGetHeaderType(dev, &hdrType, &multifunction) < 0) + return false; + + return multifunction; +} + int virPCIDeviceIsPCIExpress(virPCIDevicePtr dev) { @@ -3254,10 +3266,11 @@ virPCIDeviceGetLinkCapSta(virPCIDevicePtr dev, } =20 =20 -int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdrType) +int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdrType, bool *multiFunc) { int fd; uint8_t type; + bool multi =3D false; =20 *hdrType =3D -1; =20 @@ -3268,6 +3281,7 @@ int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdr= Type) =20 virPCIDeviceConfigClose(dev, fd); =20 + multi =3D type & PCI_HEADER_TYPE_MULTI; type &=3D PCI_HEADER_TYPE_MASK; if (type >=3D VIR_PCI_HEADER_LAST) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3276,6 +3290,8 @@ int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdr= Type) } =20 *hdrType =3D type; + if (multiFunc) + *multiFunc =3D multi; =20 return 0; } diff --git a/src/util/virpci.h b/src/util/virpci.h index 794b7e59db..179249677a 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -199,6 +199,7 @@ int virPCIGetVirtualFunctions(const char *sysfs_path, size_t *num_virtual_functions, unsigned int *max_virtual_functions); =20 +bool virPCIDeviceIsMultifunction(virPCIDevicePtr dev); int virPCIIsVirtualFunction(const char *vf_sysfs_device_link); =20 int virPCIGetVirtualFunctionIndex(const char *pf_sysfs_device_link, @@ -246,7 +247,7 @@ int virPCIDeviceGetLinkCapSta(virPCIDevicePtr dev, unsigned int *sta_speed, unsigned int *sta_width); =20 -int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdrType); +int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdrType, bool *multiFunc= ); =20 void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev); =20 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099407087460.99585455424017; Thu, 15 Mar 2018 00:36:47 -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 CDC066811A; Thu, 15 Mar 2018 07:36:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B4A260C1B; Thu, 15 Mar 2018 07:36:45 +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 454C14CAA4; Thu, 15 Mar 2018 07:36:45 +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 w2EHIv47024582 for ; Wed, 14 Mar 2018 13:19:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id C7F5260BE5; Wed, 14 Mar 2018 17:18:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C174260BE3 for ; Wed, 14 Mar 2018 17:18:54 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 393D77E9C0 for ; Wed, 14 Mar 2018 17:18:54 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHGLvf065221 for ; Wed, 14 Mar 2018 13:18:53 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq5bd06gd-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:18:53 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:18:51 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:18:48 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHIm8Q42336392 for ; Wed, 14 Mar 2018 17:18:48 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7959A4040 for ; Wed, 14 Mar 2018 17:11:37 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EFB9A4057 for ; Wed, 14 Mar 2018 17:11:37 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:11:36 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:48:46 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0012-0000-0000-000005BE77FC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0013-0000-0000-0000193A7DD5 Message-Id: <152104790448.10112.4161433205633547871.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 14 Mar 2018 17:18:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 14 Mar 2018 17:18:54 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 09/28] tests: qemu: mock pci environment for qemuargv2xmltests 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.38]); Thu, 15 Mar 2018 07:36:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The upcoming patches verify the sysfs for pci hostdevs. So, preload the mock library and change the device to what exists on the mock environment to avoid a failure. Signed-off-by: Shivaprasad G Bhat --- tests/qemuargv2xmldata/hostdev-pci-address.args | 2 +- tests/qemuargv2xmldata/hostdev-pci-address.xml | 2 +- tests/qemuargv2xmltest.c | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/qemuargv2xmldata/hostdev-pci-address.args b/tests/qemuar= gv2xmldata/hostdev-pci-address.args index 4d24ce3b75..111dff773f 100644 --- a/tests/qemuargv2xmldata/hostdev-pci-address.args +++ b/tests/qemuargv2xmldata/hostdev-pci-address.args @@ -20,4 +20,4 @@ QEMU_AUDIO_DRV=3Dnone \ -net none \ -serial none \ -parallel none \ --pcidevice host=3D06:12.5 +-pcidevice host=3D06:12.1 diff --git a/tests/qemuargv2xmldata/hostdev-pci-address.xml b/tests/qemuarg= v2xmldata/hostdev-pci-address.xml index d6b9ce1d25..fd0bff62e6 100644 --- a/tests/qemuargv2xmldata/hostdev-pci-address.xml +++ b/tests/qemuargv2xmldata/hostdev-pci-address.xml @@ -31,7 +31,7 @@ -
+
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index cb010268c4..a68c13fead 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -144,12 +144,25 @@ testCompareXMLToArgvHelper(const void *data) return result; } =20 - +# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" =20 static int mymain(void) { int ret =3D 0; + 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 (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; @@ -298,7 +311,8 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, + abs_builddir "/.libs/virpcimock.so") =20 #else =20 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099192861982.9747548000887; Thu, 15 Mar 2018 00:33:12 -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 8E76E7FEC1; Thu, 15 Mar 2018 07:33:11 +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 662BE189BE; Thu, 15 Mar 2018 07:33:11 +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 32E45244EA; Thu, 15 Mar 2018 07:33:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHJMMG024618 for ; Wed, 14 Mar 2018 13:19:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 194CA5C1AB; Wed, 14 Mar 2018 17:19:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1316E5C25E for ; Wed, 14 Mar 2018 17:19:19 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B429E20B09 for ; Wed, 14 Mar 2018 17:19:18 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHJIlr124934 for ; Wed, 14 Mar 2018 13:19:18 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq5c6g6j8-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:19:18 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:19:15 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:19:14 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHJEn037814440 for ; Wed, 14 Mar 2018 17:19:14 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C29BD4204B for ; Wed, 14 Mar 2018 17:11:28 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8B3542042 for ; Wed, 14 Mar 2018 17:11:27 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:11:27 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:49:11 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD7923 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707EE0 Message-Id: <152104793377.10112.8512579272040818114.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:19:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:19:18 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 10/28] virhostdev: Introduce virHostdevPCIDevicesBelongToSameSlot 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.25]); Thu, 15 Mar 2018 07:33:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/libvirt_private.syms | 2 ++ src/util/virhostdev.c | 29 +++++++++++++++++++++++++++++ src/util/virhostdev.h | 5 +++++ src/util/virpci.c | 2 +- src/util/virpci.h | 3 +++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 53e174a223..68b648ba31 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1919,6 +1919,7 @@ virHostdevHostSupportsPassthroughKVM; virHostdevHostSupportsPassthroughVFIO; virHostdevIsSCSIDevice; virHostdevManagerGetDefault; +virHostdevPCIDevicesBelongToSameSlot; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; virHostdevPCINodeDeviceReset; @@ -2443,6 +2444,7 @@ virPCIDeviceAddressGetIOMMUGroupAddresses; virPCIDeviceAddressGetIOMMUGroupNum; virPCIDeviceAddressGetSysfsFile; virPCIDeviceAddressIOMMUGroupIterate; +virPCIDeviceAddressIsEqual; virPCIDeviceAddressParse; virPCIDeviceCopy; virPCIDeviceDetach; diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 807caf567a..9508a29954 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -306,6 +306,35 @@ virHostdevIsVirtualFunction(virDomainHostdevDefPtr hos= tdev) } =20 =20 +bool +virHostdevPCIDevicesBelongToSameSlot(virDomainHostdevDefPtr dev1, + virDomainHostdevDefPtr dev2) +{ + virPCIDeviceAddressPtr devAddr1 =3D NULL, devAddr2 =3D NULL; + + if (!dev1 || !dev2) + return false; + + devAddr1 =3D &dev1->source.subsys.u.pci.addr; + devAddr2 =3D &dev2->source.subsys.u.pci.addr; + if ((devAddr1->domain !=3D devAddr2->domain) || + (devAddr1->bus !=3D devAddr2->bus) || + (devAddr1->slot !=3D devAddr2->slot) || + (virPCIDeviceAddressIsEqual(devAddr1, devAddr2))) { + return false; + } + + /* The Virtual Functions have multifunction false even though they hav= e same + * domain:bus:slot as the Physical function. They are to be treated + * like non-multifunction devices + */ + if (virHostdevIsVirtualFunction(dev1) || virHostdevIsVirtualFunction(d= ev2)) + return false; + + return true; +} + + static int virHostdevNetDevice(virDomainHostdevDefPtr hostdev, int pfNetDevIdx, diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index d5efffbac2..ded7620355 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -155,6 +155,11 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr = mgr, const char *drv_name, const char *dom_name) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); + +bool +virHostdevPCIDevicesBelongToSameSlot(virDomainHostdevDefPtr dev1, + virDomainHostdevDefPtr dev2); + int virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr, virDomainHostdevDefPtr *hostdevs, diff --git a/src/util/virpci.c b/src/util/virpci.c index a827b3bc0f..987db605cc 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2603,7 +2603,7 @@ virPCIDeviceAddressParse(char *address, /* * returns true if equal */ -static bool +bool virPCIDeviceAddressIsEqual(virPCIDeviceAddressPtr bdf1, virPCIDeviceAddressPtr bdf2) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 179249677a..5830fb4c12 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -188,6 +188,9 @@ int virPCIDeviceIsAssignable(virPCIDevicePtr dev, int strict_acs_check); int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher); =20 +bool +virPCIDeviceAddressIsEqual(virPCIDeviceAddressPtr bdf1, + virPCIDeviceAddressPtr bdf2); virPCIDeviceAddressPtr virPCIGetDeviceAddressFromSysfsLink(const char *device_link); =20 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099205316557.2910585163921; Thu, 15 Mar 2018 00:33:25 -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 1B4167F7A7; Thu, 15 Mar 2018 07:33:24 +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 BFA6C608F4; Thu, 15 Mar 2018 07:33:23 +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 7CB644CAA3; Thu, 15 Mar 2018 07:33:23 +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 w2EHJmrD024676 for ; Wed, 14 Mar 2018 13:20:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0989F5D70B; Wed, 14 Mar 2018 17:19:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 015255D753 for ; Wed, 14 Mar 2018 17:19:44 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8655E7E9C2 for ; Wed, 14 Mar 2018 17:19:43 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHImGj105816 for ; Wed, 14 Mar 2018 13:19:43 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq6nev108-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:19:42 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:19:40 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:19:38 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHJcoK50528356 for ; Wed, 14 Mar 2018 17:19:38 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EEE3A4051 for ; Wed, 14 Mar 2018 17:12:27 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E544A404D for ; Wed, 14 Mar 2018 17:12:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:12:26 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:49:35 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-0000042079D5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000026237F3E Message-Id: <152104795960.10112.16299515500617305394.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 14 Mar 2018 17:19:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 14 Mar 2018 17:19:43 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 11/28] qemu: address: Separate the slots into multiple aggregates 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.28]); Thu, 15 Mar 2018 07:33:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Today's aggregate flag with the slot being true for pcie-root-ports is not enough as there will more number of aggregates depending on the number of Multifuntion PCI cards assigned to the domain. The aggregate is changed to unsigned int and Zero means Not Applicable, 1 is reserved for the pcie-root-ports and >=3D 2 for the the PCI multifunction cards(coming..). Signed-off-by: Shivaprasad G Bhat --- src/conf/device_conf.h | 1=20 src/conf/domain_addr.c | 43 ++++++++++++++------- src/conf/domain_addr.h | 36 ++++++++--------- src/qemu/qemu_domain_address.c | 83 +++++++++++++++++++++++++++++++++---= ---- src/qemu/qemu_domain_address.h | 8 ++++ 5 files changed, 123 insertions(+), 48 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index f87d6f1fc6..cdb2040fb8 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -163,6 +163,7 @@ struct _virDomainDeviceInfo { * assignment, never saved and never reported. */ int pciConnectFlags; /* enum virDomainPCIConnectFlags */ + unsigned int aggregateSlotIdx; /* Used when the aggregate flag is set = */ char *loadparm; =20 /* PCI devices will only be automatically placed on a PCI bus diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 0c914fe25c..c4a0b99628 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -63,7 +63,7 @@ virDomainPCIControllerModelToConnectType(virDomainControl= lerModelPCI model) return VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - return VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | VIR_PCI_CONNECT_AGGRE= GATE_SLOT; + return VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: return VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT; @@ -565,6 +565,7 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddr= essSetPtr addrs, virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags, unsigned int isolationGroup, + unsigned int aggregateSlotIdx, bool fromConfig) { int ret =3D -1; @@ -598,8 +599,13 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAdd= ressSetPtr addrs, * slot, set the slot's aggregate flag. */ if (!bus->slot[addr->slot].functions && - flags & VIR_PCI_CONNECT_AGGREGATE_SLOT) { - bus->slot[addr->slot].aggregate =3D true; + aggregateSlotIdx > 0) { + bus->slot[addr->slot].aggregateSlotIdx =3D aggregateSlotIdx; + } else if (bus->slot[addr->slot].aggregateSlotIdx !=3D aggregateSlotId= x && fromConfig) { + bus->slot[addr->slot].aggregateSlotIdx =3D 0; + VIR_DEBUG("PCI functions of %.4x:%.2x is aggregated to slot %u" + "because of user assigned address %s", + addr->domain, addr->bus, aggregateSlotIdx, addrStr); } =20 if (virDomainPCIAddressBusIsEmpty(bus) && !bus->isolationGroupLocked) { @@ -624,8 +630,8 @@ virDomainPCIAddressReserveAddrInternal(virDomainPCIAddr= essSetPtr addrs, =20 /* mark the requested function as reserved */ bus->slot[addr->slot].functions |=3D (1 << addr->function); - VIR_DEBUG("Reserving PCI address %s (aggregate=3D'%s')", addrStr, - bus->slot[addr->slot].aggregate ? "true" : "false"); + VIR_DEBUG("Reserving PCI address %s (aggregateSlotIdx=3D'%d')", addrSt= r, + bus->slot[addr->slot].aggregateSlotIdx); =20 ret =3D 0; cleanup: @@ -638,10 +644,11 @@ int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags, - unsigned int isolationGroup) + unsigned int isolationGroup, + unsigned int aggregateSlotIdx) { return virDomainPCIAddressReserveAddrInternal(addrs, addr, flags, - isolationGroup, true); + isolationGroup, aggregat= eSlotIdx, true); } =20 int @@ -678,6 +685,7 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr= addrs, =20 ret =3D virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.p= ci, flags, dev->isolation= Group, + dev->aggregateSlotIdx, true); } else { ret =3D virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1); @@ -730,6 +738,7 @@ virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr ad= drs) static int virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCIAddressBusPtr bus, virPCIDeviceAddressPtr searchAd= dr, + unsigned int aggregateSlotIdx, int function, virDomainPCIConnectFlags flags, bool *found) @@ -753,8 +762,8 @@ virDomainPCIAddressFindUnusedFunctionOnBus(virDomainPCI= AddressBusPtr bus, break; } =20 - if (flags & VIR_PCI_CONNECT_AGGREGATE_SLOT && - bus->slot[searchAddr->slot].aggregate) { + if (bus->slot[searchAddr->slot].aggregateSlotIdx > 0 && + bus->slot[searchAddr->slot].aggregateSlotIdx =3D=3D aggreg= ateSlotIdx) { /* slot and device are okay with aggregating devices */ if ((bus->slot[searchAddr->slot].functions & (1 << searchAddr->function)) =3D=3D 0) { @@ -799,6 +808,7 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPt= r addrs, virPCIDeviceAddressPtr next_addr, virDomainPCIConnectFlags flags, unsigned int isolationGroup, + unsigned int aggregateSlotIdx, int function) { virPCIDeviceAddress a =3D { 0 }; @@ -827,7 +837,9 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPt= r addrs, =20 a.slot =3D bus->minSlot; =20 - if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function, + if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, + aggregateSlotIdx, + function, flags, &found) < 0)= { goto error; } @@ -851,7 +863,9 @@ virDomainPCIAddressGetNextAddr(virDomainPCIAddressSetPt= r addrs, =20 a.slot =3D bus->minSlot; =20 - if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, function, + if (virDomainPCIAddressFindUnusedFunctionOnBus(bus, &a, + aggregateSlotIdx, + function, flags, &found) < 0)= { goto error; } @@ -910,12 +924,13 @@ virDomainPCIAddressReserveNextAddr(virDomainPCIAddres= sSetPtr addrs, { virPCIDeviceAddress addr; =20 - if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags, - dev->isolationGroup, function) < 0) + if (virDomainPCIAddressGetNextAddr(addrs, &addr, flags, dev->isolation= Group, + dev->aggregateSlotIdx, function) < = 0) return -1; =20 if (virDomainPCIAddressReserveAddrInternal(addrs, &addr, flags, - dev->isolationGroup, false)= < 0) + dev->isolationGroup, + dev->aggregateSlotIdx, fals= e) < 0) return -1; =20 if (!addrs->dryRun) { diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index d3541bab09..fa98b67e5c 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -32,23 +32,18 @@ typedef enum { VIR_PCI_CONNECT_HOTPLUGGABLE =3D 1 << 0, /* is hotplug needed/supported= */ =20 - /* set for devices that can share a single slot in auto-assignment - * (by assigning one device to each of the 8 functions on the slot) - */ - VIR_PCI_CONNECT_AGGREGATE_SLOT =3D 1 << 1, - /* kinds of devices as a bitmap so they can be combined (some PCI * controllers permit connecting multiple types of devices) */ - VIR_PCI_CONNECT_TYPE_PCI_DEVICE =3D 1 << 2, - VIR_PCI_CONNECT_TYPE_PCIE_DEVICE =3D 1 << 3, - VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT =3D 1 << 4, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT =3D 1 << 5, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT =3D 1 << 6, - VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE =3D 1 << 7, - VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS =3D 1 << 8, - VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS =3D 1 << 9, - VIR_PCI_CONNECT_TYPE_PCI_BRIDGE =3D 1 << 10, + VIR_PCI_CONNECT_TYPE_PCI_DEVICE =3D 1 << 1, + VIR_PCI_CONNECT_TYPE_PCIE_DEVICE =3D 1 << 2, + VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT =3D 1 << 3, + VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT =3D 1 << 4, + VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT =3D 1 << 5, + VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE =3D 1 << 6, + VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS =3D 1 << 7, + VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS =3D 1 << 8, + VIR_PCI_CONNECT_TYPE_PCI_BRIDGE =3D 1 << 9, } virDomainPCIConnectFlags; =20 /* a combination of all bits that describe the type of connections @@ -81,12 +76,12 @@ typedef struct { */ uint8_t functions; =20 - /* aggregate is true if this slot has only devices with - * VIR_PCI_CONNECT_AGGREGATE assigned to its functions (meaning - * that other devices with the same flags could also be - * auto-assigned to the other functions) + /* aggregate is greater than zero if this slot has only devices with + * VIR_PCI_CONNECT_AGGREGATE assigned to its functions and + * that other devices with the same aggregateSlotIdx could also be + * auto-assigned to the other functions on this slot) */ - bool aggregate; + unsigned int aggregateSlotIdx; } virDomainPCIAddressSlot; =20 typedef struct { @@ -152,7 +147,8 @@ bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSe= tPtr addrs, int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags, - unsigned int isolationGroup) + unsigned int isolationGroup, + unsigned int aggregateSlotIdx) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int virDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5f4e8edd2c..424b56dac9 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -26,6 +26,7 @@ #include "qemu_domain_address.h" #include "qemu_domain.h" #include "viralloc.h" +#include "virhostdev.h" #include "virerror.h" #include "virlog.h" =20 @@ -1185,6 +1186,53 @@ qemuDomainSetupIsolationGroups(virDomainDefPtr def) } =20 =20 +void +qemuDomainSetDeviceSlotAggregateIdx(virDomainDefPtr def ATTRIBUTE_UNUSED, + virDomainDeviceDefPtr dev) +{ + virDomainDeviceInfoPtr info =3D virDomainDeviceGetInfo(dev); + + if (!info) + return; + + info->aggregateSlotIdx =3D 0; + + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER) { + virDomainControllerDefPtr cont =3D dev->data.controller; + if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && + cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT)= { + info->aggregateSlotIdx =3D 1; + } + } + + return; +} + + +static int +qemuDomainFillDeviceSlotAggregationIter(virDomainDefPtr def, + virDomainDeviceDefPtr dev, + virDomainDeviceInfoPtr info ATTRIB= UTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + qemuDomainSetDeviceSlotAggregateIdx(def, dev); + + return 0; +} + + +static int +qemuDomainSetupSlotAggregation(virDomainDefPtr def) +{ + if (virDomainDeviceInfoIterate(def, qemuDomainFillDeviceSlotAggregatio= nIter, + NULL) < 0) { + return -1; + } + + return 0; +} + + /** * qemuDomainFillDevicePCIConnectFlags: * @@ -1319,7 +1367,8 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRI= BUTE_UNUSED, =20 if (virDomainPCIAddressReserveAddr(addrs, addr, info->pciConnectFlags, - info->isolationGroup) < 0) { + info->isolationGroup, + info->aggregateSlotIdx) < 0) { goto cleanup; } =20 @@ -1480,7 +1529,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, continue; } if (addrs->nbuses && - virDomainPCIAddressReserveAddr(addrs, &cont->info.addr.pci, fl= ags, 0) < 0) + virDomainPCIAddressReserveAddr(addrs, &cont->info.addr.pci, fl= ags, 0, 0) < 0) goto cleanup; } =20 @@ -1489,11 +1538,11 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefP= tr def, memset(&tmp_addr, 0, sizeof(tmp_addr)); tmp_addr.slot =3D 1; /* ISA Bridge at 00:01.0 */ - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0, 0) = < 0) goto cleanup; /* Bridge at 00:01.3 */ tmp_addr.function =3D 3; - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0, 0) = < 0) goto cleanup; } =20 @@ -1528,7 +1577,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, goto cleanup; } } else { - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0, 0) < 0) goto cleanup; primaryVideo->info.addr.pci =3D tmp_addr; primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; @@ -1553,7 +1602,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, VIR_DEBUG("PCI address 0:0:2.0 in use, future addition of a vi= deo" " device will not be possible without manual" " intervention"); - } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0) < 0) { + } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0, 0) < 0) { goto cleanup; } } @@ -1629,7 +1678,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, assign =3D true; } if (assign) { - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0, 0) < 0) goto cleanup; =20 cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1652,7 +1701,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, memset(&tmp_addr, 0, sizeof(tmp_addr)); tmp_addr.slot =3D 0x1E; if (!virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0, 0) < 0) goto cleanup; =20 cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1676,12 +1725,12 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr= def, tmp_addr.slot =3D 0x1F; tmp_addr.function =3D 0; tmp_addr.multi =3D VIR_TRISTATE_SWITCH_ON; - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0, 0) = < 0) goto cleanup; =20 tmp_addr.function =3D 3; tmp_addr.multi =3D VIR_TRISTATE_SWITCH_ABSENT; - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0, 0) = < 0) goto cleanup; } =20 @@ -1715,7 +1764,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, goto cleanup; } } else { - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0) < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0, 0) < 0) goto cleanup; primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; primaryVideo->info.addr.pci =3D tmp_addr; @@ -1741,7 +1790,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, " device will not be possible without manual" " intervention"); virResetLastError(); - } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0) < 0) { + } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0, 0) < 0) { goto cleanup; } } @@ -1762,7 +1811,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, !virDeviceInfoPCIAddressWanted(&sound->info)) { continue; } - if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0)= < 0) + if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0,= 0) < 0) goto cleanup; =20 sound->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1967,7 +2016,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, /* Reserve this function on the slot we found */ if (virDomainPCIAddressReserveAddr(addrs, &addr, cont->info.pciConnectFl= ags, - cont->info.isolationGro= up) < 0) { + cont->info.isolationGro= up, + cont->info.aggregateSlo= tIdx) < 0) { goto error; } =20 @@ -2348,6 +2398,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, if (qemuDomainSetupIsolationGroups(def) < 0) goto cleanup; =20 + if (qemuDomainSetupSlotAggregation(def) < 0) + goto cleanup; + if (nbuses > 0) { /* 1st pass to figure out how many PCI bridges we need */ if (!(addrs =3D qemuDomainPCIAddressSetCreate(def, nbuses, true))) @@ -2463,6 +2516,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, dev.data.controller =3D def->controllers[contIndex]; /* set connect flags so it will be properly addressed */ qemuDomainFillDevicePCIConnectFlags(def, &dev, qemuCaps, drive= r); + qemuDomainSetDeviceSlotAggregateIdx(def, &dev); =20 /* Reserve an address for the controller. pci-root and pcie-ro= ot * controllers don't plug into any other PCI controller, hence @@ -2932,6 +2986,7 @@ qemuDomainEnsurePCIAddress(virDomainObjPtr obj, return 0; =20 qemuDomainFillDevicePCIConnectFlags(obj->def, dev, priv->qemuCaps, dri= ver); + qemuDomainSetDeviceSlotAggregateIdx(obj->def, dev); =20 return virDomainPCIAddressEnsureAddr(priv->pciaddrs, info, info->pciConnectFlags); diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 83f8e81cad..650f977cf7 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -55,6 +55,14 @@ int qemuDomainFillDeviceIsolationGroup(virDomainDefPtr d= ef, virDomainDeviceDefPtr dev) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +void +qemuDomainSetDeviceSlotAggregateIdx(virDomainDefPtr def, + virDomainDeviceDefPtr dev); +int +qemuDomainDefDeviceFindSlotAggregateIdx(virDomainDefPtr def, + virDomainDeviceDefPtr dev); + + void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, virDomainDeviceInfoPtr info, const char *devstr); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099130558963.9548303796805; Thu, 15 Mar 2018 00:32:10 -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 F241BC01F290; Thu, 15 Mar 2018 07:32:08 +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 BD4DF5D728; Thu, 15 Mar 2018 07:32:08 +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 6C14B4CAA4; Thu, 15 Mar 2018 07:32:08 +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 w2EHJwtL024685 for ; Wed, 14 Mar 2018 13:20:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id B2598620CA; Wed, 14 Mar 2018 17:19:58 +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 AADC36046B for ; Wed, 14 Mar 2018 17:19:55 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A3D0804E4 for ; Wed, 14 Mar 2018 17:19:53 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHEBi2032678 for ; Wed, 14 Mar 2018 13:19:52 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq7172s3s-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:19:52 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:19:50 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:19:49 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHJm8Y61931584 for ; Wed, 14 Mar 2018 17:19:48 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1251142049 for ; Wed, 14 Mar 2018 17:12:03 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 468AF42041 for ; Wed, 14 Mar 2018 17:12:02 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:12:01 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:49:46 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD793B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707EF8 Message-Id: <152104798353.10112.420755108578841493.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:19:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:19:53 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.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 Subject: [libvirt] [RFC PATCH 12/28] qemu: address: Enable auto addressing multifunction cards 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.31]); Thu, 15 Mar 2018 07:32:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For existing domains using the primary function alone of a multifunction ca= rd, the card is still treated as a multifunction card. This is done to prevent hotplug of other functions when the primary function is already hotplugged. If the secondary functions are part of the xml without the primary function being part of the xml, this has never been supported. So, the libvirt doesn= 't consider this either as a multifunction card. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_domain.h | 11 + src/qemu/qemu_domain_address.c | 169 ++++++++++++++++= +++- tests/qemuhotplugtest.c | 1=20 .../hostdev-pci-multifunction.args | 18 +- tests/qemuxml2argvdata/pseries-hostdevs-1.args | 5 - tests/qemuxml2argvdata/pseries-hostdevs-3.args | 5 - tests/qemuxml2argvtest.c | 5 - .../hostdev-pci-multifunction.xml | 16 +- tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml | 4=20 tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml | 4=20 10 files changed, 207 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 6d3e6eb5e3..fbfc994652 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -473,6 +473,17 @@ struct _qemuDomainSaveCookie { =20 qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm); =20 +typedef struct _qemuDomainPCIHostdevdata qemuDomainPCIHostdevdata; +typedef qemuDomainPCIHostdevdata *qemuDomainPCIHostdevDataPtr; +struct _qemuDomainPCIHostdevdata { + const virDomainDef *def; + virDomainPCIAddressSetPtr addrs; + virDomainHostdevDefPtr device; +}; + +typedef int (*virDomainPCIHostdevCallback)(qemuDomainPCIHostdevDataPtr dat= a, + virDomainHostdevDefPtr hostdev); + const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job, int phase); int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 424b56dac9..bc72b6e94c 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1186,11 +1186,155 @@ qemuDomainSetupIsolationGroups(virDomainDefPtr def) } =20 =20 +#define PCI_MAX_BRIDGE_NUMBER 0xff +#define PCI_MAX_DEVICES 32 + + +/** + * qemuDomainPCIHostDevicesIter: + * @data - The data->device is the one which is called-back with for + * each hostdev + * cb() - callback to be called for each hostdev + * Return : + * If the callback for any of the hostdev fails, the Iter returns + * with the return value for that callback. + * Zero on success. + */ +static +int qemuDomainPCIHostDevicesIter(qemuDomainPCIHostdevDataPtr data, + virDomainPCIHostdevCallback cb) +{ + size_t i; + int ret =3D -1; + + /* Iterate through the PCI Hostdevices, the Mdev source is of type + * UUID, so skip that. */ + for (i =3D 0; i < data->def->nhostdevs; i++) { + virDomainHostdevSubsysPtr subsys =3D &data->def->hostdevs[i]->sour= ce.subsys; + virDomainHostdevDefPtr hostdev =3D data->def->hostdevs[i]; + if (data->device =3D=3D hostdev) + continue; + if (data->def->hostdevs[i]->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBS= YS) + continue; + if (subsys->type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && + subsys->type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST && + (subsys->type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV && + subsys->u.mdev.model =3D=3D VIR_MDEV_MODEL_TYPE_VFIO_PCI)) { + continue; + } + + if ((ret =3D cb(data, hostdev)) !=3D 0) + return ret; + } + + return 0; +} + + + +static int +qemuDomainFindNextAggregationSlotIdxIter(virDomainDefPtr def ATTRIBUTE_UNU= SED, + virDomainDeviceDefPtr dev ATTRIBU= TE_UNUSED, + virDomainDeviceInfoPtr info, + void *opaque) +{ + int *aggregationSlotIdx =3D opaque; + + if (info && info->aggregateSlotIdx =3D=3D *aggregationSlotIdx) + return -1; + + return 0; +} + + +static unsigned int +qemuDomainFindNextSlotAggregationIdx(virDomainDefPtr def) +{ + int aggregateSlotIdx =3D 2; + + while (aggregateSlotIdx < PCI_MAX_BRIDGE_NUMBER * PCI_MAX_DEVICES && + virDomainDeviceInfoIterate(def, + qemuDomainFindNextAggregationSlotIdx= Iter, + &aggregateSlotIdx) < 0) { + aggregateSlotIdx++; + } + + return aggregateSlotIdx; +} + + +static int +qemuDomainDefHostdevGetSlotAggregateIdx(qemuDomainPCIHostdevDataPtr data, + virDomainHostdevDefPtr hostdev) +{ + if (data->device && + virHostdevPCIDevicesBelongToSameSlot(data->device, hostdev)) { + if (hostdev->info->aggregateSlotIdx > 0) + return hostdev->info->aggregateSlotIdx; + } + + return 0; +} + +/** + * qemuDomainDefDeviceFindSlotAggregateIdx: + * @def : domain def + * @dev : Find the slot aggregate for the device if other + * functions are already part of the def and have + * a slot aggreate idx assigned. + * Return: + * -1: if not assigned. + * 0: If the device is not a hostdev or not a + * multifunction device. + * >0: If assinged a value; + **/ +int +qemuDomainDefDeviceFindSlotAggregateIdx(virDomainDefPtr def, + virDomainDeviceDefPtr dev) +{ + int aggregateSlotIdx =3D 0; + virPCIDevicePtr pciDev; + virDomainHostdevDefPtr hostdev =3D dev->data.hostdev; + qemuDomainPCIHostdevdata temp =3D {def, NULL, hostdev}; + virPCIDeviceAddressPtr hostAddr =3D &hostdev->source.subsys.u.pci.addr; + + /* Only PCI host devices are subject to isolation */ + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PC= I) { + return 0; + } + + if (!(pciDev =3D virPCIDeviceNew(hostAddr->domain, + hostAddr->bus, + hostAddr->slot, + hostAddr->function))) { + /* 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 majority of host are non-multifunction, + * assume this one is too. + */ + return 0; + } + + if (!virPCIDeviceIsMultifunction(pciDev)) + return 0; + + aggregateSlotIdx =3D qemuDomainPCIHostDevicesIter(&temp, qemuDomainDef= HostdevGetSlotAggregateIdx); + if (aggregateSlotIdx > 0) + return aggregateSlotIdx; + + return -1; +} + + void -qemuDomainSetDeviceSlotAggregateIdx(virDomainDefPtr def ATTRIBUTE_UNUSED, +qemuDomainSetDeviceSlotAggregateIdx(virDomainDefPtr def, virDomainDeviceDefPtr dev) { virDomainDeviceInfoPtr info =3D virDomainDeviceGetInfo(dev); + int aggregateSlotIdx =3D 0; =20 if (!info) return; @@ -1203,6 +1347,12 @@ qemuDomainSetDeviceSlotAggregateIdx(virDomainDefPtr = def ATTRIBUTE_UNUSED, cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT)= { info->aggregateSlotIdx =3D 1; } + } else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) { + aggregateSlotIdx =3D qemuDomainDefDeviceFindSlotAggregateIdx(def, = dev); + if (aggregateSlotIdx > 0) + info->aggregateSlotIdx =3D aggregateSlotIdx; + else if (aggregateSlotIdx < 0) + info->aggregateSlotIdx =3D qemuDomainFindNextSlotAggregationId= x(def); } =20 return; @@ -2073,10 +2223,12 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, =20 /* Host PCI devices */ for (i =3D 0; i < def->nhostdevs; i++) { - virDomainHostdevSubsysPtr subsys =3D &def->hostdevs[i]->source.sub= sys; - if (!virDeviceInfoPCIAddressWanted(def->hostdevs[i]->info)) + int function =3D 0; + virDomainHostdevDefPtr hostdev =3D def->hostdevs[i]; + virDomainHostdevSubsysPtr subsys =3D &hostdev->source.subsys; + if (!virDeviceInfoPCIAddressWanted(hostdev->info)) continue; - if (def->hostdevs[i]->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) continue; if (subsys->type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && subsys->type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST && @@ -2085,9 +2237,14 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, continue; } =20 - if (qemuDomainPCIAddressReserveNextAddr(addrs, - def->hostdevs[i]->info) < = 0) + if (hostdev->info->aggregateSlotIdx > 1) + function =3D hostdev->source.subsys.u.pci.addr.function; + + if (virDomainPCIAddressReserveNextAddr(addrs, hostdev->info, + hostdev->info->pciConnectFl= ags, + function) < 0) { goto error; + } } =20 /* VirtIO balloon */ diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 31ce8d43b9..b5dca5e5c9 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -81,6 +81,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, 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); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); =20 diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.args b/tests/= qemuxml2argvdata/hostdev-pci-multifunction.args index 6b57f5713f..243ca8f2aa 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-multifunction.args +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.args @@ -19,11 +19,13 @@ server,nowait \ -no-acpi \ -boot c \ -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=3D06:12.1,id=3Dhostdev5,bus=3Dpci.0,addr=3D0x8 \ --device vfio-pci,host=3D06:12.2,id=3Dhostdev6,bus=3Dpci.0,addr=3D0x9 \ --device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0xa +-device vfio-pci,host=3D0005:90:01.0,id=3Dhostdev0,bus=3Dpci.0,multifuncti= on=3Don,\ +addr=3D0x3 \ +-device vfio-pci,host=3D0001:01:00.1,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4.= 0x1 \ +-device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev2,bus=3Dpci.0,multifuncti= on=3Don,\ +addr=3D0x4 \ +-device vfio-pci,host=3D0005:90:01.2,id=3Dhostdev3,bus=3Dpci.0,addr=3D0x3.= 0x2 \ +-device vfio-pci,host=3D0005:90:01.3,id=3Dhostdev4,bus=3Dpci.0,addr=3D0x3.= 0x3 \ +-device vfio-pci,host=3D06:12.1,id=3Dhostdev5,bus=3Dpci.0,addr=3D0x5 \ +-device vfio-pci,host=3D06:12.2,id=3Dhostdev6,bus=3Dpci.0,addr=3D0x6 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x7 diff --git a/tests/qemuxml2argvdata/pseries-hostdevs-1.args b/tests/qemuxml= 2argvdata/pseries-hostdevs-1.args index 8a4a4c5a63..6195350291 100644 --- a/tests/qemuxml2argvdata/pseries-hostdevs-1.args +++ b/tests/qemuxml2argvdata/pseries-hostdevs-1.args @@ -21,5 +21,6 @@ server,nowait \ -device spapr-pci-host-bridge,index=3D1,id=3Dpci.1 \ -device spapr-pci-host-bridge,index=3D2,id=3Dpci.2 \ -device vfio-pci,host=3D0005:90:01.0,id=3Dhostdev0,bus=3Dpci.1.0,addr=3D0x= 1 \ --device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev1,bus=3Dpci.2.0,addr=3D0x= 1 \ --device vfio-pci,host=3D0001:01:00.1,id=3Dhostdev2,bus=3Dpci.2.0,addr=3D0x2 +-device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev1,bus=3Dpci.2.0,multifunc= tion=3Don,\ +addr=3D0x1 \ +-device vfio-pci,host=3D0001:01:00.1,id=3Dhostdev2,bus=3Dpci.2.0,addr=3D0x= 1.0x1 diff --git a/tests/qemuxml2argvdata/pseries-hostdevs-3.args b/tests/qemuxml= 2argvdata/pseries-hostdevs-3.args index 66a31ba1a8..2e800574de 100644 --- a/tests/qemuxml2argvdata/pseries-hostdevs-3.args +++ b/tests/qemuxml2argvdata/pseries-hostdevs-3.args @@ -20,5 +20,6 @@ server,nowait \ -boot c \ -device spapr-pci-host-bridge,index=3D1,id=3Dpci.1 \ -device spapr-pci-host-bridge,index=3D2,id=3Dpci.2 \ --device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev0,bus=3Dpci.2.0,addr=3D0x= 1 \ --device vfio-pci,host=3D0001:01:00.1,id=3Dhostdev1,bus=3Dpci.2.0,addr=3D0x2 +-device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev0,bus=3Dpci.2.0,multifunc= tion=3Don,\ +addr=3D0x1 \ +-device vfio-pci,host=3D0001:01:00.1,id=3Dhostdev1,bus=3Dpci.2.0,addr=3D0x= 1.0x1 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1e00eb167a..583598dfec 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1607,7 +1607,8 @@ mymain(void) DO_TEST("hostdev-pci-multifunction", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_VFIO_PCI, - QEMU_CAPS_HOST_PCI_MULTIDOMAIN, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_HOST_PCI_MULTIDOMAIN, QEMU_CAPS_PCI_MULTIFUNCTION); DO_TEST("hostdev-mdev-precreated", QEMU_CAPS_NODEFCONFIG, @@ -1905,6 +1906,7 @@ mymain(void) QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_HOST_PCI_MULTIDOMAIN, + QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("pseries-hostdevs-2", @@ -1918,6 +1920,7 @@ mymain(void) QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_HOST_PCI_MULTIDOMAIN, QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DEVICE_VFIO_PCI); =20 DO_TEST("pseries-features-hpt", diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml b/tests= /qemuxml2xmloutdata/hostdev-pci-multifunction.xml index 52ed86e305..3396a73cf8 100644 --- a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml +++ b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml @@ -28,52 +28,52 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml b/tests/qemuxm= l2xmloutdata/pseries-hostdevs-1.xml index e77a060a38..c09588de9d 100644 --- a/tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml +++ b/tests/qemuxml2xmloutdata/pseries-hostdevs-1.xml @@ -40,14 +40,14 @@
-
+
-
+
diff --git a/tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml b/tests/qemuxm= l2xmloutdata/pseries-hostdevs-3.xml index f91959b805..f01adf6d25 100644 --- a/tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml +++ b/tests/qemuxml2xmloutdata/pseries-hostdevs-3.xml @@ -32,14 +32,14 @@
-
+
-
+
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099397923588.7953481531927; Thu, 15 Mar 2018 00:36:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EAEA42BBF; Thu, 15 Mar 2018 07:36:36 +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 39E665D757; Thu, 15 Mar 2018 07:36:36 +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 EEF43180BADA; Thu, 15 Mar 2018 07:36:35 +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 w2EHKAGX024705 for ; Wed, 14 Mar 2018 13:20:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F8AB5D72A; Wed, 14 Mar 2018 17:20:10 +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 34C645D724 for ; Wed, 14 Mar 2018 17:20:04 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F24EB80F8D for ; Wed, 14 Mar 2018 17:20:03 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHEDvr110737 for ; Wed, 14 Mar 2018 13:20:03 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq4phsyfu-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:20:03 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:20:01 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:20:00 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHJxap55181404 for ; Wed, 14 Mar 2018 17:19:59 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A09911C04C for ; Wed, 14 Mar 2018 17:12:38 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C52F11C04A for ; Wed, 14 Mar 2018 17:12:37 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:12:37 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:49:57 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0020-0000-0000-000004047B33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0021-0000-0000-00004298803B Message-Id: <152104799398.10112.7187116303201817433.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:20:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:20:04 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 13/28] util: make virHostdevIsVirtualFunction() public 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 15 Mar 2018 07:36:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function will be useful in qemu_domain_address.c, so promote it from static. Signed-off-by: Shivaprasad G Bhat --- src/libvirt_private.syms | 1 + src/util/virhostdev.c | 2 +- src/util/virhostdev.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 68b648ba31..b092c240d8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1918,6 +1918,7 @@ virHostdevFindUSBDevice; virHostdevHostSupportsPassthroughKVM; virHostdevHostSupportsPassthroughVFIO; virHostdevIsSCSIDevice; +virHostdevIsVirtualFunction; virHostdevManagerGetDefault; virHostdevPCIDevicesBelongToSameSlot; virHostdevPCINodeDeviceDetach; diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 9508a29954..454ae3568c 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -289,7 +289,7 @@ virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev, } =20 =20 -static int +int virHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev) { char *sysfs_path =3D NULL; diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index ded7620355..d696b5fdcc 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -196,6 +196,9 @@ virHostdevReAttachDomainDevices(virHostdevManagerPtr mg= r, bool virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev) ATTRIBUTE_NONNULL(1); +int +virHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev) + ATTRIBUTE_NONNULL(1); =20 /* functions used by NodeDevDetach/Reattach/Reset */ int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr, -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152109912318566.81115845993008; Thu, 15 Mar 2018 00:32:03 -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 A5FED7E9DC; Thu, 15 Mar 2018 07:32:01 +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 4E8225D729; Thu, 15 Mar 2018 07:32: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 15933180BAD9; Thu, 15 Mar 2018 07:32:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHKqdF024756 for ; Wed, 14 Mar 2018 13:21:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 75E5D5E1B9; Wed, 14 Mar 2018 17:20:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FF815C552 for ; Wed, 14 Mar 2018 17:20:49 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E5CEC057FA1 for ; Wed, 14 Mar 2018 17:20:48 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKNoO137496 for ; Wed, 14 Mar 2018 13:20:47 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5b88c55-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:20:47 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:20:25 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:20:23 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHKNCw42467526 for ; Wed, 14 Mar 2018 17:20:23 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21E84AE04D for ; Wed, 14 Mar 2018 17:10:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66470AE045 for ; Wed, 14 Mar 2018 17:10:49 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:10:49 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:50:21 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD794E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707F0B Message-Id: <152104800524.10112.12656969925367084863.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:20:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:20:48 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 14/28] conf: qemu: validate multifunction hostdevice domain configs 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.26]); Thu, 15 Mar 2018 07:32:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It is invalid to have secondary functions without the primary functions part of the domain. Prevents new domain define, but existing ones would not vanish. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_domain.c | 3 + src/qemu/qemu_domain_address.c | 57 ++++++++++++++++= ++++ src/qemu/qemu_domain_address.h | 2 + .../hostdev-pci-no-primary-function.xml | 23 ++++++++ tests/qemuxml2argvdata/hostdev-pci-validate.args | 25 +++++++++ tests/qemuxml2argvdata/hostdev-pci-validate.xml | 29 ++++++++++ tests/qemuxml2argvtest.c | 9 +++ 7 files changed, 148 insertions(+) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-no-primary-function.= xml create mode 100644 tests/qemuxml2argvdata/hostdev-pci-validate.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-validate.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2d108bec1b..12ed68a89b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3565,6 +3565,9 @@ qemuDomainDefValidate(const virDomainDef *def, if (qemuDomainDefValidateFeatures(def) < 0) goto cleanup; =20 + if (qemuDomainDefValidatePCIHostdevs(def) < 0) + goto cleanup; + ret =3D 0; =20 cleanup: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bc72b6e94c..7bee4fb937 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1996,6 +1996,63 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDe= fPtr def, } =20 =20 +static int +qemuDomainDefPCIHostdevIsPrimaryFunction(qemuDomainPCIHostdevDataPtr data, + virDomainHostdevDefPtr hostdev) +{ + if (!data->device || !hostdev) + return 0; + + if ((hostdev->source.subsys.u.pci.addr.function =3D=3D 0) && + (virHostdevPCIDevicesBelongToSameSlot(data->device, hostdev))) + return 1; + + return 0; +} + + +static int qemuDomainDefValidatePCIMultifunctionHostdev(qemuDomainPCIHostd= evDataPtr data, + virDomainHostdevDe= fPtr hostdev) +{ + int ret =3D 0; + qemuDomainPCIHostdevdata hostdevIterData =3D {data->def, NULL, hostdev= }; + + if (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PC= I || + hostdev->source.subsys.u.pci.addr.function =3D=3D 0) + goto skip; + + if (virHostdevIsVirtualFunction(hostdev)) + goto skip; + + /* If the device is non-zero function but its Primary function is not + * part of the domain, then error out. + */ + if (!qemuDomainPCIHostDevicesIter(&hostdevIterData, + qemuDomainDefPCIHostdevIsPrimaryFunc= tion)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Secondary functions of a PCI multifunction card " + "cannot be assigned to a domain without the " + "Primary function.")); + ret =3D -1; + } + + skip: + return ret; +} + +int qemuDomainDefValidatePCIHostdevs(const virDomainDef *def) +{ + qemuDomainPCIHostdevdata hostdevdata =3D {def, NULL, NULL}; + + if (qemuDomainPCIHostDevicesIter(&hostdevdata, + qemuDomainDefValidatePCIMultifunction= Hostdev)) { + return -1; + } + + return 0; +} + + /* * This assigns static PCI slots to all configured devices. * The ordering here is chosen to match the ordering used diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 650f977cf7..e1cc467714 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -62,6 +62,8 @@ int qemuDomainDefDeviceFindSlotAggregateIdx(virDomainDefPtr def, virDomainDeviceDefPtr dev); =20 +int qemuDomainDefValidatePCIHostdevs(const virDomainDef *def); + =20 void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, virDomainDeviceInfoPtr info, diff --git a/tests/qemuxml2argvdata/hostdev-pci-no-primary-function.xml b/t= ests/qemuxml2argvdata/hostdev-pci-no-primary-function.xml new file mode 100644 index 0000000000..7106ab73b1 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-no-primary-function.xml @@ -0,0 +1,23 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 4 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + diff --git a/tests/qemuxml2argvdata/hostdev-pci-validate.args b/tests/qemux= ml2argvdata/hostdev-pci-validate.args new file mode 100644 index 0000000000..bda8cab6c9 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-validate.args @@ -0,0 +1,25 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name delete \ +-S \ +-M pc \ +-m 256 \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \ +-nographic \ +-nodefconfig \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-delete/monitor.= sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-usb \ +-device vfio-pci,host=3D06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D06:12.2,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 diff --git a/tests/qemuxml2argvdata/hostdev-pci-validate.xml b/tests/qemuxm= l2argvdata/hostdev-pci-validate.xml new file mode 100644 index 0000000000..54797c2dda --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-validate.xml @@ -0,0 +1,29 @@ + + 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 583598dfec..659f20cb28 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1610,6 +1610,15 @@ mymain(void) QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, QEMU_CAPS_HOST_PCI_MULTIDOMAIN, QEMU_CAPS_PCI_MULTIFUNCTION); + DO_TEST("hostdev-pci-validate", + QEMU_CAPS_KVM, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_HOST_PCI_MULTIDOMAIN, + QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST_PARSE_ERROR("hostdev-pci-no-primary-function", + QEMU_CAPS_KVM, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_HOST_PCI_MULTIDOMAIN, + QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST("hostdev-mdev-precreated", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099410240417.30422225013683; Thu, 15 Mar 2018 00:36:50 -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 ED60723E6E7; Thu, 15 Mar 2018 07:36:48 +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 A62AA17243; Thu, 15 Mar 2018 07:36:48 +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 62E054CAA9; Thu, 15 Mar 2018 07:36:48 +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 w2EHKh1Y024740 for ; Wed, 14 Mar 2018 13:20:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B2C2601A7; Wed, 14 Mar 2018 17:20:43 +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 94FED60476 for ; Wed, 14 Mar 2018 17:20:40 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A70A780511 for ; Wed, 14 Mar 2018 17:20:39 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKStG079660 for ; Wed, 14 Mar 2018 13:20:39 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq5bd08dn-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:20:38 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:20:36 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:20:35 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHKYiV55050266 for ; Wed, 14 Mar 2018 17:20:34 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09EF411C058 for ; Wed, 14 Mar 2018 17:13:13 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4762211C050 for ; Wed, 14 Mar 2018 17:13:12 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:13:12 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:50:32 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0016-0000-0000-00000532795A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0017-0000-0000-0000286F7F0D Message-Id: <152104802879.10112.1194295592019802232.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:20:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:20:39 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.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 Subject: [libvirt] [RFC PATCH 15/28] conf: Add helper to get active functions of a slot of domain 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.29]); Thu, 15 Mar 2018 07:36:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In some cases it may be better to have a bitmap representing state of individual functions rather than iterating the definition. The new helper creates a bitmap representing the state from the domain definition. Signed-off-by: Shivaprasad G Bhat --- src/conf/domain_conf.c | 25 +++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 29 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86fc275116..3deed8eb4d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16146,6 +16146,31 @@ virDomainHostdevFind(virDomainDefPtr def, return *found ? i : -1; } =20 +#define PCI_MAX_SLOT_FUNCTIONS 8 +/** + * virDomainDefHostdevGetPCIOnlineFunctionMap: + * @def: domain definition + * @aggrSlotIdx: slot aggregation index + * Returns a bitmap representing state of individual functions of a slot. + */ +virBitmapPtr +virDomainDefHostdevGetPCIOnlineFunctionMap(virDomainDefPtr def, + int aggrSlotIdx) +{ + size_t i; + virBitmapPtr ret =3D NULL; + + if (!(ret =3D virBitmapNew(PCI_MAX_SLOT_FUNCTIONS))) + return NULL; + + for (i =3D 0; i < def->nhostdevs; i++) { + if (def->hostdevs[i]->info->aggregateSlotIdx =3D=3D aggrSlotIdx) + ignore_value(virBitmapSetBit(ret, def->hostdevs[i]->source.sub= sys.u.pci.addr.function)); + } + + return ret; +} + static bool virDomainDiskControllerMatch(int controller_type, int disk_bus) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 61379e50fe..a3d686a5ca 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3067,6 +3067,9 @@ virDomainHostdevDefPtr virDomainHostdevRemove(virDomainDefPtr def, size_t i); int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match, virDomainHostdevDefPtr *found); +virBitmapPtr virDomainDefHostdevGetPCIOnlineFunctionMap(virDomainDefPtr de= f, + int aggrSlotIdx); + =20 virDomainGraphicsListenDefPtr virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b092c240d8..b0e8f2ca61 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -278,6 +278,7 @@ virDomainDefHasMemballoon; virDomainDefHasMemoryHotplug; virDomainDefHasUSB; virDomainDefHasVcpusOffline; +virDomainDefHostdevGetPCIOnlineFunctionMap; virDomainDefLifecycleActionAllowed; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099115947504.62796831477146; Thu, 15 Mar 2018 00:31:55 -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 AD473C20B4C6; Thu, 15 Mar 2018 07:31:54 +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 7D78D60BB6; Thu, 15 Mar 2018 07:31:54 +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 21C6C180BAD7; Thu, 15 Mar 2018 07:31:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHKunE024762 for ; Wed, 14 Mar 2018 13:21:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D11B5C552; Wed, 14 Mar 2018 17:20:56 +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 45E1B5F703 for ; Wed, 14 Mar 2018 17:20:56 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5CF5B804F4 for ; Wed, 14 Mar 2018 17:20:55 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKV5K054877 for ; Wed, 14 Mar 2018 13:20:54 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq7172tb6-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:20:54 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:20:52 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:20:50 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHKoUW57016550 for ; Wed, 14 Mar 2018 17:20:50 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84EA15203F for ; Wed, 14 Mar 2018 16:12:20 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id CDB8E52041 for ; Wed, 14 Mar 2018 16:12:19 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:50:48 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-000004407932 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000020E37EFD Message-Id: <152104804006.10112.16370642138573819933.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:20:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Mar 2018 17:20:55 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 16/28] qemu: hostdev: Move the hostdev preparation to a separate function 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.32]); Thu, 15 Mar 2018 07:31:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" No functional change. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_hotplug.c | 90 +++++++++++++++++++++++++++++--------------= ---- src/qemu/qemu_hotplug.h | 5 +++ 2 files changed, 60 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e0a5300f08..1bf87d963e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -688,6 +688,57 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr = driver, return 0; } =20 +int qemuDomainAttachPCIHostDevicePrepare(virQEMUDriverPtr driver, + virDomainDefPtr def, + virDomainHostdevDefPtr hostdev, + virQEMUCapsPtr qemuCaps) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + unsigned int flags =3D 0; + int ret =3D -1; + int backend; + + if (!cfg->relaxedACS) + flags |=3D VIR_HOSTDEV_STRICT_ACS_CHECK; + if (qemuHostdevPreparePCIDevices(driver, def->name, def->uuid, + &hostdev, 1, qemuCaps, flags) < 0) + goto exit; + + /* this could have been changed by qemuHostdevPreparePCIDevices */ + backend =3D hostdev->source.subsys.u.pci.backend; + + switch ((virDomainHostdevSubsysPCIBackendType) backend) { + case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VFIO PCI device assignment is not " + "supported by this version of qemu")); + goto error; + } + break; + + case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: + case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: + break; + + case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN: + case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("QEMU does not support device assignment mode '%s= '"), + virDomainHostdevSubsysPCIBackendTypeToString(backen= d)); + goto error; + break; + } + + ret =3D 0; + exit: + virObjectUnref(cfg); + return ret; + error: + qemuHostdevReAttachPCIDevices(driver, def->name, &hostdev, 1); + goto exit; +} + =20 int qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver, @@ -1257,44 +1308,16 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driv= er, bool teardownlabel =3D false; bool teardowndevice =3D false; int backend; - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); - unsigned int flags =3D 0; =20 if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) - goto cleanup; + return -1; =20 - if (!cfg->relaxedACS) - flags |=3D VIR_HOSTDEV_STRICT_ACS_CHECK; - if (qemuHostdevPreparePCIDevices(driver, vm->def->name, vm->def->uuid, - &hostdev, 1, priv->qemuCaps, flags) <= 0) - goto cleanup; + if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, + hostdev, priv->qemuCaps) < 0) + return -1; =20 - /* this could have been changed by qemuHostdevPreparePCIDevices */ backend =3D hostdev->source.subsys.u.pci.backend; =20 - switch ((virDomainHostdevSubsysPCIBackendType) backend) { - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: - if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("VFIO PCI device assignment is not " - "supported by this version of qemu")); - goto error; - } - break; - - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: - break; - - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN: - case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("QEMU does not support device assignment mode '%s= '"), - virDomainHostdevSubsysPCIBackendTypeToString(backen= d)); - goto error; - break; - } - /* Temporarily add the hostdev to the domain definition. This is needed * because qemuDomainAdjustMaxMemLock() requires the hostdev to be alr= eady * part of the domain definition, but other functions like @@ -1366,7 +1389,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, VIR_FREE(devstr); VIR_FREE(configfd_name); VIR_FORCE_CLOSE(configfd); - virObjectUnref(cfg); =20 return 0; =20 @@ -1389,8 +1411,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, VIR_FREE(configfd_name); VIR_FORCE_CLOSE(configfd); =20 - cleanup: - virObjectUnref(cfg); return -1; } =20 diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index b2f5fa688b..db0e1df79a 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -154,6 +154,11 @@ void qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *alias); =20 +int qemuDomainAttachPCIHostDevicePrepare(virQEMUDriverPtr driver, + virDomainDefPtr def, + virDomainHostdevDefPtr dev, + virQEMUCapsPtr qemuCaps); + int qemuDomainChrInsert(virDomainDefPtr vmdef, virDomainChrDefPtr chr); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099413244299.79113495625734; Thu, 15 Mar 2018 00:36:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAC4F445E3; Thu, 15 Mar 2018 07:36:51 +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 B4A915D755; Thu, 15 Mar 2018 07:36:51 +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 763F34CAAB; Thu, 15 Mar 2018 07:36:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHLAjO024781 for ; Wed, 14 Mar 2018 13:21:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB2C15F71D; Wed, 14 Mar 2018 17:21:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D51395E1B9 for ; Wed, 14 Mar 2018 17:21:08 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D6D5C058EB0 for ; Wed, 14 Mar 2018 17:21:07 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKOrs054282 for ; Wed, 14 Mar 2018 13:21:06 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq7172tjx-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:21:06 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:21:04 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:21:03 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHL20U50724916 for ; Wed, 14 Mar 2018 17:21:02 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB72052047 for ; Wed, 14 Mar 2018 16:12:32 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 418CD5204F for ; Wed, 14 Mar 2018 16:12:30 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:50:58 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0012-0000-0000-000005BE7851 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0013-0000-0000-0000193A7E34 Message-Id: <152104805572.10112.2044180540428078854.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:21:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:21:07 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 17/28] qemu: hotplug: Move the detach of PCI device to the beginnging of live 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 15 Mar 2018 07:36:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The hostdevices are the only devices which have dependencies outside of themselves such that, other functions of the PCI card should also have been detached from host driver before attempting the hotplug. This patch moves the detach to the beginning of the hotplug so that the following patch can detach all funtions first before attempting to hotplug any. We need not move the detach for net devices using SRIOV as all SRIOV devices are single function devices and can be independently detached as usual. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_hotplug.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1bf87d963e..214e169980 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -888,6 +888,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, bool charDevPlugged =3D false; bool netdevPlugged =3D false; bool hostPlugged =3D false; + virDomainHostdevDefPtr hostdev =3D NULL; =20 /* preallocate new slot for device */ if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) @@ -998,9 +999,16 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, * as a hostdev (the hostdev code will reach over into the * netdev-specific code as appropriate), then also added to * the nets list (see cleanup:) if successful. + * + * qemuDomainAttachHostDevice uses a connection to resolve + * a SCSI hostdev secret, which is not this case, so pass NULL. */ - ret =3D qemuDomainAttachHostDevice(driver, vm, - virDomainNetGetActualHostdev(net)= ); + hostdev =3D virDomainNetGetActualHostdev(net); + if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, + hostdev, priv->qemuCaps) = < 0) + goto cleanup; + if ((ret =3D qemuDomainAttachHostDevice(driver, vm, hostdev)) < 0) + qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev,= 1); goto cleanup; break; =20 @@ -1312,10 +1320,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr drive= r, if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) return -1; =20 - if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, - hostdev, priv->qemuCaps) < 0) - return -1; - backend =3D hostdev->source.subsys.u.pci.backend; =20 /* Temporarily add the hostdev to the domain definition. This is needed @@ -1405,8 +1409,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, info, NULL); =20 - qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1); - VIR_FREE(devstr); VIR_FREE(configfd_name); VIR_FORCE_CLOSE(configfd); @@ -2588,6 +2590,8 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("hotplug is not supported for hostdev mode '%s'"), @@ -2597,9 +2601,14 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver, =20 switch (hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, + hostdev, priv->qemuCaps) = < 0) + goto error; if (qemuDomainAttachHostPCIDevice(driver, vm, - hostdev) < 0) + hostdev) < 0) { + qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev,= 1); goto error; + } break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099190328974.4086630945557; Thu, 15 Mar 2018 00:33:10 -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 E72A2800AF; Thu, 15 Mar 2018 07:33:08 +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 B55615C1AB; Thu, 15 Mar 2018 07:33:08 +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 79B7E3FC6E; Thu, 15 Mar 2018 07:33:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHLLbk024788 for ; Wed, 14 Mar 2018 13:21:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id B906E5C542; Wed, 14 Mar 2018 17:21:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B35875C25E for ; Wed, 14 Mar 2018 17:21:21 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB41FC0587E8 for ; Wed, 14 Mar 2018 17:21:20 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKNlV056961 for ; Wed, 14 Mar 2018 13:21:20 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq67xd8td-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:21:19 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:21:18 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:21:15 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHLFNb393512 for ; Wed, 14 Mar 2018 17:21:15 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5A4C4C046 for ; Wed, 14 Mar 2018 17:14:29 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 626524C040 for ; Wed, 14 Mar 2018 17:14:29 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:14:29 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:51:13 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-00000440793E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000020E37F0A Message-Id: <152104806813.10112.13942579251963623779.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:21:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:21:20 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 18/28] qemu: hotplug: move assignment outside qemuDomainAttachHostPCIDevice 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.28]); Thu, 15 Mar 2018 07:33:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" No functional change. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_hotplug.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 214e169980..007ecb0923 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1304,14 +1304,11 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driv= er, virDomainHostdevDefPtr hostdev) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_HOSTDEV, - { .hostdev =3D hostdev } }; virDomainDeviceInfoPtr info =3D hostdev->info; int ret; char *devstr =3D NULL; int configfd =3D -1; char *configfd_name =3D NULL; - bool releaseaddr =3D false; bool teardowncgroup =3D false; bool teardownlabel =3D false; bool teardowndevice =3D false; @@ -1350,15 +1347,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr drive= r, if (qemuAssignDeviceHostdevAlias(vm->def, &info->alias, -1) < 0) goto error; =20 - if (qemuDomainIsPSeries(vm->def)) { - /* Isolation groups are only relevant for pSeries guests */ - if (qemuDomainFillDeviceIsolationGroup(vm->def, &dev) < 0) - goto error; - } - - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) - goto error; - releaseaddr =3D true; if (backend !=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PCI_CONFIGFD)) { configfd =3D qemuOpenPCIConfig(hostdev); @@ -1406,9 +1394,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, qemuDomainNamespaceTeardownHostdev(vm, hostdev) < 0) VIR_WARN("Unable to remove host device from /dev"); =20 - if (releaseaddr) - qemuDomainReleaseDeviceAddress(vm, info, NULL); - VIR_FREE(devstr); VIR_FREE(configfd_name); VIR_FORCE_CLOSE(configfd); @@ -2591,6 +2576,8 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver, virDomainHostdevDefPtr hostdev) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_HOSTDEV, + { .hostdev =3D hostdev } }; =20 if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2604,8 +2591,19 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver, if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, hostdev, priv->qemuCaps) = < 0) goto error; + + if (qemuDomainIsPSeries(vm->def)) { + /* Isolation groups are only relevant for pSeries guests */ + if (qemuDomainFillDeviceIsolationGroup(vm->def, &dev) < 0) + goto error; + } + + if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) + goto error; + if (qemuDomainAttachHostPCIDevice(driver, vm, hostdev) < 0) { + qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL); qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev,= 1); goto error; } -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099195988738.1189691957596; Thu, 15 Mar 2018 00:33:15 -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 A7DAD46668; Thu, 15 Mar 2018 07:33:14 +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 7FC62620A0; Thu, 15 Mar 2018 07:33:14 +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 44865181BA11; Thu, 15 Mar 2018 07:33:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHLo93025144 for ; Wed, 14 Mar 2018 13:22:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB69A5E1B9; Wed, 14 Mar 2018 17:21:50 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2F835C552 for ; Wed, 14 Mar 2018 17:21:48 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4BFAC058EB0 for ; Wed, 14 Mar 2018 17:21:46 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKRj3023557 for ; Wed, 14 Mar 2018 13:21:46 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq446444a-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:21:45 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:21:44 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:21:41 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHLeBT65994788 for ; Wed, 14 Mar 2018 17:21:40 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 517384C044 for ; Wed, 14 Mar 2018 17:14:55 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA1C04C04A for ; Wed, 14 Mar 2018 17:14:54 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:14:54 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:51:38 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD796B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707F2A Message-Id: <152104808071.10112.13304848195442484697.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:21:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Mar 2018 17:21:46 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 19/28] Introduce virDomainDeviceDefParseXMLMany 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.30]); Thu, 15 Mar 2018 07:33:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/conf/domain_conf.c | 169 ++++++++++++++++++++++++++++++++++++++++--= ---- src/conf/domain_conf.h | 36 ++++++++++ src/libvirt_private.syms | 6 ++ 3 files changed, 190 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3deed8eb4d..5f4a5127d4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -963,6 +963,83 @@ virDomainXMLOptionClassDispose(void *obj) (xmlopt->config.privFree)(xmlopt->config.priv); } =20 +/* virDomainDeviceDefListAddCopy - add a *copy* of the device to this list= */ +int +virDomainDeviceDefListAddCopy(virDomainDeviceDefListPtr list, + virDomainDeviceDefPtr dev, + virDomainDeviceDefListDataPtr data) +{ + virDomainDeviceDefPtr copy =3D virDomainDeviceDefCopy(dev, data->def, = data->caps, data->xmlopt); + + if (!copy) + return -1; + if (VIR_APPEND_ELEMENT(list->devs, list->count, copy) < 0) { + virDomainDeviceDefFree(copy); + return -1; + } + return 0; +} + +void virDomainDeviceDefListFree(virDomainDeviceDefListPtr list) +{ + size_t i; + + if (!list) + return; + for (i =3D 0; i < list->count; i++) + virDomainDeviceDefFree(list->devs[i]); + VIR_FREE(list->devs); +} + +void virDomainDeviceDefListFreeShallow(virDomainDeviceDefListPtr list) +{ + size_t i; + + if (!list) + return; + for (i =3D 0; i < list->count; i++) + VIR_FREE(list->devs[i]); +} + + +/* virDomainDeviceDefListIter - Iterate through the list with the callback= */ +int +virDomainDeviceDefListIterate(virDomainDeviceDefListPtr list, + virDomainDeviceDefListIterCallback cb, + void *data) +{ + size_t i; + + for (i =3D 0; i < list->count; i++) + if (cb(list->devs[i], data)) + return -1; + + return 0; +} + +virDomainDeviceDefListPtr +virDomainDeviceDefListCopy(virDomainDeviceDefListPtr list, + virDomainDeviceDefListDataPtr data) +{ + size_t i; + virDomainDeviceDefListPtr devlist =3D NULL; + + if (list && (VIR_ALLOC(devlist) < 0)) + goto cleanup; + + for (i =3D 0; i < list->count; i++) { + if (virDomainDeviceDefListAddCopy(devlist, list->devs[i], data) < = 0) + goto cleanup; + } + + return devlist; + cleanup: + virDomainDeviceDefListFree(devlist); + return NULL; +} + + + /** * virDomainKeyWrapCipherDefParseXML: * @@ -15677,25 +15754,16 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, return ret; } =20 - -virDomainDeviceDefPtr -virDomainDeviceDefParse(const char *xmlStr, - const virDomainDef *def, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +static +virDomainDeviceDefPtr virDomainDeviceDefParseXML(xmlNodePtr node, + const virDomainDef *def, + virCapsPtr caps, + virDomainXMLOptionPtr xml= opt, + xmlXPathContextPtr ctxt, + unsigned int flags) { - xmlDocPtr xml; - xmlNodePtr node; - xmlXPathContextPtr ctxt =3D NULL; virDomainDeviceDefPtr dev =3D NULL; char *netprefix; - - if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(device_definition)"), = &ctxt))) - goto error; - - node =3D ctxt->node; - if (VIR_ALLOC(dev) < 0) goto error; =20 @@ -15846,14 +15914,33 @@ virDomainDeviceDefParse(const char *xmlStr, if (virDomainDeviceDefValidate(dev, def, flags, xmlopt) < 0) goto error; =20 - cleanup: + return dev; + error: + return NULL; +} + +virDomainDeviceDefPtr +virDomainDeviceDefParse(const char *xmlStr, + const virDomainDef *def, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + xmlDocPtr xml; + xmlNodePtr node; + xmlXPathContextPtr ctxt =3D NULL; + virDomainDeviceDefPtr dev =3D NULL; + + if (!(xml =3D virXMLParseStringCtxt(xmlStr, _("(device_definition)"), = &ctxt))) + return NULL; + + node =3D ctxt->node; + + dev =3D virDomainDeviceDefParseXML(node, def, caps, xmlopt, ctxt, flag= s); + xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); return dev; - - error: - VIR_FREE(dev); - goto cleanup; } =20 =20 @@ -29394,3 +29481,43 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefP= tr def) virStoragePoolDefFree(pooldef); return ret; } + +virDomainDeviceDefListPtr +virDomainDeviceDefParseXMLMany(const char *xml, + const virDomainDef *def, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + xmlXPathContextPtr ctxt =3D NULL; + xmlDocPtr xmlPtr; + xmlNodePtr node, root; + virDomainDeviceDefPtr dev =3D NULL; + virDomainDeviceDefListPtr devlist; + + if (!(xmlPtr =3D virXMLParseStringCtxt(xml, _("(device_definition)"), = &ctxt))) + return NULL; + + if (VIR_ALLOC(devlist) < 0) + goto exit; + + root =3D xmlDocGetRootElement(xmlPtr); + node =3D root->children; + while (node) { + if (node->type =3D=3D XML_ELEMENT_NODE) { + dev =3D virDomainDeviceDefParseXML(node, def, caps, xmlopt, ct= xt, flags); + if (VIR_APPEND_ELEMENT(devlist->devs, devlist->count, dev) < 0= ) { + virDomainDeviceDefFree(dev); + virDomainDeviceDefListFree(devlist); + goto exit; + } + dev =3D NULL; + } + node =3D node->next; + } + + exit: + xmlFreeDoc(xmlPtr); + xmlXPathFreeContext(ctxt); + return devlist; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a3d686a5ca..828fe9f6d8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2561,6 +2561,37 @@ typedef int (*virDomainDefPostParseBasicCallback)(vi= rDomainDefPtr def, virCapsPtr caps, void *opaque); =20 +typedef struct _virDomainDeviceDefListData virDomainDeviceDefListData; +typedef virDomainDeviceDefListData *virDomainDeviceDefListDataPtr; +struct _virDomainDeviceDefListData { + const virDomainDef *def; + virCapsPtr caps; + virDomainXMLOptionPtr xmlopt; +}; + +struct virDomainDeviceDefList { + virDomainDeviceDefPtr *devs; + size_t count; +}; +typedef struct virDomainDeviceDefList *virDomainDeviceDefListPtr; + +typedef int (*virDomainDeviceDefListIterCallback)(virDomainDeviceDefPtr de= v, + void *opaque); +int virDomainDeviceDefListIterate(virDomainDeviceDefListPtr devlist, + virDomainDeviceDefListIterCallback cb, + void *data); +int +virDomainDeviceDefListAddCopy(virDomainDeviceDefListPtr list, + virDomainDeviceDefPtr dev, + virDomainDeviceDefListDataPtr data); +virDomainDeviceDefListPtr +virDomainDeviceDefListCopy(virDomainDeviceDefListPtr list, + virDomainDeviceDefListDataPtr data); + +void virDomainDeviceDefListFree(virDomainDeviceDefListPtr list); +void virDomainDeviceDefListFreeShallow(virDomainDeviceDefListPtr list); + + /* Called once after everything else has been parsed, for adjusting * overall domain defaults. * @parseOpaque is opaque data passed by virDomainDefParse* caller, @@ -2935,6 +2966,11 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const = char *xmlStr, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, unsigned int flags); +virDomainDeviceDefListPtr virDomainDeviceDefParseXMLMany(const char *xmlSt= r, + const virDomainDe= f *def, + virCapsPtr caps, + virDomainXMLOptio= nPtr xmlopt, + unsigned int flag= s); virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr, const virDomainDef *def, virDomainXMLOptionPtr xmlo= pt, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b0e8f2ca61..d1ff2f5f99 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -300,7 +300,13 @@ virDomainDeviceAddressTypeToString; virDomainDeviceAliasIsUserAlias; virDomainDeviceDefCopy; virDomainDeviceDefFree; +virDomainDeviceDefListAddCopy; +virDomainDeviceDefListCopy; +virDomainDeviceDefListFree; +virDomainDeviceDefListFreeShallow; +virDomainDeviceDefListIterate; virDomainDeviceDefParse; +virDomainDeviceDefParseXMLMany; virDomainDeviceFindSCSIController; virDomainDeviceGetInfo; virDomainDeviceInfoIterate; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099187450709.4740567545258; Thu, 15 Mar 2018 00:33:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38D0DC206ADF; Thu, 15 Mar 2018 07:33:06 +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 E89B6541C1; Thu, 15 Mar 2018 07:33: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 A1B364A49C; Thu, 15 Mar 2018 07:33:05 +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 w2EHM7Lq025480 for ; Wed, 14 Mar 2018 13:22:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id E09ED60933; Wed, 14 Mar 2018 17:22:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8D1A608F7 for ; Wed, 14 Mar 2018 17:22:05 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 677B9C0467DD for ; Wed, 14 Mar 2018 17:22:04 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKRpt023577 for ; Wed, 14 Mar 2018 13:22:03 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq44644f3-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:22:03 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:22:01 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:21:59 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHLweY55902440 for ; Wed, 14 Mar 2018 17:21:58 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A53B3AE04D for ; Wed, 14 Mar 2018 17:12:25 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 108E5AE051 for ; Wed, 14 Mar 2018 17:12:25 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:12:24 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:51:56 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0016-0000-0000-00000532797E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0017-0000-0000-0000286F7F34 Message-Id: <152104810611.10112.10186711678510517800.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Mar 2018 17:22:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Mar 2018 17:22:04 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 20/28] Introduce qemuDomainDeviceParseXMLMany 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 15 Mar 2018 07:33:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_domain.c | 67 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_domain.h | 5 ++++ 2 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 12ed68a89b..c0a0af525f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11842,3 +11842,70 @@ qemuProcessEventFree(struct qemuProcessEvent *even= t) } VIR_FREE(event); } + + +static bool isPCIMultifunctionDeviceXML(const char *xml) +{ + xmlDocPtr xmlptr; + + if (!(xmlptr =3D virXMLParse(NULL, xml, _("(device_definition)")))) { + /* We report error anyway later */ + return false; + } + + return STREQ((const char *)(xmlDocGetRootElement(xmlptr))->name, "devic= es"); +} + +static +int qemuDomainValidateMultifunctionDeviceList(virDomainDeviceDefListPtr de= vlist) +{ + size_t i; + virDomainHostdevDefPtr hostdev =3D NULL; + virDomainDeviceInfoPtr info; + + for (i =3D 0; i < devlist->count; i++) { + info =3D virDomainDeviceGetInfo(devlist->devs[i]); + if (devlist->devs[i]->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV) + hostdev =3D devlist->devs[i]->data.hostdev; + + if (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE= _PCI) + return -1; + + if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + return -1; + } + } + return 0; +} + + +virDomainDeviceDefListPtr +qemuDomainDeviceParseXMLMany(const char *xml, + virDomainDeviceDefListDataPtr data, + unsigned int parse_flags) +{ + virDomainDeviceDefListPtr devlist =3D NULL; + + if (isPCIMultifunctionDeviceXML(xml)) { + if (!(devlist =3D virDomainDeviceDefParseXMLMany(xml, data->def, + data->caps, data->x= mlopt, + parse_flags))) + goto cleanup; + + if (qemuDomainValidateMultifunctionDeviceList(devlist) < 0) + goto cleanup; + } else { + virDomainDeviceDefPtr dev =3D virDomainDeviceDefParse(xml, data->d= ef, + data->caps, da= ta->xmlopt, + parse_flags); + if (!dev || VIR_ALLOC(devlist) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(devlist->devs, devlist->count, dev) < 0) + goto cleanup; + } + + cleanup: + return devlist; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index fbfc994652..339d0ba82c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1011,4 +1011,9 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, qemuDomainObjPrivatePtr priv, virQEMUDriverConfigPtr cfg); =20 +virDomainDeviceDefListPtr +qemuDomainDeviceParseXMLMany(const char *xml, + virDomainDeviceDefListDataPtr data, + unsigned int parse_flags); + #endif /* __QEMU_DOMAIN_H__ */ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099108963211.84238316470373; Thu, 15 Mar 2018 00:31:48 -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 95784C01F2E0; Thu, 15 Mar 2018 07:31:47 +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 63DB218944; Thu, 15 Mar 2018 07:31:47 +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 30A974CAA3; Thu, 15 Mar 2018 07:31:47 +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 w2EHMLTu025493 for ; Wed, 14 Mar 2018 13:22:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36E005FCA4; Wed, 14 Mar 2018 17:22:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F56518BBD for ; Wed, 14 Mar 2018 17:22:18 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C91880470 for ; Wed, 14 Mar 2018 17:22:17 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKJMg110308 for ; Wed, 14 Mar 2018 13:22:16 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq6nev47j-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:22:16 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:22:13 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:22:11 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHMBD753674234 for ; Wed, 14 Mar 2018 17:22:11 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F080A4040 for ; Wed, 14 Mar 2018 17:15:00 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 041D2A4055 for ; Wed, 14 Mar 2018 17:15:00 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:14:59 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:52:09 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0008-0000-0000-000004DD7976 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0009-0000-0000-00001E707F35 Message-Id: <152104812505.10112.183879668172823363.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 14 Mar 2018 17:22:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 14 Mar 2018 17:22:17 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 21/28] qemu: refactor qemuDomain[Attach|Detach]DeviceConfig 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.31]); Thu, 15 Mar 2018 07:31:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This helps calling the routines with a list of devices. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_driver.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0ade86d6a9..18e88f05bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7969,11 +7969,8 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm, } =20 static int -qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - virDomainDeviceDefPtr dev, - virCapsPtr caps, - unsigned int parse_flags, - virDomainXMLOptionPtr xmlopt) +qemuDomainAttachDeviceConfigInternal(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev) { virDomainDiskDefPtr disk; virDomainNetDefPtr net; @@ -8151,20 +8148,34 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 - if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) - return -1; - return 0; } =20 =20 static int -qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, +qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, virCapsPtr caps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) { + if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0) + return -1; + + if (qemuDomainAttachDeviceConfigInternal(vmdef, dev)) + return -1; + + if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) + return -1; + + return 0; +} + + +static int +qemuDomainDetachDeviceConfigInternal(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev) +{ virDomainDiskDefPtr disk, det_disk; virDomainNetDefPtr net; virDomainHostdevDefPtr hostdev, det_hostdev; @@ -8334,6 +8345,20 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 + return 0; +} + + +static int +qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev, + virCapsPtr caps, + unsigned int parse_flags, + virDomainXMLOptionPtr xmlopt) +{ + if (qemuDomainDetachDeviceConfigInternal(vmdef, dev)) + return -1; + if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) return -1; =20 @@ -8486,8 +8511,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, if (!vmdef) goto cleanup; =20 - if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0) - goto cleanup; if ((ret =3D qemuDomainAttachDeviceConfig(vmdef, dev, caps, parse_flags, driver->xmlopt)) < 0) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099105484576.7469790978042; Thu, 15 Mar 2018 00:31:45 -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 34B0B7FEB9; Thu, 15 Mar 2018 07:31:44 +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 0ECBA600C0; Thu, 15 Mar 2018 07:31:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B5265181B9FE; Thu, 15 Mar 2018 07:31:43 +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 w2EHMf4g025513 for ; Wed, 14 Mar 2018 13:22:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id F25615D70B; Wed, 14 Mar 2018 17:22:40 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB48E5D753 for ; Wed, 14 Mar 2018 17:22:38 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1999356C3 for ; Wed, 14 Mar 2018 17:22:37 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKNHM054214 for ; Wed, 14 Mar 2018 13:22:37 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq7172ver-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:22:36 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:22:35 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:22:33 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHMXIG50266178 for ; Wed, 14 Mar 2018 17:22:33 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE5D442042 for ; Wed, 14 Mar 2018 17:14:47 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 278ED42041 for ; Wed, 14 Mar 2018 17:14:47 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:14:46 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:52:31 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0020-0000-0000-000004047B6A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0021-0000-0000-000042988072 Message-Id: <152104813662.10112.6139693513332286115.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:22:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Mar 2018 17:22:37 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 22/28] qemu: refactor qemuDomain[Attach|Detach]DeviceLive 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.25]); Thu, 15 Mar 2018 07:31:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Helps calling multiple time per device --- src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 18e88f05bb..d2e10082ea 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7599,9 +7599,9 @@ qemuDomainUndefine(virDomainPtr dom) } =20 static int -qemuDomainAttachDeviceLive(virDomainObjPtr vm, - virDomainDeviceDefPtr dev, - virQEMUDriverPtr driver) +qemuDomainAttachDeviceLiveInternal(virDomainObjPtr vm, + virDomainDeviceDefPtr dev, + virQEMUDriverPtr driver) { int ret =3D -1; const char *alias =3D NULL; @@ -7739,12 +7739,25 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, qemuDomainEventQueue(driver, event); } =20 + return ret; +} + +static int +qemuDomainAttachDeviceLive(virDomainObjPtr vm, + virDomainDeviceDefPtr dev, + virQEMUDriverPtr driver) +{ + int ret =3D -1; + + if (virDomainDefCompatibleDevice(vm->def, dev, NULL) < 0) + return -1; + + ret =3D qemuDomainAttachDeviceLiveInternal(vm, dev, driver); if (ret =3D=3D 0) ret =3D qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE= ); =20 return ret; } - static int qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -7766,9 +7779,9 @@ qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr= driver, } =20 static int -qemuDomainDetachDeviceLive(virDomainObjPtr vm, - virDomainDeviceDefPtr dev, - virQEMUDriverPtr driver) +qemuDomainDetachDeviceLiveInternal(virDomainObjPtr vm, + virDomainDeviceDefPtr dev, + virQEMUDriverPtr driver) { int ret =3D -1; =20 @@ -7829,6 +7842,17 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, break; } =20 + return ret; +} + +static int +qemuDomainDetachDeviceLive(virDomainObjPtr vm, + virDomainDeviceDefPtr dev, + virQEMUDriverPtr driver) +{ + int ret =3D -1; + + ret =3D qemuDomainDetachDeviceLiveInternal(vm, dev, driver); if (ret =3D=3D 0) ret =3D qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE= ); =20 @@ -8518,9 +8542,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL) < 0) - goto cleanup; - if ((ret =3D qemuDomainAttachDeviceLive(vm, dev_copy, driver)) < 0) goto cleanup; /* -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099416417831.9442304348895; Thu, 15 Mar 2018 00:36:56 -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 25C9F7E9E1; Thu, 15 Mar 2018 07:36:55 +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 F07B917243; Thu, 15 Mar 2018 07:36:54 +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 B75544CAAC; Thu, 15 Mar 2018 07:36:54 +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 w2EHNDLq025551 for ; Wed, 14 Mar 2018 13:23:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78B045D757; Wed, 14 Mar 2018 17:23:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 719B35D755 for ; Wed, 14 Mar 2018 17:23:11 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DB108123D for ; Wed, 14 Mar 2018 17:23:10 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHMZnc093817 for ; Wed, 14 Mar 2018 13:23:10 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq515hbqv-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:23:09 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:23:07 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:23:05 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHN4lR51773562 for ; Wed, 14 Mar 2018 17:23:04 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3710D42057 for ; Wed, 14 Mar 2018 17:15:19 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96A1242042 for ; Wed, 14 Mar 2018 17:15:18 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:15:18 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:53:02 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-000004407961 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000020E37F2D Message-Id: <152104815867.10112.4524650953911651399.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Mar 2018 17:23:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Mar 2018 17:23:10 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 23/28] qemu: hotplug: Queue and wait for multiple devices 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.26]); Thu, 15 Mar 2018 07:36:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" With multifunction devices, multiple delete requests are sent to qemu and all the requests should be queued up. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_domain.h | 3 ++- src/qemu/qemu_hotplug.c | 38 ++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 339d0ba82c..85cbc2b5e8 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -195,7 +195,8 @@ typedef enum { typedef struct _qemuDomainUnpluggingDevice qemuDomainUnpluggingDevice; typedef qemuDomainUnpluggingDevice *qemuDomainUnpluggingDevicePtr; struct _qemuDomainUnpluggingDevice { - const char *alias; + const char **aliases; + size_t naliases; qemuDomainUnpluggingDeviceStatus status; }; =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 007ecb0923..7dffaf9502 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4542,16 +4542,21 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, =20 static void qemuDomainMarkDeviceAliasForRemoval(virDomainObjPtr vm, - const char *alias) + const char *alias, + bool fresh) { qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 - memset(&priv->unplug, 0, sizeof(priv->unplug)); + if (fresh) + memset(&priv->unplug, 0, sizeof(priv->unplug)); =20 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT)) return; =20 - priv->unplug.alias =3D alias; + if (VIR_REALLOC_N(priv->unplug.aliases, priv->unplug.naliases + 1) < 0) + return; + + priv->unplug.aliases[priv->unplug.naliases++] =3D alias; } =20 =20 @@ -4560,7 +4565,7 @@ qemuDomainMarkDeviceForRemoval(virDomainObjPtr vm, virDomainDeviceInfoPtr info) =20 { - qemuDomainMarkDeviceAliasForRemoval(vm, info->alias); + qemuDomainMarkDeviceAliasForRemoval(vm, info->alias, true); } =20 =20 @@ -4568,7 +4573,8 @@ static void qemuDomainResetDeviceRemoval(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - priv->unplug.alias =3D NULL; + VIR_FREE(priv->unplug.aliases); + priv->unplug.naliases =3D 0; } =20 /* Returns: @@ -4596,13 +4602,14 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm) return 1; until +=3D qemuDomainRemoveDeviceWaitTime; =20 - while (priv->unplug.alias) { + /* All devices should get released around same time*/ + while (priv->unplug.naliases) { if ((rc =3D virDomainObjWaitUntil(vm, until)) =3D=3D 1) return 0; =20 if (rc < 0) { VIR_WARN("Failed to wait on unplug condition for domain '%s' " - "device '%s'", vm->def->name, priv->unplug.alias); + "device '%s'", vm->def->name, priv->unplug.aliases[0]= ); return 1; } } @@ -4627,14 +4634,17 @@ qemuDomainSignalDeviceRemoval(virDomainObjPtr vm, const char *devAlias, qemuDomainUnpluggingDeviceStatus status) { + size_t i; qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 - if (STREQ_NULLABLE(priv->unplug.alias, devAlias)) { - VIR_DEBUG("Removal of device '%s' continues in waiting thread", de= vAlias); - qemuDomainResetDeviceRemoval(vm); - priv->unplug.status =3D status; - virDomainObjBroadcast(vm); - return true; + for (i =3D 0; i < priv->unplug.naliases; i++) { + if (STREQ_NULLABLE(priv->unplug.aliases[i], devAlias)) { + VIR_DEBUG("Removal of device '%s' continues in waiting thread"= , devAlias); + VIR_DELETE_ELEMENT(priv->unplug.aliases, i, priv->unplug.nalia= ses); + priv->unplug.status =3D status; + virDomainObjBroadcast(vm); + return true; + } } return false; } @@ -5675,7 +5685,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, return -1; } =20 - qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias); + qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias, true); =20 qemuDomainObjEnterMonitor(driver, vm); =20 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099119841208.61601894092337; Thu, 15 Mar 2018 00:31:59 -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 875CE7FDDF; Thu, 15 Mar 2018 07:31:58 +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 5339F177C9; Thu, 15 Mar 2018 07:31:58 +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 173764CA9D; Thu, 15 Mar 2018 07:31:58 +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 w2EHNRYM025574 for ; Wed, 14 Mar 2018 13:23:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 51BF85D962; Wed, 14 Mar 2018 17:23:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AE154FA23 for ; Wed, 14 Mar 2018 17:23:24 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CF613AA1B for ; Wed, 14 Mar 2018 17:23:23 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHLktQ100736 for ; Wed, 14 Mar 2018 13:23:23 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq5b8895a-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:23:22 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:23:20 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:23:18 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHNHYb56361176 for ; Wed, 14 Mar 2018 17:23:17 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C71D552043 for ; Wed, 14 Mar 2018 16:14:47 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 167EF5203F for ; Wed, 14 Mar 2018 16:14:46 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:53:15 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0016-0000-0000-000005327994 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0017-0000-0000-0000286F7F4A Message-Id: <152104819007.10112.2791139597190204989.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:23:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:23:23 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 24/28] domain: addr: Introduce virDomainPCIAddressEnsureMultifunctionAddress 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.27]); Thu, 15 Mar 2018 07:31:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/conf/device_conf.h | 6 +++ src/conf/domain_addr.c | 84 ++++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_addr.h | 5 +++ src/libvirt_private.syms | 1 + src/util/virpci.h | 2 + 5 files changed, 98 insertions(+) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index cdb2040fb8..ae7a651ee0 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -177,6 +177,12 @@ struct _virDomainDeviceInfo { bool isolationGroupLocked; }; =20 +typedef struct _virDomainPCIMultifunctionAddressInfo virDomainPCIMultifunc= tionAddressInfo; +typedef virDomainPCIMultifunctionAddressInfo *virDomainPCIMultifunctionAdd= ressInfoPtr; +struct _virDomainPCIMultifunctionAddressInfo { + virDomainDeviceInfoPtr infos[VIR_PCI_MAX_FUNCTIONS]; +}; + int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, virDomainDeviceInfoPtr src); void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index c4a0b99628..43227a4b25 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -27,6 +27,7 @@ #include "virlog.h" #include "virstring.h" #include "domain_addr.h" +#include "device_conf.h" =20 #define VIR_FROM_THIS VIR_FROM_DOMAIN =20 @@ -697,6 +698,89 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPt= r addrs, } =20 =20 +/* + *virDomainPCIAddressEnsureMultifunctionAddress: + * + * + * + */ + +int +virDomainPCIAddressEnsureMultifunctionAddress(virDomainPCIAddressSetPtr ad= drs, + virDomainPCIMultifunctionAdd= ressInfoPtr pcicard) +{ + size_t i; + int ret =3D 0; + virPCIDeviceAddressPtr addr1 =3D NULL, addr2 =3D NULL; + virDomainDeviceInfoPtr dev =3D NULL; + char *addrStr =3D NULL; + + if (!pcicard->infos[0]) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Function-Zero missing on the slot")); + return -1; + } + + /* If the address is given by the user, make sure they belong + * to same slot */ + for (i =3D 0; i < VIR_PCI_MAX_FUNCTIONS; i++) { + dev =3D pcicard->infos[i]; + if (dev && !dev->pciConnectFlags) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Not a PCI Multifunction device.")); + goto cleanup; + } + if (dev && virDeviceInfoPCIAddressPresent(dev)) { + /* Pick one and compare against rest of the user given */ + addr1 =3D addr1 ? addr1 : &dev->addr.pci; + addr2 =3D &dev->addr.pci; + if (!(addrStr =3D virDomainPCIAddressAsString(addr2))) + goto cleanup; + if (!virDomainPCIAddressValidate(addrs, addr2, + addrStr, dev->pciConnectFlags= , true)) + goto cleanup; + if (!(addr1->domain =3D=3D addr2->domain && addr1->bus =3D=3D = addr2->bus && + addr1->slot =3D=3D addr2->slot)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Addresses belong to different PCI slots= ")); + goto cleanup; + } + VIR_FREE(addrStr); + } + } + + /* Reserve all the user given addresses. */ + for (i =3D 0; i < VIR_PCI_MAX_FUNCTIONS; i++) { + dev =3D pcicard->infos[i]; + if (dev && virDeviceInfoPCIAddressPresent(dev)) { + ret =3D virDomainPCIAddressReserveAddrInternal(addrs, &dev->ad= dr.pci, + dev->pciConnectFl= ags, dev->isolationGroup, + dev->aggregateSlo= tIdx, + true); + if (ret < 0) + goto cleanup; + } + } + + /* If the user has not given addresses, start with function zero */ + for (i =3D 0; i < VIR_PCI_MAX_FUNCTIONS; i++) { + dev =3D pcicard->infos[i]; + if (dev && !virDeviceInfoPCIAddressPresent(dev)) { + ret =3D virDomainPCIAddressReserveNextAddr(addrs, dev, dev->pc= iConnectFlags, i); + if (ret < 0) + goto cleanup; + } + } + + /* Set multi on overriding what user has set. */ + pcicard->infos[0]->addr.pci.multi =3D VIR_TRISTATE_SWITCH_ON; + + cleanup: + VIR_FREE(addrStr); + return ret; +} + + void virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr) diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index fa98b67e5c..e80e1e9089 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -162,6 +162,11 @@ int virDomainPCIAddressEnsureAddr(virDomainPCIAddressS= etPtr addrs, virDomainPCIConnectFlags flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +int +virDomainPCIAddressEnsureMultifunctionAddress(virDomainPCIAddressSetPtr ad= drs, + virDomainPCIMultifunctionAdd= ressInfoPtr pcicard) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + void virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d1ff2f5f99..3e4d627004 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -114,6 +114,7 @@ virDomainPCIAddressAsString; virDomainPCIAddressBusIsFullyReserved; virDomainPCIAddressBusSetModel; virDomainPCIAddressEnsureAddr; +virDomainPCIAddressEnsureMultifunctionAddress; virDomainPCIAddressReleaseAddr; virDomainPCIAddressReserveAddr; virDomainPCIAddressReserveNextAddr; diff --git a/src/util/virpci.h b/src/util/virpci.h index 5830fb4c12..65e586ed15 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -29,6 +29,8 @@ # include "virobject.h" # include "virutil.h" =20 +# define VIR_PCI_MAX_FUNCTIONS 8 + typedef struct _virPCIDevice virPCIDevice; typedef virPCIDevice *virPCIDevicePtr; typedef struct _virPCIDeviceAddress virPCIDeviceAddress; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099438717682.4351943353669; Thu, 15 Mar 2018 00:37:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F370C025019; Thu, 15 Mar 2018 07:37:17 +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 40B78537B3; Thu, 15 Mar 2018 07:37:17 +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 F330C4CAAC; Thu, 15 Mar 2018 07:37:16 +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 w2EHNhCE025598 for ; Wed, 14 Mar 2018 13:23:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2CACF5D6B2; Wed, 14 Mar 2018 17:23:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22C305D753 for ; Wed, 14 Mar 2018 17:23:40 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A10CC0467DD for ; Wed, 14 Mar 2018 17:23:38 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHKNAk086658 for ; Wed, 14 Mar 2018 13:23:38 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq515hc7y-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:23:37 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:23:34 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:23:32 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHNVG456295628 for ; Wed, 14 Mar 2018 17:23:31 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3F6E11C054 for ; Wed, 14 Mar 2018 17:16:09 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 386E011C04C for ; Wed, 14 Mar 2018 17:16:09 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:16:08 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:53:29 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-000004207A21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000026237F8C Message-Id: <152104820338.10112.16359313256631575931.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Mar 2018 17:23:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Mar 2018 17:23:38 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 25/28] qemu: hotplug: Implement multifunction device 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 15 Mar 2018 07:37:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_domain.c | 2=20 src/qemu/qemu_domain_address.c | 68 +++++++++++++++++ src/qemu/qemu_domain_address.h | 5 + src/qemu/qemu_driver.c | 66 ++++++++++------ src/qemu/qemu_hotplug.c | 82 ++++++++++++++++= ++++ src/qemu/qemu_hotplug.h | 4 + tests/qemuhotplugtest.c | 39 ++++++++-- .../qemuhotplug-multifunction-hostdev-pci-2.xml | 14 +++ .../qemuhotplug-multifunction-hostdev-pci.xml | 20 +++++ ...hotplug-base-live+multifunction-hostdev-pci.xml | 76 ++++++++++++++++= +++ ...eries-base-live+multifunction-hostdev-pci-2.xml | 61 +++++++++++++++ ...pseries-base-live+multifunction-hostdev-pci.xml | 69 +++++++++++++++++ 12 files changed, 475 insertions(+), 31 deletions(-) create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-multifunction-= hostdev-pci-2.xml create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-multifunction-= hostdev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+mult= ifunction-hostdev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-l= ive+multifunction-hostdev-pci-2.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-l= ive+multifunction-hostdev-pci.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c0a0af525f..1cfaf01540 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -33,6 +33,8 @@ #include "qemu_capabilities.h" #include "qemu_migration.h" #include "qemu_security.h" +#include "qemu_hotplug.h" +#include "qemu_hostdev.h" #include "viralloc.h" #include "virlog.h" #include "virerror.h" diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 7bee4fb937..ee743321dd 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -25,6 +25,7 @@ =20 #include "qemu_domain_address.h" #include "qemu_domain.h" +#include "domain_conf.h" #include "viralloc.h" #include "virhostdev.h" #include "virerror.h" @@ -3206,6 +3207,73 @@ qemuDomainEnsurePCIAddress(virDomainObjPtr obj, info->pciConnectFlags); } =20 + +int +qemuDomainPCIMultifunctionHostdevEnsurePCIAddresses(virDomainObjPtr vm, + virDomainDeviceDefList= Ptr devlist, + virQEMUDriverPtr drive= r) +{ + int ret =3D -1, aggrslotidx =3D 0; + virBitmapPtr slotmap =3D NULL; + size_t i; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virDomainPCIMultifunctionAddressInfoPtr devinfos =3D NULL; + + if (devlist->count > VIR_PCI_MAX_FUNCTIONS) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("More devices per slot found")); + return -1; + } + + for (i =3D 0; i < devlist->count; i++) + qemuDomainFillDevicePCIConnectFlags(vm->def, devlist->devs[i], pri= v->qemuCaps, driver); + + if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + devlist->cou= nt) < 0) + return -1; + + /* Temporarily add the devices to the domain def to get the + * next aggregateIdx */ + for (i =3D 0; i < devlist->count; i++) + vm->def->hostdevs[vm->def->nhostdevs++] =3D devlist->devs[i]->data= .hostdev; + + for (i =3D 0; i < devlist->count; i++) { + if (qemuDomainIsPSeries(vm->def)) { + /* Isolation groups are only relevant for pSeries guests */ + if (qemuDomainFillDeviceIsolationGroup(vm->def, devlist->devs[= i]) < 0) + return -1; + } + qemuDomainSetDeviceSlotAggregateIdx(vm->def, devlist->devs[i]); + aggrslotidx =3D aggrslotidx ? aggrslotidx : devlist->devs[i]->data= .hostdev->info->aggregateSlotIdx; + if (aggrslotidx !=3D devlist->devs[i]->data.hostdev->info->aggrega= teSlotIdx) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Devices belong to different PCI slots")); + return -1; + } + } + + for (i =3D 0; i < devlist->count; i++) + vm->def->hostdevs[--(vm->def->nhostdevs)] =3D NULL; + + slotmap =3D virDomainDefHostdevGetPCIOnlineFunctionMap(vm->def, aggrsl= otidx); + if (!virBitmapIsAllClear(slotmap)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Device already assigned to guest")); + return -1; + } + + if (VIR_ALLOC(devinfos) < 0) + return -1; + + for (i =3D 0; i < devlist->count; i++) { + virPCIDeviceAddress addr =3D devlist->devs[i]->data.hostdev->sour= ce.subsys.u.pci.addr; + devinfos->infos[addr.function] =3D devlist->devs[i]->data.hostde= v->info; + } + + ret =3D virDomainPCIAddressEnsureMultifunctionAddress(priv->pciaddrs, = devinfos); + VIR_FREE(devinfos); + return ret; +} + void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, virDomainDeviceInfoPtr info, diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index e1cc467714..43d1de889e 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -51,6 +51,11 @@ int qemuDomainEnsurePCIAddress(virDomainObjPtr obj, virQEMUDriverPtr driver) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 +int +qemuDomainPCIMultifunctionHostdevEnsurePCIAddresses(virDomainObjPtr obj, + virDomainDeviceDefList= Ptr devlist, + virQEMUDriverPtr drive= r); + int qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def, virDomainDeviceDefPtr dev) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d2e10082ea..fb14475d8c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7744,15 +7744,26 @@ qemuDomainAttachDeviceLiveInternal(virDomainObjPtr = vm, =20 static int qemuDomainAttachDeviceLive(virDomainObjPtr vm, - virDomainDeviceDefPtr dev, + virDomainDeviceDefListPtr devlist, virQEMUDriverPtr driver) { int ret =3D -1; + size_t i; =20 - if (virDomainDefCompatibleDevice(vm->def, dev, NULL) < 0) - return -1; + for (i =3D 0; i < devlist->count; i++) + if (virDomainDefCompatibleDevice(vm->def, devlist->devs[i], NULL) = < 0) + return ret; + + if (devlist->count > 1) { + ret =3D qemuDomainAttachMultifunctionDevice(vm, devlist, driver); + if (ret =3D=3D 0) { + for (i =3D 0; i < devlist->count; i++) + devlist->devs[i]->data.hostdev =3D NULL; + } + } else if (devlist->count =3D=3D 1) { + ret =3D qemuDomainAttachDeviceLiveInternal(vm, devlist->devs[0], d= river); + } =20 - ret =3D qemuDomainAttachDeviceLiveInternal(vm, dev, driver); if (ret =3D=3D 0) ret =3D qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE= ); =20 @@ -8178,16 +8189,22 @@ qemuDomainAttachDeviceConfigInternal(virDomainDefPt= r vmdef, =20 static int qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - virDomainDeviceDefPtr dev, + virDomainDeviceDefListPtr devlist, virCapsPtr caps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) { - if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0) - return -1; + size_t i; =20 - if (qemuDomainAttachDeviceConfigInternal(vmdef, dev)) - return -1; + for (i =3D 0; i < devlist->count; i++) { + if (virDomainDefCompatibleDevice(vmdef, devlist->devs[i], NULL) < 0) + return -1; + } + + for (i =3D 0; i < devlist->count; i++) { + if (qemuDomainAttachDeviceConfigInternal(vmdef, devlist->devs[i])) + return -1; + } =20 if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) return -1; @@ -8493,9 +8510,11 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr = vm, const char *xml, unsigned int flags) { + size_t i; virDomainDefPtr vmdef =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; - virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; + virDomainDeviceDefListPtr devlist =3D NULL, devcopylist =3D NULL; + virDomainDeviceDefListData data =3D {.def =3D vm->def, .xmlopt =3D dri= ver->xmlopt, .caps =3D NULL}; int ret =3D -1; virCapsPtr caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | @@ -8508,15 +8527,16 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr= vm, =20 if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + data.caps =3D caps; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, - parse_flags); - if (dev =3D=3D NULL) + devlist =3D qemuDomainDeviceParseXMLMany(xml, &data, parse_flags); + if (!devlist) goto cleanup; + devcopylist =3D devlist; =20 - if (virDomainDeviceValidateAliasForHotplug(vm, dev, flags) < 0) - goto cleanup; + for (i =3D 0; i < devlist->count; i++) + if (virDomainDeviceValidateAliasForHotplug(vm, devlist->devs[i], f= lags) < 0) + goto cleanup; =20 if (flags & VIR_DOMAIN_AFFECT_CONFIG && flags & VIR_DOMAIN_AFFECT_LIVE) { @@ -8524,8 +8544,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, caps, driver->xm= lopt); - if (!dev_copy) + devcopylist =3D virDomainDeviceDefListCopy(devlist, &data); + if (!devcopylist) goto cleanup; } =20 @@ -8535,14 +8555,14 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr= vm, if (!vmdef) goto cleanup; =20 - if ((ret =3D qemuDomainAttachDeviceConfig(vmdef, dev, caps, + if ((ret =3D qemuDomainAttachDeviceConfig(vmdef, devlist, caps, parse_flags, driver->xmlopt)) < 0) goto cleanup; } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if ((ret =3D qemuDomainAttachDeviceLive(vm, dev_copy, driver)) < 0) + if ((ret =3D qemuDomainAttachDeviceLive(vm, devcopylist, driver)) = < 0) goto cleanup; /* * update domain status forcibly because the domain status may be @@ -8566,9 +8586,9 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, =20 cleanup: virDomainDefFree(vmdef); - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); - virDomainDeviceDefFree(dev); + if (devlist !=3D devcopylist) + virDomainDeviceDefListFree(devcopylist); + virDomainDeviceDefListFree(devlist); virObjectUnref(cfg); virObjectUnref(caps); =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7dffaf9502..a339e92bfa 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1402,6 +1402,88 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr drive= r, } =20 =20 +static int +qemuiHostdevPCIMultifunctionDevicesListSort(const void *p1, + const void *p2) +{ + virDomainDeviceDefPtr a =3D *(virDomainDeviceDefPtr *) p1; + virDomainDeviceDefPtr b =3D *(virDomainDeviceDefPtr *) p2; + virPCIDeviceAddressPtr addr1 =3D &a->data.hostdev->source.subsys.u.pci= .addr; + virPCIDeviceAddressPtr addr2 =3D &b->data.hostdev->source.subsys.u.pci= .addr; + + return addr1->function - addr2->function; +} + + +int +qemuDomainAttachMultifunctionDevice(virDomainObjPtr vm, + virDomainDeviceDefListPtr devlist, + virQEMUDriverPtr driver) +{ + size_t i, d, h =3D devlist->count; + int ret =3D -1; + char *alias; + virObjectEventPtr event; + virQEMUCapsPtr qemuCaps =3D NULL; + virDomainHostdevDefPtr hostdev =3D NULL; + + if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + vm->def->emulator))) + return -1; + + qsort(devlist->devs, devlist->count, sizeof(*devlist->devs), qemuiHost= devPCIMultifunctionDevicesListSort); + + if (qemuDomainPCIMultifunctionHostdevEnsurePCIAddresses(vm, devlist, d= river) < 0) + return -1; + + for (d =3D 0; d < devlist->count; d++) + if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, devlist-= >devs[d]->data.hostdev, qemuCaps) < 0) + goto cleanup; + + /* Hotplug all functions, and Primary at last */ + for (h =3D devlist->count; h > 0; h--) { + /* The functions need not be contiguous, as a card may be sold with + * minimal functionality and then install the additional functions= on + * purchase into any of the daughter-card connectors. + */ + hostdev =3D devlist->devs[h-1]->data.hostdev; + ret =3D qemuDomainAttachHostPCIDevice(driver, vm, hostdev); + if (ret) + goto release; + + alias =3D hostdev->info->alias; + hostdev =3D NULL; + + event =3D virDomainEventDeviceAddedNewFromObj(vm, alias); + qemuDomainEventQueue(driver, event); + } + + release: + /* Release addresses for the device which are not hotplugged. + */ + for (i =3D 0; i < h; i++) + qemuDomainReleaseDeviceAddress(vm, devlist->devs[i]->data.hostdev-= >info, NULL); + + cleanup: + /* If none are actually hotplugged and just detached from the + * host driver reattach the devices to host driver. + * + * If one of the hotplug failed, those which are already hotplugged ca= nnot + * be unplugged as they are released by qemu only on guest reboot even + * if we issue device_del on them. + * So, dont attempt to reattach any of them. + * NB: Let them be in the guest as they are not used anyway without + * function-zero? + */ + if (d > 0 && h =3D=3D devlist->count) { + for (i =3D 0; i < d; i++) + qemuHostdevReAttachPCIDevices(driver, vm->def->name, &devlist-= >devs[i]->data.hostdev, 1); + } + + return ret; +} + + void qemuDomainDelTLSObjects(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index db0e1df79a..7a6e2dfb60 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -158,6 +158,10 @@ int qemuDomainAttachPCIHostDevicePrepare(virQEMUDriver= Ptr driver, virDomainDefPtr def, virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps); +int +qemuDomainAttachMultifunctionDevice(virDomainObjPtr vm, + virDomainDeviceDefListPtr devlist, + virQEMUDriverPtr driver); =20 int qemuDomainChrInsert(virDomainDefPtr vmdef, diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index b5dca5e5c9..39f122e083 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -82,6 +82,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION); if (event) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); =20 @@ -115,9 +117,14 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, =20 static int testQemuHotplugAttach(virDomainObjPtr vm, - virDomainDeviceDefPtr dev) + virDomainDeviceDefListPtr devlist) { int ret =3D -1; + virDomainDeviceDefPtr dev; + + if (devlist->count > 1) + return qemuDomainAttachMultifunctionDevice(vm, devlist, &driver); + dev =3D devlist->devs[0]; =20 switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: @@ -249,7 +256,9 @@ testQemuHotplug(const void *data) bool keep =3D test->keep; unsigned int device_parse_flags =3D 0; virDomainObjPtr vm =3D NULL; - virDomainDeviceDefPtr dev =3D NULL; + virDomainDeviceDefPtr dev =3D NULL; /*temperory */ + virDomainDeviceDefListPtr devlist =3D NULL; + virDomainDeviceDefListData listdata; virCapsPtr caps =3D NULL; qemuMonitorTestPtr test_mon =3D NULL; qemuDomainObjPrivatePtr priv =3D NULL; @@ -286,10 +295,13 @@ testQemuHotplug(const void *data) if (test->action =3D=3D ATTACH) device_parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 - if (!(dev =3D virDomainDeviceDefParse(device_xml, vm->def, - caps, driver.xmlopt, - device_parse_flags))) + listdata.def =3D vm->def; + listdata.xmlopt =3D driver.xmlopt; + listdata.caps =3D caps; + devlist =3D qemuDomainDeviceParseXMLMany(device_xml, &listdata, device= _parse_flags); + if (!devlist) goto cleanup; + dev =3D devlist->devs[0]; /* temporary */ =20 /* Now is the best time to feed the spoofed monitor with predefined * replies. */ @@ -319,11 +331,11 @@ testQemuHotplug(const void *data) =20 switch (test->action) { case ATTACH: - ret =3D testQemuHotplugAttach(vm, dev); + ret =3D testQemuHotplugAttach(vm, devlist); if (ret =3D=3D 0) { /* vm->def stolen dev->data.* so we just need to free the dev * envelope */ - VIR_FREE(dev); + virDomainDeviceDefListFreeShallow(devlist); } if (ret =3D=3D 0 || fail) ret =3D testQemuHotplugCheckResult(vm, result_xml, @@ -357,7 +369,7 @@ testQemuHotplug(const void *data) virObjectUnref(vm); test->vm =3D NULL; } - virDomainDeviceDefFree(dev); + virDomainDeviceDefListFree(devlist); virObjectUnref(caps); qemuMonitorTestFree(test_mon); return ((ret < 0 && fail) || (!ret && !fail)) ? 0 : -1; @@ -856,6 +868,17 @@ mymain(void) "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", "multifunction-hostdev-pci", false, false, + "device_add", QMP_OK, + "device_add", QMP_OK, + "device_add", QMP_OK); + + qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64); + DO_TEST_ATTACH("pseries-base-live", "multifunction-hostdev-pci-2", fal= se, false, + "device_add", QMP_OK, + "device_add", QMP_OK, + "device_add", QMP_OK); + qemuTestSetHostArch(driver.caps, VIR_ARCH_X86_64); =20 DO_TEST_ATTACH("base-live", "watchdog", false, true, "watchdog-set-action", QMP_OK, diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-multifunction-hostdev= -pci-2.xml b/tests/qemuhotplugtestdevices/qemuhotplug-multifunction-hostdev= -pci-2.xml new file mode 100644 index 0000000000..02e2236e5d --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-multifunction-hostdev-pci-2.= xml @@ -0,0 +1,14 @@ + + + + +
+ + + + + +
+ + + diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-multifunction-hostdev= -pci.xml b/tests/qemuhotplugtestdevices/qemuhotplug-multifunction-hostdev-p= ci.xml new file mode 100644 index 0000000000..54bb627e30 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-multifunction-hostdev-pci.xml @@ -0,0 +1,20 @@ + + + + +
+ + + + + +
+ + + + + +
+ + + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+multifuncti= on-hostdev-pci.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+mul= tifunction-hostdev-pci.xml new file mode 100644 index 0000000000..f53fe7601b --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+multifunction-host= dev-pci.xml @@ -0,0 +1,76 @@ + + 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+mul= tifunction-hostdev-pci-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-pse= ries-base-live+multifunction-hostdev-pci-2.xml new file mode 100644 index 0000000000..85dc48fdb8 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+multifunct= ion-hostdev-pci-2.xml @@ -0,0 +1,61 @@ + + 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+mul= tifunction-hostdev-pci.xml b/tests/qemuhotplugtestdomains/qemuhotplug-pseri= es-base-live+multifunction-hostdev-pci.xml new file mode 100644 index 0000000000..9338d42e2e --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+multifunct= ion-hostdev-pci.xml @@ -0,0 +1,69 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + +
+ + +
+ + + + +
+ + +
+ + + + +
+ + +
+ + + + + + + + -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099403991828.5163626065373; Thu, 15 Mar 2018 00:36:43 -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 A9FEB680E6; Thu, 15 Mar 2018 07:36:42 +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 7D6635D728; Thu, 15 Mar 2018 07:36:42 +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 483194CAA3; Thu, 15 Mar 2018 07:36:42 +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 w2EHNsUJ025614 for ; Wed, 14 Mar 2018 13:24:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1304F5D757; Wed, 14 Mar 2018 17:23:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0AC6B5D755 for ; Wed, 14 Mar 2018 17:23:51 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFE66333B5 for ; Wed, 14 Mar 2018 17:23:50 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHLcwh105843 for ; Wed, 14 Mar 2018 13:23:50 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5fk7rqf-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:23:49 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:23:48 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:23:47 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHNk5t1638710 for ; Wed, 14 Mar 2018 17:23:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B33BAE04D for ; Wed, 14 Mar 2018 17:14:13 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBE65AE055 for ; Wed, 14 Mar 2018 17:14:12 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:14:12 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:53:44 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0016-0000-0000-00000532799C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0017-0000-0000-0000286F7F52 Message-Id: <152104821690.10112.12294133391901447028.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:23:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:23:51 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 26/28] qemu: hotplug : Prevent updates to mulitfunction device 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, 15 Mar 2018 07:36:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The PCI hostdevs once part of the domain, cant be changed. So, prevent attempts. Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_driver.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fb14475d8c..94f76979e5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8646,6 +8646,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm =3D NULL; virDomainDefPtr vmdef =3D NULL; + virDomainDeviceDefListPtr devlist; + virDomainDeviceDefListData data =3D {.xmlopt =3D driver->xmlopt, .caps= =3D NULL}; virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; bool force =3D (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) !=3D 0; int ret =3D -1; @@ -8663,9 +8665,11 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr = dom, =20 if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + data.caps =3D caps; =20 if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; + data.def =3D vm->def; =20 if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -8673,12 +8677,18 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr= dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, - parse_flags); - if (dev =3D=3D NULL) + devlist =3D qemuDomainDeviceParseXMLMany(xml, &data, parse_flags); + if (!devlist) goto endjob; =20 + if (devlist->count > 1) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("update of device multifunction devices is not su= pported")); + goto endjob; + } + + dev =3D dev_copy =3D devlist->devs[0]; + if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) goto endjob; =20 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15210994008371010.719336998212; Thu, 15 Mar 2018 00:36:40 -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 87A8D62EA1; Thu, 15 Mar 2018 07:36:39 +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 5E1D218817; Thu, 15 Mar 2018 07:36:39 +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 2A2D44CAA0; Thu, 15 Mar 2018 07:36:39 +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 w2EHO9w3025633 for ; Wed, 14 Mar 2018 13:24:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id B1CDB6134A; Wed, 14 Mar 2018 17:24:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC0A76046B for ; Wed, 14 Mar 2018 17:24:06 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84B6D461C3 for ; Wed, 14 Mar 2018 17:24:05 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHLJZI090095 for ; Wed, 14 Mar 2018 13:24:04 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq515hcn7-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:24:04 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:24:02 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:24:00 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHO0pQ57213096 for ; Wed, 14 Mar 2018 17:24:00 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EF5A5203F for ; Wed, 14 Mar 2018 16:15:30 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id DAAA152043 for ; Wed, 14 Mar 2018 16:15:29 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:53:58 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0020-0000-0000-000004047B87 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0021-0000-0000-00004298808F Message-Id: <152104823216.10112.11835235679124619602.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 14 Mar 2018 17:24:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 14 Mar 2018 17:24:05 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 27/28] qemu: hotplug: Move out the Single function check 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.39]); Thu, 15 Mar 2018 07:36:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_hotplug.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a339e92bfa..5f6302eaf9 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4993,17 +4993,8 @@ qemuDomainDetachHostPCIDevice(virQEMUDriverPtr drive= r, virDomainHostdevDefPtr detach) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - virDomainHostdevSubsysPCIPtr pcisrc =3D &detach->source.subsys.u.pci; int ret; =20 - if (qemuIsMultiFunctionDevice(vm->def, detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %.4x= :%.2x:%.2x.%.1x"), - pcisrc->addr.domain, pcisrc->addr.bus, - pcisrc->addr.slot, pcisrc->addr.function); - return -1; - } - qemuDomainMarkDeviceForRemoval(vm, detach->info); =20 qemuDomainObjEnterMonitor(driver, vm); @@ -5094,12 +5085,22 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr dri= ver, virDomainHostdevDefPtr detach) { int ret =3D -1; + virDomainHostdevSubsysPtr subsys =3D &detach->source.subsys; + virDomainHostdevSubsysPCIPtr pcisrc =3D &subsys->u.pci; =20 if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1) < = 0) return -1; =20 switch (detach->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + if (qemuIsMultiFunctionDevice(vm->def, detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: = %.4x:%.2x:%.2x.%.1x"), + pcisrc->addr.domain, pcisrc->addr.bus, + pcisrc->addr.slot, pcisrc->addr.function); + return -1; + } + ret =3D qemuDomainDetachHostPCIDevice(driver, vm, detach); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 08:53:20 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099126680462.2970735536817; Thu, 15 Mar 2018 00:32:06 -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 3E9217FDE2; Thu, 15 Mar 2018 07:32: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 F251A63123; Thu, 15 Mar 2018 07:32:04 +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 B1004180BADB; Thu, 15 Mar 2018 07:32:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EHOTtS025659 for ; Wed, 14 Mar 2018 13:24:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id E8DAA17503; Wed, 14 Mar 2018 17:24:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD9FC5C542 for ; Wed, 14 Mar 2018 17:24:27 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEC973AD89 for ; Wed, 14 Mar 2018 17:24:25 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2EHLe5t105953 for ; Wed, 14 Mar 2018 13:24:25 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gq5fk7se2-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 13:24:24 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 17:24:22 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 17:24:21 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2EHOLdf65994842 for ; Wed, 14 Mar 2018 17:24:21 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FC8D4C04E for ; Wed, 14 Mar 2018 17:17:35 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC0B44C044 for ; Wed, 14 Mar 2018 17:17:34 +0000 (GMT) Received: from localhost.localdomain (unknown [9.79.182.166]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 14 Mar 2018 17:17:34 +0000 (GMT) From: Shivaprasad G Bhat To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 22:54:18 +0530 In-Reply-To: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> References: <152104711186.10112.1077788328340024644.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18031417-0040-0000-0000-000004207A32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031417-0041-0000-0000-000026237F9D Message-Id: <152104824558.10112.2574989242088914440.stgit@localhost.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803140193 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:24:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 14 Mar 2018 17:24:26 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'sbhat@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 28/28] qemu: hotplug: Implement multifunction device unplug 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.27]); Thu, 15 Mar 2018 07:32:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shivaprasad G Bhat --- src/qemu/qemu_driver.c | 48 +++++++++++++------- src/qemu/qemu_hotplug.c | 111 +++++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_hotplug.h | 5 ++ tests/qemuhotplugtest.c | 26 ++++++++--- 4 files changed, 165 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 94f76979e5..0640395b00 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7858,12 +7858,18 @@ qemuDomainDetachDeviceLiveInternal(virDomainObjPtr = vm, =20 static int qemuDomainDetachDeviceLive(virDomainObjPtr vm, - virDomainDeviceDefPtr dev, + virDomainDeviceDefListPtr devlist, virQEMUDriverPtr driver) { int ret =3D -1; + virDomainDeviceDefPtr dev =3D devlist->devs[0]; + + if (devlist->count > 1) { + ret =3D qemuDomainDetachMultifunctionDevice(vm, devlist, driver); + } else { + ret =3D qemuDomainDetachDeviceLiveInternal(vm, dev, driver); + } =20 - ret =3D qemuDomainDetachDeviceLiveInternal(vm, dev, driver); if (ret =3D=3D 0) ret =3D qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE= ); =20 @@ -8392,17 +8398,24 @@ qemuDomainDetachDeviceConfigInternal(virDomainDefPt= r vmdef, =20 static int qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, - virDomainDeviceDefPtr dev, + virDomainDeviceDefListPtr devlist, virCapsPtr caps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) { - if (qemuDomainDetachDeviceConfigInternal(vmdef, dev)) - return -1; + size_t i; + for (i =3D 0; i < devlist->count; i++) + if (qemuDomainDetachDeviceConfigInternal(vmdef, devlist->devs[i])) + return -1; =20 if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0) return -1; =20 + /* Dont allow removing the primary function alone for a multifunction + * device leading to guest start failure later. */ + if (devlist->count > 1 && qemuDomainDefValidatePCIHostdevs(vmdef) < 0) + return -1; + return 0; } =20 @@ -8765,8 +8778,9 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, { virCapsPtr caps =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; - virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; + virDomainDeviceDefListPtr devlist =3D NULL, devcopylist =3D NULL; + virDomainDeviceDefListData data =3D {.def =3D vm->def, .xmlopt =3D dri= ver->xmlopt, .caps =3D NULL}; virDomainDefPtr vmdef =3D NULL; int ret =3D -1; =20 @@ -8775,6 +8789,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, =20 if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + data.caps =3D caps; =20 cfg =3D virQEMUDriverGetConfig(driver); =20 @@ -8782,11 +8797,10 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPt= r driver, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, - parse_flags); - if (dev =3D=3D NULL) + devlist =3D qemuDomainDeviceParseXMLMany(xml, &data, parse_flags); + if (!devlist) goto cleanup; + devcopylist =3D devlist; =20 if (flags & VIR_DOMAIN_AFFECT_CONFIG && flags & VIR_DOMAIN_AFFECT_LIVE) { @@ -8794,8 +8808,8 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, caps, driver->xm= lopt); - if (!dev_copy) + devcopylist =3D virDomainDeviceDefListCopy(devlist, &data); + if (!devcopylist) goto cleanup; } =20 @@ -8805,14 +8819,14 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPt= r driver, if (!vmdef) goto cleanup; =20 - if ((ret =3D qemuDomainDetachDeviceConfig(vmdef, dev, caps, + if ((ret =3D qemuDomainDetachDeviceConfig(vmdef, devlist, caps, parse_flags, driver->xmlopt)) < 0) goto cleanup; } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if ((ret =3D qemuDomainDetachDeviceLive(vm, dev_copy, driver)) < 0) + if ((ret =3D qemuDomainDetachDeviceLive(vm, devcopylist, driver)) = < 0) goto cleanup; /* * update domain status forcibly because the domain status may be @@ -8837,9 +8851,9 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr = driver, cleanup: virObjectUnref(caps); virObjectUnref(cfg); - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); - virDomainDeviceDefFree(dev); + if (devlist !=3D devcopylist) + virDomainDeviceDefListFree(devcopylist); + virDomainDeviceDefListFree(devlist); virDomainDefFree(vmdef); return ret; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 5f6302eaf9..87acd5cf69 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5210,6 +5210,117 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr dri= ver, =20 =20 int +qemuDomainDetachMultifunctionDevice(virDomainObjPtr vm, + virDomainDeviceDefListPtr devlist, + virQEMUDriverPtr driver) +{ + size_t i; + int ret =3D -1; + virBitmapPtr tbdmap =3D NULL, onlinemap =3D NULL; + int *functions =3D NULL; + virDomainHostdevDefPtr hostdev, detach =3D NULL; + virDomainHostdevSubsysPtr subsys =3D NULL; + int slotaggridx =3D 0; + virDomainHostdevSubsysPCIPtr pcisrc =3D NULL; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT)) + return -1; + +#define FOR_EACH_DEV_IN_DEVLIST() \ + for (i =3D 0; i < devlist->count; i++) { \ + hostdev =3D devlist->devs[i]->data.hostdev; \ + subsys =3D &hostdev->source.subsys; \ + pcisrc =3D &subsys->u.pci; \ + virDomainHostdevFind(vm->def, hostdev, &detach); + + FOR_EACH_DEV_IN_DEVLIST() + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("hot unplug is not supported for hostdev mode= '%s'"), + virDomainHostdevModeTypeToString(hostdev->mode)= ); + goto cleanup; + } + } + + FOR_EACH_DEV_IN_DEVLIST() + if (!detach) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("host pci device %.4x:%.2x:%.2x.%.1x not foun= d"), + pcisrc->addr.domain, pcisrc->addr.bus, + pcisrc->addr.slot, pcisrc->addr.function); + goto cleanup; + } + } + + /* Check if the devices belong to same guest slot.*/ + FOR_EACH_DEV_IN_DEVLIST() + /* Pick one aggregateSlotIdx and compare against rest of them */ + slotaggridx =3D slotaggridx ? slotaggridx : detach->info->aggregat= eSlotIdx; + if (slotaggridx !=3D detach->info->aggregateSlotIdx) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("host pci device %.4x:%.2x:%.2x.%.1x doesnt n= ot belong to" + " same slot"), pcisrc->addr.domain, pcisrc->a= ddr.bus, + pcisrc->addr.slot, pcisrc->addr.function); + goto cleanup; + } + } + + /* Check if the whole slot is being removed or not */ + onlinemap =3D virDomainDefHostdevGetPCIOnlineFunctionMap(vm->def, slot= aggridx); + FOR_EACH_DEV_IN_DEVLIST() + ignore_value(virBitmapClearBit(onlinemap, pcisrc->addr.function)); + } + + if (!virBitmapIsAllClear(onlinemap)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hot unplug of partial PCI slot not allowed")); + goto cleanup; + } + + /* Mark all aliases for removal */ + memset(&priv->unplug, 0, sizeof(priv->unplug)); + FOR_EACH_DEV_IN_DEVLIST() + if (qemuAssignDeviceHostdevAlias(vm->def, &detach->info->alias, -1= ) < 0) + goto reset; + + qemuDomainMarkDeviceAliasForRemoval(vm, detach->info->alias, false= ); + } + + qemuDomainObjEnterMonitor(driver, vm); + FOR_EACH_DEV_IN_DEVLIST() + if (qemuMonitorDelDevice(priv->mon, detach->info->alias) < 0) { + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + if (virDomainObjIsActive(vm)) + virDomainAuditHostdev(vm, detach, "detach", false); + goto reset; + } + if (ARCH_IS_X86(vm->def->os.arch)) + break; /* deleting any one is enough! */ + } + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret =3D -1; + + if ((ret =3D qemuDomainWaitForDeviceRemoval(vm)) =3D=3D 1) { + FOR_EACH_DEV_IN_DEVLIST() + ret =3D qemuDomainRemoveHostDevice(driver, vm, detach); + } + } + reset: + qemuDomainResetDeviceRemoval(vm); + cleanup: + VIR_FREE(functions); + virBitmapFree(onlinemap); + virBitmapFree(tbdmap); + +#undef FOR_EACH_DEV_IN_DEVLIST + + return ret; +} + + +int qemuDomainDetachShmemDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainShmemDefPtr dev) diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 7a6e2dfb60..bc850ecc44 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -164,6 +164,11 @@ qemuDomainAttachMultifunctionDevice(virDomainObjPtr vm, virQEMUDriverPtr driver); =20 int +qemuDomainDetachMultifunctionDevice(virDomainObjPtr vm, + virDomainDeviceDefListPtr devlist, + virQEMUDriverPtr driver); + +int qemuDomainChrInsert(virDomainDefPtr vmdef, virDomainChrDefPtr chr); virDomainChrDefPtr diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 39f122e083..61557ce562 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -156,9 +156,14 @@ testQemuHotplugAttach(virDomainObjPtr vm, =20 static int testQemuHotplugDetach(virDomainObjPtr vm, - virDomainDeviceDefPtr dev) + virDomainDeviceDefListPtr devlist) { int ret =3D -1; + virDomainDeviceDefPtr dev; + + if (devlist->count > 1) + return qemuDomainDetachMultifunctionDevice(vm, devlist, &driver); + dev =3D devlist->devs[0]; =20 switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: @@ -256,7 +261,6 @@ testQemuHotplug(const void *data) bool keep =3D test->keep; unsigned int device_parse_flags =3D 0; virDomainObjPtr vm =3D NULL; - virDomainDeviceDefPtr dev =3D NULL; /*temperory */ virDomainDeviceDefListPtr devlist =3D NULL; virDomainDeviceDefListData listdata; virCapsPtr caps =3D NULL; @@ -301,7 +305,6 @@ testQemuHotplug(const void *data) devlist =3D qemuDomainDeviceParseXMLMany(device_xml, &listdata, device= _parse_flags); if (!devlist) goto cleanup; - dev =3D devlist->devs[0]; /* temporary */ =20 /* Now is the best time to feed the spoofed monitor with predefined * replies. */ @@ -343,14 +346,14 @@ testQemuHotplug(const void *data) break; =20 case DETACH: - ret =3D testQemuHotplugDetach(vm, dev); + ret =3D testQemuHotplugDetach(vm, devlist); if (ret =3D=3D 0 || fail) ret =3D testQemuHotplugCheckResult(vm, domain_xml, domain_filename, fail); break; =20 case UPDATE: - ret =3D testQemuHotplugUpdate(vm, dev); + ret =3D testQemuHotplugUpdate(vm, devlist->devs[0]); } =20 cleanup: @@ -868,16 +871,23 @@ mymain(void) "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", "multifunction-hostdev-pci", false, false, + DO_TEST_ATTACH_EVENT("base-live", "multifunction-hostdev-pci", false, = true, "device_add", QMP_OK, "device_add", QMP_OK, "device_add", QMP_OK); + DO_TEST_DETACH("base-live", "multifunction-hostdev-pci", false, false, + "device_del", QMP_DEVICE_DELETED("hostdev2") + QMP_DEVICE_DELETED("hostdev1") + QMP_DEVICE_DELETED("hostdev0") QMP_OK); =20 qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64); - DO_TEST_ATTACH("pseries-base-live", "multifunction-hostdev-pci-2", fal= se, false, - "device_add", QMP_OK, + DO_TEST_ATTACH_EVENT("pseries-base-live", "multifunction-hostdev-pci-2= ", false, true, "device_add", QMP_OK, "device_add", QMP_OK); + DO_TEST_DETACH("pseries-base-live", "multifunction-hostdev-pci-2", fal= se, false, + "device_del", QMP_OK, + "device_del", QMP_DEVICE_DELETED("hostdev1") + QMP_DEVICE_DELETED("hostdev0") QMP_OK); qemuTestSetHostArch(driver.caps, VIR_ARCH_X86_64); =20 DO_TEST_ATTACH("base-live", "watchdog", false, true, -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list