From nobody Wed May 14 15:58:25 2025 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 1523780645445474.7944566160055; Sun, 15 Apr 2018 01:24:05 -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 F260528200; Sun, 15 Apr 2018 08:24:03 +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 C59DE611B1; Sun, 15 Apr 2018 08:24:03 +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 752585BC11; Sun, 15 Apr 2018 08:24: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 w3BFxqDR026559 for ; Wed, 11 Apr 2018 11:59:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A7C45E1C9; Wed, 11 Apr 2018 15:59:41 +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 09D1581F0F for ; Wed, 11 Apr 2018 15:59:27 +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 5FB7FC01CB77 for ; Wed, 11 Apr 2018 15:50:13 +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 w3BFknpw017352 for ; Wed, 11 Apr 2018 11:50:13 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h9n6hrgc0-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 11 Apr 2018 11:50:12 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Apr 2018 16:50:10 +0100 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, 11 Apr 2018 16:50:08 +0100 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 w3BFo8R547120556; Wed, 11 Apr 2018 15:50:08 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA6BC11C04C; Wed, 11 Apr 2018 16:42:12 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3DC511C06C; Wed, 11 Apr 2018 16:42:12 +0100 (BST) Received: from s38lp13.boeblingen.de.ibm.com (unknown [9.152.161.13]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 11 Apr 2018 16:42:12 +0100 (BST) From: Shalini Chellathurai Saroja To: Libvirt Mailing List Date: Wed, 11 Apr 2018 17:49:54 +0200 In-Reply-To: <20180411154959.228209-1-shalini@linux.vnet.ibm.com> References: <20180411154959.228209-1-shalini@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041115-0044-0000-0000-00000546169E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041115-0045-0000-0000-000028864CAA Message-Id: <20180411154959.228209-4-shalini@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-11_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1804110146 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, 11 Apr 2018 15:50:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 11 Apr 2018 15:50:13 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'shalini@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 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.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Shalini Chellathurai Saroja Subject: [libvirt] [PATCH 3/8] util: virhostdev: add virHostdevIsMdevDevice() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 15 Apr 2018 08:24:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the function virHostdevIsMdevDevice() which detects whether a hostdev is a mediated device or not. Also, replace all existing conditionals. Signed-off-by: Shalini Chellathurai Saroja Reviewed-by: Bjoern Walk Reviewed-by: Boris Fiuczynski --- src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 4 +--- src/qemu/qemu_domain_address.c | 8 ++++---- src/qemu/qemu_hostdev.c | 3 +-- src/util/virhostdev.c | 26 +++++++++++++++++--------- src/util/virhostdev.h | 3 +++ 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cab324c4d7..fe35640af1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1926,6 +1926,7 @@ virHostCPUStatsAssign; =20 # util/virhostdev.h virHostdevFindUSBDevice; +virHostdevIsMdevDevice; virHostdevIsSCSIDevice; virHostdevManagerGetDefault; virHostdevPCINodeDeviceDetach; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 514c3ab2ef..e47f915fc8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5346,9 +5346,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, } =20 /* MDEV */ - if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - subsys->type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) { - + if (virHostdevIsMdevDevice(hostdev)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("VFIO PCI device assignment is not " diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index ae6c59bb01..8acd5a7b71 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -655,10 +655,10 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDev= iceDefPtr dev, virPCIDevicePtr pciDev; virPCIDeviceAddressPtr hostAddr =3D &hostdev->source.subsys.u.pci.= addr; =20 - if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || - (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TY= PE_PCI && - hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TY= PE_MDEV && - hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TY= PE_SCSI_HOST)) { + if (!virHostdevIsMdevDevice(hostdev) && + (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI && + hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_SCSI_HOST))) { return 0; } =20 diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index afe445d4e7..ab76e35a23 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -339,8 +339,7 @@ qemuHostdevPrepareMediatedDevices(virQEMUDriverPtr driv= er, supportsVFIO =3D virFileExists("/dev/vfio/vfio"); =20 for (i =3D 0; i < nhostdevs; i++) { - if (hostdevs[i]->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdevs[i]->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBS= YS_TYPE_MDEV) { + if (virHostdevIsMdevDevice(hostdevs[i])) { if (!supportsVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Mediated host device assignment requires= " diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index a12224c58f..b28dc29a41 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -375,6 +375,20 @@ virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev) } =20 =20 +/** + * virHostdevIsMdevDevice: + * @hostdev: host device to check + * + * Returns true if @hostdev is a Mediated device, false otherwise. + */ +bool +virHostdevIsMdevDevice(virDomainHostdevDefPtr hostdev) +{ + return hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV; +} + + static int virHostdevNetConfigVirtPortProfile(const char *linkdev, int vf, virNetDevVPortProfilePtr virtPort, @@ -1333,10 +1347,8 @@ virHostdevUpdateActiveMediatedDevices(virHostdevMana= gerPtr mgr, =20 mdevsrc =3D &hostdev->source.subsys.u.mdev; =20 - if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || - hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYP= E_MDEV) { + if (!virHostdevIsMdevDevice(hostdev)) continue; - } =20 if (!(mdev =3D virMediatedDeviceNew(mdevsrc->uuidstr, mdevsrc->mod= el))) goto cleanup; @@ -1831,9 +1843,7 @@ virHostdevPrepareMediatedDevices(virHostdevManagerPtr= mgr, virDomainHostdevSubsysMediatedDevPtr src =3D &hostdev->source.subs= ys.u.mdev; virMediatedDevicePtr mdev; =20 - if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) - continue; - if (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYP= E_MDEV) + if (!virHostdevIsMdevDevice(hostdev)) continue; =20 if (!(mdev =3D virMediatedDeviceNew(src->uuidstr, src->model))) @@ -2090,10 +2100,8 @@ virHostdevReAttachMediatedDevices(virHostdevManagerP= tr mgr, =20 mdevsrc =3D &hostdev->source.subsys.u.mdev; =20 - if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || - hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYP= E_MDEV) { + if (!virHostdevIsMdevDevice(hostdev)) continue; - } =20 if (!(mdev =3D virMediatedDeviceNew(mdevsrc->uuidstr, mdevsrc->model))) diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h index 54e1c66be3..8f77c00221 100644 --- a/src/util/virhostdev.h +++ b/src/util/virhostdev.h @@ -191,6 +191,9 @@ virHostdevReAttachDomainDevices(virHostdevManagerPtr mg= r, bool virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev) ATTRIBUTE_NONNULL(1); +bool +virHostdevIsMdevDevice(virDomainHostdevDefPtr hostdev) + ATTRIBUTE_NONNULL(1); =20 /* functions used by NodeDevDetach/Reattach/Reset */ int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr, --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list