From nobody Thu May 2 04:01:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1603474361; cv=none; d=zohomail.com; s=zohoarc; b=RpGbbP+HhLdBLcTW4yqlCD9+niOhLPuTDCtS7trRhsJuiZPice88GLOe6rybC3GH0ohtQBnfvLZac06BKb6FtBOXr6/n+olVoFNqxVHuoSwZzY0NDJXoWYL1AWbTHFzvBTtV4b3l8vTCib2hBN5UNa9Sc3UCBjR959IKqIjb7oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474361; 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=9IFUm4rAeefHXGsct8ZuSSb+SG5cizYeyweUy5YL9+c=; b=O8Djjqk20lFrPyCGlNwbl0ZbJabzPZLTUrOgboD91lFY9FJVU6dy3RGOkjdEmoIJL0JSqf7gyTzRRTzwtd5OrlGoJD74CjxkJ3yavGjnMkVwvzC+rPPuohIV6DeTV22DmBYah2VVONNTByBspN3Wh5mhbVsYKNZqg5GxWqIG9eg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603474361245446.2209514674287; Fri, 23 Oct 2020 10:32:41 -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-453-h21qXaFsMG2DRqOCXxDu1w-1; Fri, 23 Oct 2020 13:32:37 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36971804B71; Fri, 23 Oct 2020 17:32:31 +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 147EC55762; Fri, 23 Oct 2020 17:32:31 +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 D4CF792314; Fri, 23 Oct 2020 17:32:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHWTIX000807 for ; Fri, 23 Oct 2020 13:32:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 121442156A37; Fri, 23 Oct 2020 17:32:29 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CAAD2156A36 for ; Fri, 23 Oct 2020 17:32:29 +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 D78CA185A794 for ; Fri, 23 Oct 2020 17:32:28 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-TqzguUCkMsOx_rwGMBh2ww-1; Fri, 23 Oct 2020 13:32:26 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHWMHm099976; Fri, 23 Oct 2020 13:32:25 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 34byj08b1j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:24 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHMa7O017875; Fri, 23 Oct 2020 17:32:08 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma05fra.de.ibm.com with ESMTP id 347r883j8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:07 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09NHW58Y23003494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:05 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EF804203F; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70AF142041; Fri, 23 Oct 2020 17:32:05 +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: h21qXaFsMG2DRqOCXxDu1w-1 X-MC-Unique: TqzguUCkMsOx_rwGMBh2ww-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 01/10] conf: node_device: fix mdev_types format and XML parsing code to match schema Date: Fri, 23 Oct 2020 19:31:43 +0200 Message-Id: <20201023173152.45238-2-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 bulkscore=0 clxscore=1015 phishscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 adultscore=0 spamscore=0 lowpriorityscore=0 impostorscore=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.6 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.15 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" The nodedev schema defines that a mdev_types capability must have one or more type elements. The XML parsing and the format allows to accept and to write mdev_types capability without any type element. This patches fixes this. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 40 ++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4adfdef572..3fbe9338ee 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -276,25 +276,27 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, virPCIHeaderTypeToString(data->pci_dev.hdrType)); } if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < data->pci_dev.nmdev_types; i++) { - virMediatedDeviceTypePtr type =3D data->pci_dev.mdev_types[i]; - virBufferEscapeString(buf, "\n", type->id); + if (data->pci_dev.nmdev_types > 0) { + virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - if (type->name) - virBufferEscapeString(buf, "%s\n", - type->name); - virBufferEscapeString(buf, "%s\n", - type->device_api); - virBufferAsprintf(buf, - "%u= \n", - type->available_instances); + for (i =3D 0; i < data->pci_dev.nmdev_types; i++) { + virMediatedDeviceTypePtr type =3D data->pci_dev.mdev_types= [i]; + virBufferEscapeString(buf, "\n", type->id); + virBufferAdjustIndent(buf, 2); + if (type->name) + virBufferEscapeString(buf, "%s\n", + type->name); + virBufferEscapeString(buf, "%s\n", + type->device_api); + virBufferAsprintf(buf, + "%u\n", + type->available_instances); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferAddLit(buf, "\n"); } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); } if (data->pci_dev.nIommuGroupDevices) { virBufferAsprintf(buf, "\n", @@ -1520,6 +1522,12 @@ virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr= ctxt, if ((nmdev_types =3D virXPathNodeSet("./type", ctxt, &nodes)) < 0) goto cleanup; =20 + if (nmdev_types =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing element in element")= ); + goto cleanup; + } + orignode =3D ctxt->node; for (i =3D 0; i < nmdev_types; i++) { ctxt->node =3D nodes[i]; --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1603474383; cv=none; d=zohomail.com; s=zohoarc; b=HSyIbDwilOX0rRMPI/vZxC9tIb1SR7lWLyM9cKalLLjrZ2gPZR8kyQGg4JMFMHPA1EIbDgBw+mkbgVC3+zY0+MHBKqfKuULa8CvIaDCsB7AdN1UzAM0QVtXkZTBG5MRXZE5xHAUzcierpacotcz9xo6yYkPn7vpy9uVdz/LK1aQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474383; 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=xGyDwLtPclGN2ORP8tMdyDH44kK8aWBc4MDcfOvG6I0=; b=KGky8V0+jrRRkcrLIraOVXGhp6uTQfucoIwhZhcAmrGkpjYVj6VmsUZ2f1BMPOTdCLMsMNZ8M1yN5GD20g9vcnIFBep4njknloqRkySIAuJUw+fionEVV+t6OfQGzOkS9alq6F5xOPQuCOmKWAP+vnR4+zsMuYhj85qxhBl+/eg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603474383832663.3783316856493; Fri, 23 Oct 2020 10:33:03 -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-Jg4glmHlM9y6Wbjppe3rQw-1; Fri, 23 Oct 2020 13:32:23 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 409CF5F9DF; Fri, 23 Oct 2020 17:32:17 +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 16C1175124; 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 8CAB5181A050; 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 09NHWF9w000739 for ; Fri, 23 Oct 2020 13:32:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 215CD110DBFC; Fri, 23 Oct 2020 17:32:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CC12110DBEC for ; Fri, 23 Oct 2020 17:32:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 C8EC08582BA for ; Fri, 23 Oct 2020 17:32:12 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-Wugxi2ovM2Wl9ksOCr6JzA-1; Fri, 23 Oct 2020 13:32:10 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NH5lQn056358; Fri, 23 Oct 2020 13:32:10 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 34b73s0dhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:09 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHOQFv005171; Fri, 23 Oct 2020 17:32:08 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03ams.nl.ibm.com with ESMTP id 348d5qx0tu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:07 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09NHW5IH23265654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:05 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC98B4203F; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C29F4204D; Fri, 23 Oct 2020 17:32:05 +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: Jg4glmHlM9y6Wbjppe3rQw-1 X-MC-Unique: Wugxi2ovM2Wl9ksOCr6JzA-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 02/10] util: refactor mdev_types method from PCI to mdev Date: Fri, 23 Oct 2020 19:31:44 +0200 Message-Id: <20201023173152.45238-3-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_09:2020-10-23, 2020-10-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 suspectscore=3 mlxlogscore=999 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230107 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.15 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" Extract virPCIGetMdevTypes from PCI as virMediatedDeviceGetMdevTypes into mdev for later reuse. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 2 +- src/libvirt_private.syms | 2 +- src/util/virmdev.c | 65 +++++++++++++++++++++++++++++++++++++ src/util/virmdev.h | 4 +++ src/util/virpci.c | 60 ---------------------------------- src/util/virpci.h | 3 -- 6 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 3fbe9338ee..db1258436a 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2584,7 +2584,7 @@ virNodeDeviceGetPCIMdevTypesCaps(const char *sysfspat= h, pci_dev->nmdev_types =3D 0; pci_dev->flags &=3D ~VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; =20 - rc =3D virPCIGetMdevTypes(sysfspath, &types); + rc =3D virMediatedDeviceGetMdevTypes(sysfspath, &types); =20 if (rc <=3D 0) return rc; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 95e50835ad..9029ea4fa2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2509,6 +2509,7 @@ virMediatedDeviceAttrNew; virMediatedDeviceFree; virMediatedDeviceGetIOMMUGroupDev; virMediatedDeviceGetIOMMUGroupNum; +virMediatedDeviceGetMdevTypes; virMediatedDeviceGetSysfsPath; virMediatedDeviceGetUsedBy; virMediatedDeviceIsUsed; @@ -2845,7 +2846,6 @@ virPCIELinkSpeedTypeFromString; virPCIELinkSpeedTypeToString; virPCIGetDeviceAddressFromSysfsLink; virPCIGetHeaderType; -virPCIGetMdevTypes; virPCIGetNetName; virPCIGetPhysicalFunction; virPCIGetVirtualFunctionIndex; diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 31994631ed..80f5f2a767 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -522,3 +522,68 @@ void virMediatedDeviceAttrFree(virMediatedDeviceAttrPt= r attr) g_free(attr->value); g_free(attr); } + + +#ifdef __linux__ + +ssize_t +virMediatedDeviceGetMdevTypes(const char *sysfspath, + virMediatedDeviceTypePtr **types) +{ + ssize_t ret =3D -1; + int dirret =3D -1; + DIR *dir =3D NULL; + struct dirent *entry; + g_autofree char *types_path =3D NULL; + g_autoptr(virMediatedDeviceType) mdev_type =3D NULL; + virMediatedDeviceTypePtr *mdev_types =3D NULL; + size_t ntypes =3D 0; + size_t i; + + types_path =3D g_strdup_printf("%s/mdev_supported_types", sysfspath); + + if ((dirret =3D virDirOpenIfExists(&dir, types_path)) < 0) + goto cleanup; + + if (dirret =3D=3D 0) { + ret =3D 0; + goto cleanup; + } + + while ((dirret =3D virDirRead(dir, &entry, types_path)) > 0) { + g_autofree char *tmppath =3D NULL; + /* append the type id to the path and read the attributes from the= re */ + tmppath =3D g_strdup_printf("%s/%s", types_path, entry->d_name); + + if (virMediatedDeviceTypeReadAttrs(tmppath, &mdev_type) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(mdev_types, ntypes, mdev_type) < 0) + goto cleanup; + } + + if (dirret < 0) + goto cleanup; + + *types =3D g_steal_pointer(&mdev_types); + ret =3D ntypes; + ntypes =3D 0; + cleanup: + for (i =3D 0; i < ntypes; i++) + virMediatedDeviceTypeFree(mdev_types[i]); + VIR_FREE(mdev_types); + VIR_DIR_CLOSE(dir); + return ret; +} + +#else + +ssize_t +virMediatedDeviceGetMdevTypes(const char *sysfspath G_GNUC_UNUSED, + virMediatedDeviceTypePtr **types G_GNUC_UNUS= ED) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return -1; +} + +#endif /* __linux__ */ diff --git a/src/util/virmdev.h b/src/util/virmdev.h index eb167ccb48..846e1662e7 100644 --- a/src/util/virmdev.h +++ b/src/util/virmdev.h @@ -149,5 +149,9 @@ int virMediatedDeviceTypeReadAttrs(const char *sysfspath, virMediatedDeviceTypePtr *type); =20 +ssize_t +virMediatedDeviceGetMdevTypes(const char *sysfspath, + virMediatedDeviceTypePtr **types); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDevice, virMediatedDeviceFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceType, virMediatedDeviceType= Free); diff --git a/src/util/virpci.c b/src/util/virpci.c index 1f679a7b45..2086a4270b 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2528,57 +2528,6 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_de= vice_path, return 0; } =20 - -ssize_t -virPCIGetMdevTypes(const char *sysfspath, - virMediatedDeviceTypePtr **types) -{ - ssize_t ret =3D -1; - int dirret =3D -1; - DIR *dir =3D NULL; - struct dirent *entry; - g_autofree char *types_path =3D NULL; - g_autoptr(virMediatedDeviceType) mdev_type =3D NULL; - virMediatedDeviceTypePtr *mdev_types =3D NULL; - size_t ntypes =3D 0; - size_t i; - - types_path =3D g_strdup_printf("%s/mdev_supported_types", sysfspath); - - if ((dirret =3D virDirOpenIfExists(&dir, types_path)) < 0) - goto cleanup; - - if (dirret =3D=3D 0) { - ret =3D 0; - goto cleanup; - } - - while ((dirret =3D virDirRead(dir, &entry, types_path)) > 0) { - g_autofree char *tmppath =3D NULL; - /* append the type id to the path and read the attributes from the= re */ - tmppath =3D g_strdup_printf("%s/%s", types_path, entry->d_name); - - if (virMediatedDeviceTypeReadAttrs(tmppath, &mdev_type) < 0) - goto cleanup; - - if (VIR_APPEND_ELEMENT(mdev_types, ntypes, mdev_type) < 0) - goto cleanup; - } - - if (dirret < 0) - goto cleanup; - - *types =3D g_steal_pointer(&mdev_types); - ret =3D ntypes; - ntypes =3D 0; - cleanup: - for (i =3D 0; i < ntypes; i++) - virMediatedDeviceTypeFree(mdev_types[i]); - VIR_FREE(mdev_types); - VIR_DIR_CLOSE(dir); - return ret; -} - #else static const char *unsupported =3D N_("not supported on non-linux platform= s"); =20 @@ -2653,15 +2602,6 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_de= vice_path G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); return -1; } - - -ssize_t -virPCIGetMdevTypes(const char *sysfspath G_GNUC_UNUSED, - virMediatedDeviceTypePtr **types G_GNUC_UNUSED) -{ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); - return -1; -} #endif /* __linux__ */ =20 int diff --git a/src/util/virpci.h b/src/util/virpci.h index 1f896ca481..43828b0a8a 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -275,9 +275,6 @@ int virPCIGetHeaderType(virPCIDevicePtr dev, int *hdrTy= pe); =20 void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev); =20 -ssize_t virPCIGetMdevTypes(const char *sysfspath, - virMediatedDeviceType ***types); - void virPCIDeviceAddressFree(virPCIDeviceAddressPtr address); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIDevice, virPCIDeviceFree); --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1603474355; cv=none; d=zohomail.com; s=zohoarc; b=e+SfkgxLwSX+DWsuX4a59hZxG3vvTHBkQ6MZv2suJO2TWRt2kQARBVHBc7nCDqzwK9IRT7c6Rx+r+jzddGkSB3TURo3wPXGVefNIqqfuL5kvbqDYyYTq5Ea0pUxvBlOzJEcBIa7VarU5uf19gxEsPl69sTr2yBjwIDR2xF83owI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474355; 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=czRBonqJdCeWwwKu27Rg5e5edgWElCqYW49sLu39W+k=; b=hZFa+zskJpfrAvXcVvjICTi83J+7Cpy12xfslTMNOSxeRNkACN0h9sbfxCqkXSdi+L99DAKV1VHYTu5OvGbMZjkdK33DKRz53T2pSwnlLMbmFPObUbeX9QI51VTsiuaeFkkPPnQ7TEKD7niD2SoyD/6p63jtNfvp/y8UFtBAdT4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603474355686487.44471491935496; Fri, 23 Oct 2020 10:32:35 -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-295-wjkDoRmkNI-zXEmqnRPgjw-1; Fri, 23 Oct 2020 13:32:31 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42E971007283; Fri, 23 Oct 2020 17:32:25 +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 1EC9F5B4C7; Fri, 23 Oct 2020 17:32:25 +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 E365C92311; Fri, 23 Oct 2020 17:32:24 +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 09NHWIlN000774 for ; Fri, 23 Oct 2020 13:32:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BD751000DBE; Fri, 23 Oct 2020 17:32:18 +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 97E9D1112861 for ; Fri, 23 Oct 2020 17:32:18 +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 70B2A102F1E0 for ; Fri, 23 Oct 2020 17:32:18 +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-550-p0VUUXm4PuS-iAuXF1iBcw-1; Fri, 23 Oct 2020 13:32:15 -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 09NHVrnV006358; Fri, 23 Oct 2020 13:32:14 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 34bx0s3dd1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:13 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHNHTQ029403; 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 ppma06ams.nl.ibm.com with ESMTP id 347qvheupk-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 09NHW6Fv31326590 (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 E921742042; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA8A542047; Fri, 23 Oct 2020 17:32:05 +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: wjkDoRmkNI-zXEmqnRPgjw-1 X-MC-Unique: p0VUUXm4PuS-iAuXF1iBcw-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 03/10] util: refactor mdev_types methods return code usage Date: Fri, 23 Oct 2020 19:31:45 +0200 Message-Id: <20201023173152.45238-4-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.11 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" Remove mix of array length and error code in the return code. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 10 ++++------ src/util/virmdev.c | 14 ++++++++------ src/util/virmdev.h | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index db1258436a..af8edded3c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2574,7 +2574,7 @@ virNodeDeviceGetPCIMdevTypesCaps(const char *sysfspat= h, virNodeDevCapPCIDevPtr pci_dev) { virMediatedDeviceTypePtr *types =3D NULL; - int rc =3D 0; + size_t ntypes =3D 0; size_t i; =20 /* this could be a refresh, so clear out the old data */ @@ -2584,13 +2584,11 @@ virNodeDeviceGetPCIMdevTypesCaps(const char *sysfsp= ath, pci_dev->nmdev_types =3D 0; pci_dev->flags &=3D ~VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; =20 - rc =3D virMediatedDeviceGetMdevTypes(sysfspath, &types); - - if (rc <=3D 0) - return rc; + if (virMediatedDeviceGetMdevTypes(sysfspath, &types, &ntypes) < 0) + return -1; =20 pci_dev->mdev_types =3D g_steal_pointer(&types); - pci_dev->nmdev_types =3D rc; + pci_dev->nmdev_types =3D ntypes; pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; =20 return 0; diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 80f5f2a767..b02005bd1a 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -528,7 +528,8 @@ void virMediatedDeviceAttrFree(virMediatedDeviceAttrPtr= attr) =20 ssize_t virMediatedDeviceGetMdevTypes(const char *sysfspath, - virMediatedDeviceTypePtr **types) + virMediatedDeviceTypePtr **types, + size_t *ntypes) { ssize_t ret =3D -1; int dirret =3D -1; @@ -537,7 +538,7 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, g_autofree char *types_path =3D NULL; g_autoptr(virMediatedDeviceType) mdev_type =3D NULL; virMediatedDeviceTypePtr *mdev_types =3D NULL; - size_t ntypes =3D 0; + size_t nmdev_types =3D 0; size_t i; =20 types_path =3D g_strdup_printf("%s/mdev_supported_types", sysfspath); @@ -558,7 +559,7 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, if (virMediatedDeviceTypeReadAttrs(tmppath, &mdev_type) < 0) goto cleanup; =20 - if (VIR_APPEND_ELEMENT(mdev_types, ntypes, mdev_type) < 0) + if (VIR_APPEND_ELEMENT(mdev_types, nmdev_types, mdev_type) < 0) goto cleanup; } =20 @@ -566,10 +567,11 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, goto cleanup; =20 *types =3D g_steal_pointer(&mdev_types); - ret =3D ntypes; - ntypes =3D 0; + *ntypes =3D nmdev_types; + nmdev_types =3D 0; + ret =3D 0; cleanup: - for (i =3D 0; i < ntypes; i++) + for (i =3D 0; i < nmdev_types; i++) virMediatedDeviceTypeFree(mdev_types[i]); VIR_FREE(mdev_types); VIR_DIR_CLOSE(dir); diff --git a/src/util/virmdev.h b/src/util/virmdev.h index 846e1662e7..b6563a94fc 100644 --- a/src/util/virmdev.h +++ b/src/util/virmdev.h @@ -151,7 +151,8 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, =20 ssize_t virMediatedDeviceGetMdevTypes(const char *sysfspath, - virMediatedDeviceTypePtr **types); + virMediatedDeviceTypePtr **types, + size_t *ntypes); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDevice, virMediatedDeviceFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceType, virMediatedDeviceType= Free); --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 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 From nobody Thu May 2 04:01:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1603474352; cv=none; d=zohomail.com; s=zohoarc; b=aYGKpHn1HcZLKSh50D/SeruqZToHAQOD8CqnNYh1jTKyzpSN/coMUIL6hWBlANmz2DYe8d+KiVRofqVh9SSSRa3788ZG6Af85dr3ungUr4HQha3g/fI9wi9gGVe2Gerdeppb5lTAEsooXlo1T0rvxAuqK88jvxYUydEBv2Kt/1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474352; 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=01pRtdk9oCiP+jxSA0UWoX0TeO/wSXbtmxGg+7mxq3g=; b=exPb7Jhq4wqjcyjxitB0/T4OTQY/f1ElHUTKHr0bz/dKJGhEgOQU/0HVewKsmcEWcLiMn9vNbDtwSFXSO/jq+lrle8lZD7rg4zokm/aC9wBISEV8HvjV52LpO+cVlETZcwKJm1MjPLQM0FqzJvKiKM5SM9OTATeLBjdevZNGAZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603474352706212.51997875721224; Fri, 23 Oct 2020 10:32:32 -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-511-Sarx5UHsM2eyAoZvPP6_Hw-1; Fri, 23 Oct 2020 13:32:28 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23E0E1006CB5; Fri, 23 Oct 2020 17:32:22 +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 F14C31001281; Fri, 23 Oct 2020 17:32:21 +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 BFE6C9230E; Fri, 23 Oct 2020 17:32:21 +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 09NHWFv1000749 for ; Fri, 23 Oct 2020 13:32:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id CCC2B1000DBE; Fri, 23 Oct 2020 17:32:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C86FB110DBE8 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 A1B57800962 for ; Fri, 23 Oct 2020 17:32:15 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-udhFt-DlNAOkdADrftRxkA-1; Fri, 23 Oct 2020 13:32:11 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NH9nnF059439; Fri, 23 Oct 2020 13:32:10 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 34b73s0dj8-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 (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHMF0Q028895; 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 ppma06ams.nl.ibm.com with ESMTP id 347qvheupm-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 09NHW6Ck29360484 (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 4E3914204B; 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 2F35F4203F; 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:06 +0000 (GMT) X-MC-Unique: Sarx5UHsM2eyAoZvPP6_Hw-1 X-MC-Unique: udhFt-DlNAOkdADrftRxkA-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 05/10] conf: node_device: refactor capability mdev_types formating Date: Fri, 23 Oct 2020 19:31:47 +0200 Message-Id: <20201023173152.45238-6-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_09:2020-10-23, 2020-10-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 suspectscore=1 mlxlogscore=999 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230107 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.84 on 10.5.11.22 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" Extract the XML formating for mdev_types from PCI capability into a generic standalone method for later reuse. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 811d102208..dce04ad4f0 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -206,6 +206,37 @@ virNodeDeviceCapSystemDefFormat(virBufferPtr buf, } =20 =20 +static void +virNodeDeviceCapMdevTypesFormat(virBufferPtr buf, + virMediatedDeviceTypePtr *mdev_types, + const size_t nmdev_types) +{ + size_t i; + + if (nmdev_types > 0) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (i =3D 0; i < nmdev_types; i++) { + virMediatedDeviceTypePtr type =3D mdev_types[i]; + virBufferEscapeString(buf, "\n", type->id); + virBufferAdjustIndent(buf, 2); + if (type->name) + virBufferEscapeString(buf, "%s\n", + type->name); + virBufferEscapeString(buf, "%s\n", + type->device_api); + virBufferAsprintf(buf, + "%u= \n", + type->available_instances); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } +} + + static void virNodeDeviceCapPCIDefFormat(virBufferPtr buf, const virNodeDevCapData *data) @@ -276,27 +307,9 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, virPCIHeaderTypeToString(data->pci_dev.hdrType)); } if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { - if (data->pci_dev.nmdev_types > 0) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < data->pci_dev.nmdev_types; i++) { - virMediatedDeviceTypePtr type =3D data->pci_dev.mdev_types= [i]; - virBufferEscapeString(buf, "\n", type->id); - virBufferAdjustIndent(buf, 2); - if (type->name) - virBufferEscapeString(buf, "%s\n", - type->name); - virBufferEscapeString(buf, "%s\n", - type->device_api); - virBufferAsprintf(buf, - "%u\n", - type->available_instances); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virNodeDeviceCapMdevTypesFormat(buf, + data->pci_dev.mdev_types, + data->pci_dev.nmdev_types); } if (data->pci_dev.nIommuGroupDevices) { virBufferAsprintf(buf, "\n", --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 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=1603474430; cv=none; d=zohomail.com; s=zohoarc; b=M5VjewwSysjzU+0AyNcZTOhdpZTj1Zp/5y0YMaDfduqsQBTjfXmUAZ3OszreETIMN4h3MXAE6C96I6xizRQowsO+lYlUAq+x4zszPCwyTC37lXEmjGFOzlTN2axMpJUqrm6eZrwohvEGe70ia3z6wTtVRLAQ0fdpn7fMoeNrcNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474430; 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=yD2vlEgCyOm8z9OOcwBAzj3chO6GpjW6KQAkSfQjOl4=; b=BvMkr4r5CyVuoXmI6prLn3RVt1RS6GQTxsYVoS4mmJhS6O+hIO3P3W/epNCD13f+DK1/HC8gJgOx80kmdVFdX012yKeWTte4q6P6FF6fD4n59ESvs2gy/qTAUBnxNgGD+hEoKr5kTIFMiFSNv3M/bPlElbEGU9frg9Lh9b3PWFs= 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 1603474430211397.8239662499602; Fri, 23 Oct 2020 10:33:50 -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-546-fPbu3tzCNoe9W0A40aQoXQ-1; Fri, 23 Oct 2020 13:33:47 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D327610866B8; Fri, 23 Oct 2020 17:33:41 +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 ADFC61002C18; Fri, 23 Oct 2020 17:33:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7C2F2181A06B; Fri, 23 Oct 2020 17:33:41 +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 09NHXeap001058 for ; Fri, 23 Oct 2020 13:33:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2026B1112861; Fri, 23 Oct 2020 17:33:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C27A110DBEC for ; Fri, 23 Oct 2020 17:33:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 CC70C858284 for ; Fri, 23 Oct 2020 17:33:37 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-_QJ6If_gOsuseG314h4_1A-1; Fri, 23 Oct 2020 13:33:35 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHWwTj189119; Fri, 23 Oct 2020 13:33:35 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 34bh714pkq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:33:32 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHOMIb027458; Fri, 23 Oct 2020 17:32:09 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma01fra.de.ibm.com with ESMTP id 347r883j9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:09 +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 09NHW6DF29360486 (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 7EA9442042; 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 5C79042052; 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:06 +0000 (GMT) X-MC-Unique: fPbu3tzCNoe9W0A40aQoXQ-1 X-MC-Unique: _QJ6If_gOsuseG314h4_1A-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 06/10] conf: node_device: refactor mdev_types XML parsing Date: Fri, 23 Oct 2020 19:31:48 +0200 Message-Id: <20201023173152.45238-7-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 lowpriorityscore=0 mlxlogscore=988 spamscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 mlxscore=0 bulkscore=0 suspectscore=3 phishscore=0 adultscore=0 clxscore=1015 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.84 on 10.5.11.22 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" Extract PCI code from virNodeDevPCICapMdevTypesParseXML to make method virNodeDevCapMdevTypesParseXML generic for later reuse. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 141 ++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index dce04ad4f0..6fd5b1b038 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -757,6 +757,72 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, } =20 =20 +static int +virNodeDevCapMdevTypesParseXML(xmlXPathContextPtr ctxt, + virMediatedDeviceTypePtr **mdev_types, + size_t *nmdev_types) +{ + int ret =3D -1; + xmlNodePtr orignode =3D NULL; + xmlNodePtr *nodes =3D NULL; + int ntypes =3D -1; + virMediatedDeviceTypePtr type =3D NULL; + size_t i; + + if ((ntypes =3D virXPathNodeSet("./type", ctxt, &nodes)) < 0) + goto cleanup; + + if (nmdev_types =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing element in element")= ); + goto cleanup; + } + + orignode =3D ctxt->node; + for (i =3D 0; i < ntypes; i++) { + ctxt->node =3D nodes[i]; + + type =3D g_new0(virMediatedDeviceType, 1); + + if (!(type->id =3D virXPathString("string(./@id[1])", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing 'id' attribute for mediated device's= " + " element")); + goto cleanup; + } + + if (!(type->device_api =3D virXPathString("string(./deviceAPI[1])"= , ctxt))) { + virReportError(VIR_ERR_XML_ERROR, + _("missing device API for mediated device type = '%s'"), + type->id); + goto cleanup; + } + + if (virXPathUInt("number(./availableInstances)", ctxt, + &type->available_instances) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("missing number of available instances for " + "mediated device type '%s'"), + type->id); + goto cleanup; + } + + type->name =3D virXPathString("string(./name)", ctxt); + + if (VIR_APPEND_ELEMENT(*mdev_types, + *nmdev_types, type) < 0) + goto cleanup; + } + + ret =3D 0; + cleanup: + VIR_FREE(nodes); + virMediatedDeviceTypeFree(type); + ctxt->node =3D orignode; + return ret; +} + + static int virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def, @@ -1521,72 +1587,6 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContext= Ptr ctxt, } =20 =20 -static int -virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr ctxt, - virNodeDevCapPCIDevPtr pci_dev) -{ - int ret =3D -1; - xmlNodePtr orignode =3D NULL; - xmlNodePtr *nodes =3D NULL; - int nmdev_types =3D -1; - virMediatedDeviceTypePtr type =3D NULL; - size_t i; - - if ((nmdev_types =3D virXPathNodeSet("./type", ctxt, &nodes)) < 0) - goto cleanup; - - if (nmdev_types =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing element in element")= ); - goto cleanup; - } - - orignode =3D ctxt->node; - for (i =3D 0; i < nmdev_types; i++) { - ctxt->node =3D nodes[i]; - - type =3D g_new0(virMediatedDeviceType, 1); - - if (!(type->id =3D virXPathString("string(./@id[1])", ctxt))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing 'id' attribute for mediated device's= " - " element")); - goto cleanup; - } - - if (!(type->device_api =3D virXPathString("string(./deviceAPI[1])"= , ctxt))) { - virReportError(VIR_ERR_XML_ERROR, - _("missing device API for mediated device type = '%s'"), - type->id); - goto cleanup; - } - - if (virXPathUInt("number(./availableInstances)", ctxt, - &type->available_instances) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("missing number of available instances for " - "mediated device type '%s'"), - type->id); - goto cleanup; - } - - type->name =3D virXPathString("string(./name)", ctxt); - - if (VIR_APPEND_ELEMENT(pci_dev->mdev_types, - pci_dev->nmdev_types, type) < 0) - goto cleanup; - } - - pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; - ret =3D 0; - cleanup: - VIR_FREE(nodes); - virMediatedDeviceTypeFree(type); - ctxt->node =3D orignode; - return ret; -} - - static int virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, @@ -1609,9 +1609,12 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr c= txt, } else if (STREQ(type, "virt_functions") && virNodeDevPCICapSRIOVVirtualParseXML(ctxt, pci_dev) < 0) { goto cleanup; - } else if (STREQ(type, "mdev_types") && - virNodeDevPCICapMdevTypesParseXML(ctxt, pci_dev) < 0) { - goto cleanup; + } else if (STREQ(type, "mdev_types")) { + if (virNodeDevCapMdevTypesParseXML(ctxt, + &pci_dev->mdev_types, + &pci_dev->nmdev_types) < 0) + goto cleanup; + pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; } else { int hdrType =3D virPCIHeaderTypeFromString(type); =20 --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 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=1603474655; cv=none; d=zohomail.com; s=zohoarc; b=ZiN7QRdQlQKi8rAGEUH1zxmV+cfgHs/8mTnsrU1L+hoJZTZItnLYmxIjIIOmyy+hv8HMB54E9plI7/mIHw79KxRC6u5wzrmUAF1mZN9t6hP9+j2lIHTb7ALtQz66eSkRj/K29ePSkxBYQ68AkxoaeRKistWM5LHdY2H8cdei4/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474655; 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=12m5KfRpgOZlnfxdR02S15uVp1nH8M5F/eZBOyjW/Mk=; b=RH5Y1SPMMZT2pkweDjXk8jZROVVWjG9QkXTjpKKm2lUOLvVZBNUCmIpQB68JtZHjC3wE1mdo47k29ooWyLdAr6yNrxJ8+7qKZfHpvnchWjjnAs+n1OgdYwk1d6OpaX53P5YzvIMVgv8cElNBEmN2cM/10jV4xSCUtrrxwXlCFK8= 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 1603474654961688.753998120532; Fri, 23 Oct 2020 10:37:34 -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-578-FnURqZ-nP723KgMGxLlH-g-1; Fri, 23 Oct 2020 13:37:31 -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 F1322640A0; Fri, 23 Oct 2020 17:37:25 +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 92AEA5D9CC; Fri, 23 Oct 2020 17:37:24 +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 A394492304; Fri, 23 Oct 2020 17:37:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHbKBk001444 for ; Fri, 23 Oct 2020 13:37:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2AC5207A524; Fri, 23 Oct 2020 17:37:20 +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 CDBA7207A641 for ; Fri, 23 Oct 2020 17:37:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 2F14E102F1E1 for ; Fri, 23 Oct 2020 17:37:17 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-jFya2kI-Pm-EwTeDpDRu7w-1; Fri, 23 Oct 2020 13:37:11 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHWEOW002178; Fri, 23 Oct 2020 13:37:11 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 34c1ct4w8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:37:10 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHMF0R028895; Fri, 23 Oct 2020 17:32:09 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 347qvheupn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:09 +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 09NHW6ou21496228 (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 AF8264203F; 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 8AE8F4204D; 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:06 +0000 (GMT) X-MC-Unique: FnURqZ-nP723KgMGxLlH-g-1 X-MC-Unique: jFya2kI-Pm-EwTeDpDRu7w-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 07/10] conf: node_device: refactor CSS formating Date: Fri, 23 Oct 2020 19:31:49 +0200 Message-Id: <20201023173152.45238-8-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_09:2020-10-23, 2020-10-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 suspectscore=1 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=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.4 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" Move XML formating code into a new method. Signed-off-by: Boris Fiuczynski Reviewed-by: Marc Hartmayer Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 6fd5b1b038..ebabf20b67 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -533,6 +533,20 @@ virNodeDeviceCapMdevDefFormat(virBufferPtr buf, } } =20 + +static void +virNodeDeviceCapCCWDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + virBufferAsprintf(buf, "0x%x\n", + data->ccw_dev.cssid); + virBufferAsprintf(buf, "0x%x\n", + data->ccw_dev.ssid); + virBufferAsprintf(buf, "0x%04x\n", + data->ccw_dev.devno); +} + + char * virNodeDeviceDefFormat(const virNodeDeviceDef *def) { @@ -619,12 +633,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) break; case VIR_NODE_DEV_CAP_CCW_DEV: case VIR_NODE_DEV_CAP_CSS_DEV: - virBufferAsprintf(&buf, "0x%x\n", - data->ccw_dev.cssid); - virBufferAsprintf(&buf, "0x%x\n", - data->ccw_dev.ssid); - virBufferAsprintf(&buf, "0x%04x\n", - data->ccw_dev.devno); + virNodeDeviceCapCCWDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_FC_HOST: --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 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=1603474380; cv=none; d=zohomail.com; s=zohoarc; b=K45ek3Ao24zZolujWEWSha5sBlSg4czE3eDHigyER2rTZUL3unC1fjDvI9aQweb9lX1L0/dtXZ0Mvsghjvzpdwa2jc3HgoLIdPlUGjatNrGuIjuxeehjcU4eFxMjOSfWZKcTsSTKJKQ3nnc0GokyQP12Km1jF8HCZ4U/WHOeJEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474380; 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=qF+VGkeH6WDZ2rzO52YBA64QpFKn8+vmh7A2oMHRBYY=; b=Ng+ZOQOMhtCQrsEqSE6aZmumnlMlLsjaexWuR2GXPOWnCeaMsqDIuiwu8aj7HGUgtAcvQmORtyqE6Tvarm/ydH/CNZgFVvmPxQWA0kk2SADohQTKqATWBOS/uCg/fygBmBUVnXE2BabJlguA4mHsWNiSzT4FIz3QSXVUOnKe2gs= 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 1603474380883358.09903066982315; Fri, 23 Oct 2020 10:33:00 -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-60-c5uJFsU4PiK0s5y8sIagag-1; Fri, 23 Oct 2020 13:32:57 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC2AA10866B0; Fri, 23 Oct 2020 17:32: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 A8BBD5B4C1; Fri, 23 Oct 2020 17:32: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 781FB92318; Fri, 23 Oct 2020 17:32:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHWnIv000900 for ; Fri, 23 Oct 2020 13:32:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42C322156A36; Fri, 23 Oct 2020 17:32:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DB322156A3A for ; Fri, 23 Oct 2020 17:32:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 147F48D632C for ; Fri, 23 Oct 2020 17:32:46 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-SFw63MyeO7GML6P0C4_2KQ-1; Fri, 23 Oct 2020 13:32:41 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHWZr1100623; Fri, 23 Oct 2020 13:32:39 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 34bd0srm8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:38 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHMpiQ024503; Fri, 23 Oct 2020 17:32:09 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 347r88ev5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:09 +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 09NHW6Le18678192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:07 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBF9342049; 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 BCAC242045; 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:06 +0000 (GMT) X-MC-Unique: c5uJFsU4PiK0s5y8sIagag-1 X-MC-Unique: SFw63MyeO7GML6P0C4_2KQ-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 08/10] schema: refactor mdev_types out of PCI nodedev schema Date: Fri, 23 Oct 2020 19:31:50 +0200 Message-Id: <20201023173152.45238-9-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 lowpriorityscore=0 malwarescore=0 phishscore=0 suspectscore=1 spamscore=0 impostorscore=0 mlxscore=0 adultscore=0 mlxlogscore=885 bulkscore=0 priorityscore=1501 clxscore=1015 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.6 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.11 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" Refactor mdev_types into standalone define for later reuse. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- docs/schemas/nodedev.rng | 48 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 166e278cf8..9548412999 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -215,27 +215,7 @@ =20 - - - mdev_types - - - - - - - - - - - vfio-pci - - - - - - - + =20 @@ -696,4 +676,30 @@ =20 + + + + mdev_types + + + + + + + + + + + + vfio-pci + + + + + + + + + + --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1603474353; cv=none; d=zohomail.com; s=zohoarc; b=akmVPoGfB5O9M6n6pOYW/S2d9srhcZd2TWWdsDQ7aTwesnVRHh/qhkzjhqZ3aB/wsxQOGRXDKrTcbFqxUgC3ExaZMmexKEkZWioX33tSe1u/f1FvHGjkX9cGKYH7zans+jMr5JJwVmPHxN2yFcYm9cnMt36D13laZmT6DTT9ahI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474353; 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=luhDiNRx/YKYL8mGmHNGObUS33IZ5nD9p0js1Un/X+U=; b=ZELCc4EPqssuwzbvMF6eSWOcFf5esoOEcG8glO0rgkoyzUUm2UVJ2+1P40KwXLQhlQSpyWLJ+oTlP7jzIBziYm9B4ZmQvrxIxttMxvJbwTCL7Ff/jNXLigQ2f8vVwETOHs8x7w1KhZ/iuB9etrAvtKS5RJP2xtfH+xlWIP/jZ50= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603474353036801.8287797575961; Fri, 23 Oct 2020 10:32:33 -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-463-lytxcL9HMRebHI29JlfbYw-1; Fri, 23 Oct 2020 13:32:29 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 702A1807339; Fri, 23 Oct 2020 17:32:23 +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 4FAC79CBA0; Fri, 23 Oct 2020 17:32: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 1E1E09230F; Fri, 23 Oct 2020 17:32:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHWJdP000779 for ; Fri, 23 Oct 2020 13:32:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id E52B22156A3C; Fri, 23 Oct 2020 17:32:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFD5B2156A39 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 7064C858284 for ; Fri, 23 Oct 2020 17:32:15 +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-484-Akonxrw9N9ijDwLv6i_3MA-1; Fri, 23 Oct 2020 13:32:12 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHVked095887; Fri, 23 Oct 2020 13:32:11 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 34c1w0bg1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:11 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHNQkW004113; Fri, 23 Oct 2020 17:32:09 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 348d5qx0tw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:09 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09NHW7ZD20447552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:07 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1397542049; Fri, 23 Oct 2020 17:32:07 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E87B54204D; 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:06 +0000 (GMT) X-MC-Unique: lytxcL9HMRebHI29JlfbYw-1 X-MC-Unique: Akonxrw9N9ijDwLv6i_3MA-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 09/10] conf: node_device: cleanup virNodeDevCapCCWParseXML Date: Fri, 23 Oct 2020 19:31:51 +0200 Message-Id: <20201023173152.45238-10-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 lowpriorityscore=0 adultscore=0 spamscore=0 suspectscore=3 mlxlogscore=999 bulkscore=0 malwarescore=0 phishscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 impostorscore=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.6 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.13 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" Make use of g_autofree Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index ebabf20b67..39950565b5 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -839,57 +839,52 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, virNodeDevCapCCWPtr ccw_dev) { VIR_XPATH_NODE_AUTORESTORE(ctxt) - int ret =3D -1; - char *cssid =3D NULL, *ssid =3D NULL, *devno =3D NULL; + g_autofree char *cssid =3D NULL; + g_autofree char *ssid =3D NULL; + g_autofree char *devno =3D NULL; =20 ctxt->node =3D node; =20 - if (!(cssid =3D virXPathString("string(./cssid[1])", ctxt))) { + if (!(cssid =3D virXPathString("string(./cssid[1])", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing cssid value for '%s'"), def->name); - goto out; + return -1; } =20 if (virStrToLong_uip(cssid, NULL, 0, &ccw_dev->cssid) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid cssid value '%s' for '%s'"), cssid, def->name); - goto out; + return -1; } =20 if (!(ssid =3D virXPathString("string(./ssid[1])", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing ssid value for '%s'"), def->name); - goto out; + return -1; } =20 if (virStrToLong_uip(ssid, NULL, 0, &ccw_dev->ssid) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid ssid value '%s' for '%s'"), cssid, def->name); - goto out; + return -1; } =20 if (!(devno =3D virXPathString("string(./devno[1])", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing devno value for '%s'"), def->name); - goto out; + return -1; } =20 if (virStrToLong_uip(devno, NULL, 16, &ccw_dev->devno) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid devno value '%s' for '%s'"), devno, def->name); - goto out; + return -1; } =20 - ret =3D 0; - - out: - VIR_FREE(cssid); - VIR_FREE(ssid); - VIR_FREE(devno); - return ret; + return 0; } =20 =20 --=20 2.25.1 From nobody Thu May 2 04:01:51 2024 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=1603474370; cv=none; d=zohomail.com; s=zohoarc; b=IjokosFx516iNZvnpFByodSSmmWJDlGYAow3IbLJP/EE/ZItA2kUNmbIFYCo9MBzj6eQfmO1Mpudv+xpFzLcL1iwZPMSS1l90Co5M/+6WeQaofBefzUiKM8MienSu40+z6g0BSf8Ep6TWN6Fas18IIr1mEnQtz/0KIYkmc4wK5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474370; 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=ZvHWBBfQYM1cM5NEoYW5QtsicJWpOelr9NOOFvoUW0M=; b=T6aoRonlyl5SaBmdGKVDtb8fsHGffcRnmutGDLZ9nzI4V8ntdk6YOYQ2sfA7cb9Z8R3lzAfphjQrUo32cwUzDwfLHymGW76HLKKb6d19jOLqNvubCgiP389htKdQHUr/dHQnqm9oNyefoA7CsB7GCvV4nSIpH2oEaL5g6blp5xM= 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 1603474370358812.0982326149827; Fri, 23 Oct 2020 10:32:50 -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-432-RolsZWS_Oym9lkLozj7FBg-1; Fri, 23 Oct 2020 13:32:46 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0574210866A8; Fri, 23 Oct 2020 17:32:41 +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 D909D5B4B3; Fri, 23 Oct 2020 17:32: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 A61FD181A06C; Fri, 23 Oct 2020 17:32:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHWdEi000838 for ; Fri, 23 Oct 2020 13:32:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 196EC207A524; Fri, 23 Oct 2020 17:32:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 143E9207A645 for ; Fri, 23 Oct 2020 17:32:36 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 DDB79811E78 for ; Fri, 23 Oct 2020 17:32:35 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-bHiJZljkNDmX965lbXdxEQ-1; Fri, 23 Oct 2020 13:32:33 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHWTZK033217; Fri, 23 Oct 2020 13:32:32 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 34bvm2x9n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:32 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHMnd5024495; Fri, 23 Oct 2020 17:32:09 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 347r88ev5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:09 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09NHW73c32571736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:07 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40F2842056; Fri, 23 Oct 2020 17:32:07 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20D3E42052; Fri, 23 Oct 2020 17:32:07 +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:07 +0000 (GMT) X-MC-Unique: RolsZWS_Oym9lkLozj7FBg-1 X-MC-Unique: bHiJZljkNDmX965lbXdxEQ-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 10/10] node_device: detecting mdev_types capability on CSS devices Date: Fri, 23 Oct 2020 19:31:52 +0200 Message-Id: <20201023173152.45238-11-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 spamscore=0 mlxlogscore=999 impostorscore=0 suspectscore=43 lowpriorityscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 clxscore=1015 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.4 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.11 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" Add detection of mdev_types capability to channel subsystem devices. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk --- docs/drvnodedev.html.in | 5 +- docs/formatnode.html.in | 39 ++++++++ docs/schemas/nodedev.rng | 4 + src/conf/node_device_conf.c | 92 ++++++++++++++++++- src/conf/node_device_conf.h | 11 +++ src/conf/virnodedeviceobj.c | 7 +- src/libvirt_private.syms | 1 + src/node_device/node_device_udev.c | 3 + .../css_0_0_fffe_mdev_types.xml | 17 ++++ tests/nodedevxml2xmltest.c | 1 + 10 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 tests/nodedevschemadata/css_0_0_fffe_mdev_types.xml diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in index 0823c1888d..d5191d6d93 100644 --- a/docs/drvnodedev.html.in +++ b/docs/drvnodedev.html.in @@ -139,12 +139,13 @@ =20

MDEV capability

- A PCI device capable of creating mediated devices will include a nes= ted + A device capable of creating mediated devices will include a nested capability mdev_types which enumerates all supported md= ev types on the physical device, along with the type attributes availab= le through sysfs. A detailed description of the XML format for the mdev_types capability can be found - here. + here for PCI or + here for CSS.

The following example shows how we might represent an NVIDIA GPU dev= ice diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 594427468b..7f3c71941d 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -430,6 +430,45 @@

The subchannel-set identifier.
devno
The device number.
+
capability
+
+ This optional element can occur multiple times. If it + exists, it has a mandatory type attribute + which will be set to: +
+
mdev_types
+
+ This device is capable of creating mediated devices, a= nd + the capability will contain a list of type + elements, which list all mdev types supported on the + physical device. Since 6.9.0 + Each type element has a single id + attribute that holds an official vendor-supplied ident= ifier + for the type. It supports the following sub-elements: +
+
name
+
+ The name element holds a vendor-suppl= ied + code name for the given mediated device type. This= is + an optional element. +
+
deviceAPI
+
+ The value of this element describes how an instanc= e of + the given type will be presented to the guest by t= he + VFIO framework. +
+
availableInstances
+
+ This element reports the current state of resource + allocation. In other words, how many instances of = the + given type can still be successfully created on the + physical device. +
+
+
+
+
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 9548412999..d3248e90a9 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -653,6 +653,9 @@ + + + =20 @@ -692,6 +695,7 @@ vfio-pci + vfio-ccw diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 39950565b5..75c033b0e1 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -544,6 +544,10 @@ virNodeDeviceCapCCWDefFormat(virBufferPtr buf, data->ccw_dev.ssid); virBufferAsprintf(buf, "0x%04x\n", data->ccw_dev.devno); + if (data->ccw_dev.flags & VIR_NODE_DEV_CAP_FLAG_CSS_MDEV) + virNodeDeviceCapMdevTypesFormat(buf, + data->ccw_dev.mdev_types, + data->ccw_dev.nmdev_types); } =20 =20 @@ -832,6 +836,33 @@ virNodeDevCapMdevTypesParseXML(xmlXPathContextPtr ctxt, } =20 =20 +static int +virNodeDevCSSCapabilityParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapCCWPtr ccw_dev) +{ + g_autofree char *type =3D virXMLPropString(node, "type"); + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + ctxt->node =3D node; + + if (!type) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type= ")); + return -1; + } + + if (STREQ(type, "mdev_types")) { + if (virNodeDevCapMdevTypesParseXML(ctxt, + &ccw_dev->mdev_types, + &ccw_dev->nmdev_types) < 0) + return -1; + ccw_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_CSS_MDEV; + } + + return 0; +} + + static int virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def, @@ -839,6 +870,9 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, virNodeDevCapCCWPtr ccw_dev) { VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree xmlNodePtr *nodes =3D NULL; + int n =3D 0; + size_t i =3D 0; g_autofree char *cssid =3D NULL; g_autofree char *ssid =3D NULL; g_autofree char *devno =3D NULL; @@ -884,6 +918,14 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, return -1; } =20 + if ((n =3D virXPathNodeSet("./capability", ctxt, &nodes)) < 0) + return -1; + + for (i =3D 0; i < n; i++) { + if (virNodeDevCSSCapabilityParseXML(ctxt, nodes[i], ccw_dev) < 0) + return -1; + } + return 0; } =20 @@ -2241,12 +2283,16 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) virMediatedDeviceAttrFree(data->mdev.attributes[i]); VIR_FREE(data->mdev.attributes); break; + case VIR_NODE_DEV_CAP_CSS_DEV: + for (i =3D 0; i < data->ccw_dev.nmdev_types; i++) + virMediatedDeviceTypeFree(data->ccw_dev.mdev_types[i]); + VIR_FREE(data->ccw_dev.mdev_types); + break; case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_CCW_DEV: - case VIR_NODE_DEV_CAP_CSS_DEV: case VIR_NODE_DEV_CAP_LAST: /* This case is here to shutup the compiler */ break; @@ -2284,6 +2330,11 @@ virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def) &cap->data.pci_dev) < 0) return -1; break; + case VIR_NODE_DEV_CAP_CSS_DEV: + if (virNodeDeviceGetCSSDynamicCaps(def->sysfs_path, + &cap->data.ccw_dev) < 0) + return -1; + break; =20 /* all types that (supposedly) don't require any updates * relative to what's in the cache. @@ -2300,7 +2351,6 @@ virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def) case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_MDEV: case VIR_NODE_DEV_CAP_CCW_DEV: - case VIR_NODE_DEV_CAP_CSS_DEV: case VIR_NODE_DEV_CAP_LAST: break; } @@ -2374,6 +2424,15 @@ virNodeDeviceCapsListExport(virNodeDeviceDefPtr def, ncaps++; } } + + if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_CSS_DEV) { + flags =3D caps->data.ccw_dev.flags; + + if (flags & VIR_NODE_DEV_CAP_FLAG_CSS_MDEV) { + MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_MDEV_TYPES); + ncaps++; + } + } } =20 #undef MAYBE_ADD_CAP @@ -2639,6 +2698,28 @@ virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath, return 0; } =20 + +/* virNodeDeviceGetCSSDynamicCaps() get info that is stored in sysfs + * about devices related to this device, i.e. things that can change + * without this device itself changing. These must be refreshed + * anytime full XML of the device is requested, because they can + * change with no corresponding notification from the kernel/udev. + */ +int +virNodeDeviceGetCSSDynamicCaps(const char *sysfsPath, + virNodeDevCapCCWPtr ccw_dev) +{ + ccw_dev->flags &=3D ~VIR_NODE_DEV_CAP_FLAG_CSS_MDEV; + if (virNodeDeviceGetMdevTypesCaps(sysfsPath, + &ccw_dev->mdev_types, + &ccw_dev->nmdev_types) < 0) + return -1; + if (ccw_dev->nmdev_types > 0) + ccw_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_CSS_MDEV; + + return 0; +} + #else =20 int @@ -2661,4 +2742,11 @@ int virNodeDeviceGetSCSITargetCaps(const char *sysfs= Path G_GNUC_UNUSED, return -1; } =20 +int +virNodeDeviceGetCSSDynamicCaps(const char *sysfsPath G_GNUC_UNUSED, + virNodeDevCapCCWPtr ccw_dev G_GNUC_UNUSED) +{ + return -1; +} + #endif /* __linux__ */ diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 5484bc340f..c72b943ba3 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -101,6 +101,10 @@ typedef enum { VIR_NODE_DEV_CAP_FLAG_PCI_MDEV =3D (1 << 3), } virNodeDevPCICapFlags; =20 +typedef enum { + VIR_NODE_DEV_CAP_FLAG_CSS_MDEV =3D (1 << 0), +} virNodeDevCCWCapFlags; + typedef enum { /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ VIR_NODE_DEV_DRM_PRIMARY, @@ -273,6 +277,9 @@ struct _virNodeDevCapCCW { unsigned int cssid; unsigned int ssid; unsigned int devno; + unsigned int flags; /* enum virNodeDevCCWCapFlags */ + virMediatedDeviceTypePtr *mdev_types; + size_t nmdev_types; }; =20 typedef struct _virNodeDevCapData virNodeDevCapData; @@ -382,6 +389,10 @@ int virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath, virNodeDevCapPCIDevPtr pci_dev); =20 +int +virNodeDeviceGetCSSDynamicCaps(const char *sysfsPath, + virNodeDevCapCCWPtr ccw_dev); + int virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def); =20 diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index f240abf315..e5a1af8b3b 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -696,6 +696,12 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *obj, return true; break; =20 + case VIR_NODE_DEV_CAP_CSS_DEV: + if (type =3D=3D VIR_NODE_DEV_CAP_MDEV_TYPES && + (cap->data.ccw_dev.flags & VIR_NODE_DEV_CAP_FLAG_CSS_MDEV)) + return true; + break; + case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_USB_DEV: case VIR_NODE_DEV_CAP_USB_INTERFACE: @@ -710,7 +716,6 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *obj, case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_MDEV: case VIR_NODE_DEV_CAP_CCW_DEV: - case VIR_NODE_DEV_CAP_CSS_DEV: case VIR_NODE_DEV_CAP_LAST: break; } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9029ea4fa2..d9c8df81a7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -823,6 +823,7 @@ virNodeDeviceDefFree; virNodeDeviceDefParseFile; virNodeDeviceDefParseNode; virNodeDeviceDefParseString; +virNodeDeviceGetCSSDynamicCaps; virNodeDeviceGetPCIDynamicCaps; virNodeDeviceGetSCSIHostCaps; virNodeDeviceGetSCSITargetCaps; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 29a7eaa07c..062c0fc52e 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1139,6 +1139,9 @@ udevProcessCSS(struct udev_device *device, if (udevGenerateDeviceName(device, def, NULL) !=3D 0) return -1; =20 + if (virNodeDeviceGetCSSDynamicCaps(def->sysfs_path, &def->caps->data.c= cw_dev) < 0) + return -1; + return 0; } =20 diff --git a/tests/nodedevschemadata/css_0_0_fffe_mdev_types.xml b/tests/no= dedevschemadata/css_0_0_fffe_mdev_types.xml new file mode 100644 index 0000000000..5058b6434e --- /dev/null +++ b/tests/nodedevschemadata/css_0_0_fffe_mdev_types.xml @@ -0,0 +1,17 @@ + + css_0_0_fffe + /sys/devices/css0/0.0.fffe + computer + + 0x0 + 0x0 + 0xfffe + + + I/O subchannel (Non-QDIO) + vfio-ccw + 1 + + + + diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 3cb23b1df4..a009ecb343 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -124,6 +124,7 @@ mymain(void) DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b"); DO_TEST("ccw_0_0_ffff"); DO_TEST("css_0_0_ffff"); + DO_TEST("css_0_0_fffe_mdev_types"); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.25.1