From nobody Wed May 14 09:48:01 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525704239822354.2436837102422; Mon, 7 May 2018 07:43:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0369630023CF; Mon, 7 May 2018 14:43:56 +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 CA53C1001959; Mon, 7 May 2018 14:43:55 +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 888E45BBE6; Mon, 7 May 2018 14:43:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w47EfaQ0001136 for ; Mon, 7 May 2018 10:41:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 866B830B498D; Mon, 7 May 2018 14:41:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BB9730B4985 for ; Mon, 7 May 2018 14:41:32 +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 813493004435 for ; Mon, 7 May 2018 14:41:30 +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 w47EeUnM140821 for ; Mon, 7 May 2018 10:41:29 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2htqcpm8hc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 May 2018 10:41:29 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 May 2018 15:41:27 +0100 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; Mon, 7 May 2018 15:41:24 +0100 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 w47EfODO7864710; Mon, 7 May 2018 14:41:24 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB065AE059; Mon, 7 May 2018 15:30:53 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79FA8AE056; Mon, 7 May 2018 15:30:53 +0100 (BST) Received: from localhost.localdomain (unknown [9.152.222.69]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 7 May 2018 15:30:53 +0100 (BST) From: Boris Fiuczynski To: libvir-list@redhat.com Date: Mon, 7 May 2018 16:41:13 +0200 In-Reply-To: <20180507144118.6260-1-fiuczy@linux.ibm.com> References: <20180507144118.6260-1-fiuczy@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18050714-0040-0000-0000-00000455FC56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050714-0041-0000-0000-000020FA3776 Message-Id: <20180507144118.6260-4-fiuczy@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-07_06:, , 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-1805070150 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.49]); Mon, 07 May 2018 14:41:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 May 2018 14:41:30 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'fiuczy@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: shalini@linux.vnet.ibm.com, cohuck@redhat.com Subject: [libvirt] [PATCH v2 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 07 May 2018 14:43:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Shalini Chellathurai Saroja 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 Reviewed-by: John Ferlan --- 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 92b5e0f..36150a3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1925,6 +1925,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 50b0ffc..df1c046 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5294,9 +5294,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 8a5ff74..50f815c 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 d2b5460..955b5df 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 db10b7a..f4bd19d 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -372,6 +372,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, @@ -1330,10 +1344,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; @@ -1828,9 +1840,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))) @@ -2087,10 +2097,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 54e1c66..8f77c00 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.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list