From nobody Sat Feb 7 21:16:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1603474346; cv=none; d=zohomail.com; s=zohoarc; b=fZAbenNAZlGR353MJbd6OvBuP+7XAzqQPnI6C0tqwlFi94XcEev8R6TYCeLPt4LNB84bRC7N4qYAbA8wziUD9G0MrxQKbtVuhsSbLGeAyci9RKe+I+BfpSOj/jlpfChoCqVI0f35GuhD/M7UPp+cB05MQvTg7Cmg4oNHYf2RPAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474346; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t8veGu5oiGWLSkkjRsmxduKTILmgoBjr7fsyX22AJqA=; b=IDNFZZt2bYz5Vmn54pjdMhliTfnoxirVoL1VGoclL1LlQ6F1fpvx8MjOV7Cji2VUVUMWn4+NXNFiK2uFa7hGwDIBCICFsHAqLXeKyWe3bPpeB/sxWt05G9FA/avNSspGC2M9e/lendogZ3PjV7iHCacq58XFvlcSdmtqu0x8/q4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 16034743465821016.5767265491435; Fri, 23 Oct 2020 10:32:26 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-U5YOqfYVNQmS5H_avM7zbw-1; Fri, 23 Oct 2020 13:32:23 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60FAB1006CB3; Fri, 23 Oct 2020 17:32: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 166F05D9D5; Fri, 23 Oct 2020 17:32: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 4448092307; Fri, 23 Oct 2020 17:32:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHWFo1000740 for ; Fri, 23 Oct 2020 13:32:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 29F5B1000DBE; Fri, 23 Oct 2020 17:32:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2573310031E6 for ; Fri, 23 Oct 2020 17:32:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1CB1102F1E5 for ; Fri, 23 Oct 2020 17:32:14 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-HyHZRp-SP1KxTgMDjmFMWA-1; Fri, 23 Oct 2020 13:32:12 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHVsmn006466; Fri, 23 Oct 2020 13:32:11 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 34bx0s3dd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:10 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHMBXo019919; Fri, 23 Oct 2020 17:32:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 347r88bhpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:08 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09NHW6pX11927980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:06 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2205C4204D; Fri, 23 Oct 2020 17:32:06 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 021DA4204B; Fri, 23 Oct 2020 17:32:06 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.42.215]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) X-MC-Unique: U5YOqfYVNQmS5H_avM7zbw-1 X-MC-Unique: HyHZRp-SP1KxTgMDjmFMWA-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 04/10] conf: node_devive: refactor GetPCIMdevTypesCaps into GetMdevTypeCapes Date: Fri, 23 Oct 2020 19:31:46 +0200 Message-Id: <20201023173152.45238-5-fiuczy@linux.ibm.com> In-Reply-To: <20201023173152.45238-1-fiuczy@linux.ibm.com> References: <20201023173152.45238-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.737 definitions=2020-10-23_12:2020-10-23, 2020-10-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=3 impostorscore=0 clxscore=1015 spamscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230109 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extracting PCI from virNodeDeviceGetPCIMdevTypesCaps creating virNodeDeviceGetMdevTypesCaps to make later reuse possible. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index af8edded3c..811d102208 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2570,26 +2570,25 @@ virNodeDeviceGetPCIIOMMUGroupCaps(virNodeDevCapPCID= evPtr pci_dev) =20 =20 static int -virNodeDeviceGetPCIMdevTypesCaps(const char *sysfspath, - virNodeDevCapPCIDevPtr pci_dev) +virNodeDeviceGetMdevTypesCaps(const char *sysfspath, + virMediatedDeviceTypePtr **mdev_types, + size_t *nmdev_types) { virMediatedDeviceTypePtr *types =3D NULL; size_t ntypes =3D 0; size_t i; =20 /* this could be a refresh, so clear out the old data */ - for (i =3D 0; i < pci_dev->nmdev_types; i++) - virMediatedDeviceTypeFree(pci_dev->mdev_types[i]); - VIR_FREE(pci_dev->mdev_types); - pci_dev->nmdev_types =3D 0; - pci_dev->flags &=3D ~VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; + for (i =3D 0; i < *nmdev_types; i++) + virMediatedDeviceTypeFree(*mdev_types[i]); + VIR_FREE(*mdev_types); + *nmdev_types =3D 0; =20 if (virMediatedDeviceGetMdevTypes(sysfspath, &types, &ntypes) < 0) return -1; =20 - pci_dev->mdev_types =3D g_steal_pointer(&types); - pci_dev->nmdev_types =3D ntypes; - pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; + *mdev_types =3D g_steal_pointer(&types); + *nmdev_types =3D ntypes; =20 return 0; } @@ -2606,9 +2605,17 @@ virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath, virNodeDevCapPCIDevPtr pci_dev) { if (virNodeDeviceGetPCISRIOVCaps(sysfsPath, pci_dev) < 0 || - virNodeDeviceGetPCIIOMMUGroupCaps(pci_dev) < 0 || - virNodeDeviceGetPCIMdevTypesCaps(sysfsPath, pci_dev) < 0) + virNodeDeviceGetPCIIOMMUGroupCaps(pci_dev) < 0) + return -1; + + pci_dev->flags &=3D ~VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; + if (virNodeDeviceGetMdevTypesCaps(sysfsPath, + &pci_dev->mdev_types, + &pci_dev->nmdev_types) < 0) return -1; + if (pci_dev->nmdev_types > 0) + pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; + return 0; } =20 --=20 2.25.1