From nobody Sun Feb 8 21:33:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165243790617959.191029674767265; Fri, 13 May 2022 03:31:46 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-424-QdjSeDmSO2-Op-la6zZlzg-1; Fri, 13 May 2022 06:31:41 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 589BD86B8D8; Fri, 13 May 2022 10:31:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 076A7438BE0; Fri, 13 May 2022 10:31:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ECD561932123; Fri, 13 May 2022 10:31:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E8BDC192B8FC for ; Fri, 13 May 2022 10:31:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CB637416156; Fri, 13 May 2022 10:31:32 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C627F416364 for ; Fri, 13 May 2022 10:31:32 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA2D139F9CBA for ; Fri, 13 May 2022 10:31:32 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-ZdQ506WBPwSlZdCWQiaEgA-1; Fri, 13 May 2022 06:31:31 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24D9fp5j031106 for ; Fri, 13 May 2022 10:31:30 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g1mx40vgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 13 May 2022 10:31:29 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24DAMlWE004282 for ; Fri, 13 May 2022 10:31:27 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3fwgd8xkjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 13 May 2022 10:31:27 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24DAVOku53608894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 May 2022 10:31:24 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F33FD11C04C; Fri, 13 May 2022 10:31:23 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBDFD11C052; Fri, 13 May 2022 10:31:23 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.93.141]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 13 May 2022 10:31:23 +0000 (GMT) X-MC-Unique: QdjSeDmSO2-Op-la6zZlzg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ZdQ506WBPwSlZdCWQiaEgA-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 13/17] nodedev: refactor ccw device address parsing from XML Date: Fri, 13 May 2022 12:31:12 +0200 Message-Id: <20220513103116.3751-14-fiuczy@linux.ibm.com> In-Reply-To: <20220513103116.3751-1-fiuczy@linux.ibm.com> References: <20220513103116.3751-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 2Oh-9nK_w3IM_NfgxtWfRWcKo3DnZIMc X-Proofpoint-ORIG-GUID: 2Oh-9nK_w3IM_NfgxtWfRWcKo3DnZIMc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-13_04,2022-05-12_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 spamscore=0 clxscore=1015 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205130046 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.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Fiuczynski Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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 X-ZM-MESSAGEID: 1652438809125100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Move ccw device address XML parsing into new method for later reuse. Signed-off-by: Boris Fiuczynski --- src/conf/node_device_conf.c | 96 ++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 97779078e8..8d160185eb 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1143,6 +1143,58 @@ virNodeDevAPMatrixCapabilityParseXML(xmlXPathContext= Ptr ctxt, } =20 =20 +static int +virNodeDevCCWDeviceAddressParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + const char *dev_name, + virCCWDeviceAddress *ccw_addr) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree char *cssid =3D NULL; + g_autofree char *ssid =3D NULL; + g_autofree char *devno =3D NULL; + + ctxt->node =3D node; + + if (!(cssid =3D virXPathString("string(./cssid[1])", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing cssid value for '%s'"), dev_name); + return -1; + } + if (virStrToLong_uip(cssid, NULL, 0, &ccw_addr->cssid) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid cssid value '%s' for '%s'"), + cssid, dev_name); + return -1; + } + + if (!(ssid =3D virXPathString("string(./ssid[1])", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing ssid value for '%s'"), dev_name); + return -1; + } + if (virStrToLong_uip(ssid, NULL, 0, &ccw_addr->ssid) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid ssid value '%s' for '%s'"), + ssid, dev_name); + return -1; + } + + if (!(devno =3D virXPathString("string(./devno[1])", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing devno value for '%s'"), dev_name); + return -1; + } + if (virStrToLong_uip(devno, NULL, 16, &ccw_addr->devno) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid devno value '%s' for '%s'"), + devno, dev_name); + return -1; + } + + return 0; +} + static int virNodeDevCSSCapabilityParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, @@ -1180,50 +1232,18 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr 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; + g_autofree virCCWDeviceAddress *ccw_addr =3D NULL; =20 ctxt->node =3D node; =20 - if (!(cssid =3D virXPathString("string(./cssid[1])", ctxt))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("missing cssid value for '%s'"), def->name); - return -1; - } - - if (virStrToLong_uip(cssid, NULL, 0, &ccw_dev->cssid) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid cssid value '%s' for '%s'"), - cssid, def->name); - return -1; - } - - if (!(ssid =3D virXPathString("string(./ssid[1])", ctxt))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("missing ssid value for '%s'"), def->name); - return -1; - } + ccw_addr =3D g_new0(virCCWDeviceAddress, 1); =20 - if (virStrToLong_uip(ssid, NULL, 0, &ccw_dev->ssid) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid ssid value '%s' for '%s'"), - ssid, def->name); + if (virNodeDevCCWDeviceAddressParseXML(ctxt, node, def->name, ccw_addr= ) < 0) return -1; - } =20 - if (!(devno =3D virXPathString("string(./devno[1])", ctxt))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("missing devno value for '%s'"), def->name); - return -1; - } - - if (virStrToLong_uip(devno, NULL, 16, &ccw_dev->devno) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid devno value '%s' for '%s'"), - devno, def->name); - return -1; - } + ccw_dev->cssid =3D ccw_addr->cssid; + ccw_dev->ssid =3D ccw_addr->ssid; + ccw_dev->devno =3D ccw_addr->devno; =20 if ((n =3D virXPathNodeSet("./capability", ctxt, &nodes)) < 0) return -1; --=20 2.33.1