From nobody Sun Feb 8 04:11:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=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