From nobody Tue Dec 16 03:43:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1751904335; cv=none; d=zohomail.com; s=zohoarc; b=fV1PBR5GPZTa7Lr+UQSbZYux+WnJnh+zT5mOtI/ndha41DihQ/6a9htdsVS2ky6O11UIPLT/JTb+SCmjyGiZIj+gvWgLLo7S+7OWECBW8fNqylT0kSEFuT76gA1eHiVsdbiyTB3JJAGSwSX+tYK2DR5T8a9H4du97I8N6Lav17U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751904335; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=hbBGUMYpi78cFLswmx4l3GS1r/MhQhnO+DL7tkGdas4=; b=XjU9qmuLN9darNqLwJUk5Qr/u2sTfBZj7t4IZj58Xs0KLYSh+RtoAdlPMUfCjbIv6lHq1XIDKH816ean0wMJJ8vr/GzkgY51u3WIyWMoAqpjd8ak+ONxYo1Lo1H+q9rVL5xSMC28jWaXHPoPlufELLL4hWegTNVVjehHfy6wZ+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1751904335063475.08495452921443; Mon, 7 Jul 2025 09:05:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 20D3E157D; Mon, 7 Jul 2025 12:05:34 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6D780155D; Mon, 7 Jul 2025 12:04:48 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8145B127A; Mon, 7 Jul 2025 12:04:44 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EFFA31258 for ; Mon, 7 Jul 2025 12:04:43 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-Qj52awPfMZmTzVr5uPS4Ww-1; Mon, 07 Jul 2025 12:04:42 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C7531955ECF for ; Mon, 7 Jul 2025 16:04:41 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.csb (unknown [10.43.2.22]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97130195609D; Mon, 7 Jul 2025 16:04:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751904283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o5l4YSwmP6wHBuuur3tR0bdRvUynhHqq+T1pTlGaVW8=; b=MEmDtjP29QCso3JWpmHBin5eq+7lY8I2dlXVn7Tu1ZPFcoUpectX6bcNH5vl2Pt/gqRhLi 9IkwDXbo/cwMSjuKLqyajLUVyi+px7koIHUrOjMK+nyff/vxDfygxTXzfkAr39ZWtf6NNm /aRHPVb87jWSMeR21LBOwVjfOsZpufE= X-MC-Unique: Qj52awPfMZmTzVr5uPS4Ww-1 X-Mimecast-MFC-AGG-ID: Qj52awPfMZmTzVr5uPS4Ww_1751904281 To: devel@lists.libvirt.org Subject: [PATCH 1/5] conf: virNetDevVPortProfileParse refactor Date: Mon, 7 Jul 2025 18:03:46 +0200 Message-ID: <20250707160426.184333-2-kshcheti@redhat.com> In-Reply-To: <20250707160426.184333-1-kshcheti@redhat.com> References: <20250707160426.184333-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vXbsaw8dTSicdkpa8LW_s8FM6g6wd6rNulYplJTn58A_1751904281 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QKEP4ANAVWLZALG3EYWIMTZT2GKK5UAZ X-Message-ID-Hash: QKEP4ANAVWLZALG3EYWIMTZT2GKK5UAZ X-MailFrom: kshcheti@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Kirill Shchetiniuk X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1751904336385116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Refactored the virNetDevVPortProfileParse function to use the appropriate virXMLProp* functions to parse input configuration XML. Signed-off-by: Kirill Shchetiniuk --- src/conf/netdev_vport_profile_conf.c | 120 +++++++++++---------------- 1 file changed, 48 insertions(+), 72 deletions(-) diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_p= rofile_conf.c index 032a3147d7..9be19de808 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -29,12 +29,6 @@ virNetDevVPortProfile * virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags) { g_autofree char *virtPortType =3D NULL; - g_autofree char *virtPortManagerID =3D NULL; - g_autofree char *virtPortTypeID =3D NULL; - g_autofree char *virtPortTypeIDVersion =3D NULL; - g_autofree char *virtPortInstanceID =3D NULL; - g_autofree char *virtPortProfileID =3D NULL; - g_autofree char *virtPortInterfaceID =3D NULL; g_autofree virNetDevVPortProfile *virtPort =3D NULL; xmlNodePtr parameters; =20 @@ -55,88 +49,70 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned in= t flags) } =20 if ((parameters =3D virXMLNodeGetSubelement(node, "parameters"))) { - virtPortManagerID =3D virXMLPropString(parameters, "managerid"); - virtPortTypeID =3D virXMLPropString(parameters, "typeid"); - virtPortTypeIDVersion =3D virXMLPropString(parameters, "typeidvers= ion"); - virtPortInstanceID =3D virXMLPropString(parameters, "instanceid"); - virtPortProfileID =3D virXMLPropString(parameters, "profileid"); - virtPortInterfaceID =3D virXMLPropString(parameters, "interfaceid"= ); - } + int ret; + unsigned int tempUInt; + g_autofree char *virtPortProfileID =3D virXMLPropString(parameters= , "profileid"); =20 - if (virtPortManagerID) { - unsigned int val; + if ((ret =3D virXMLPropUInt(parameters, "managerid", 10, VIR_XML_P= ROP_NONE, &tempUInt))) { + if (ret < 0) + return NULL; =20 - if (virStrToLong_ui(virtPortManagerID, NULL, 0, &val)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot parse value of managerid parameter")); - return NULL; - } - if (val > 0xff) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("value of managerid out of range")); - return NULL; + if (tempUInt > 0xff) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("value of managerid out of range")); + return NULL; + } + + virtPort->managerID =3D (uint8_t)tempUInt; + virtPort->managerID_specified =3D true; } - virtPort->managerID =3D (uint8_t)val; - virtPort->managerID_specified =3D true; - } =20 - if (virtPortTypeID) { - unsigned int val; + if ((ret =3D virXMLPropUInt(parameters, "typeid", 10, VIR_XML_PROP= _NONE, &tempUInt))) { + if (ret < 0) + return NULL; =20 - if (virStrToLong_ui(virtPortTypeID, NULL, 0, &val)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot parse value of typeid parameter")); - return NULL; - } - if (val > 0xffffff) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("value for typeid out of range")); - return NULL; + if (tempUInt > 0xffffff) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("value for typeid out of range")); + return NULL; + } + virtPort->typeID =3D (uint32_t)tempUInt; + virtPort->typeID_specified =3D true; } - virtPort->typeID =3D (uint32_t)val; - virtPort->typeID_specified =3D true; - } =20 - if (virtPortTypeIDVersion) { - unsigned int val; + if ((ret =3D virXMLPropUInt(parameters, "typeidversion", 10, VIR_X= ML_PROP_NONE, &tempUInt))) { + if (ret < 0) + return NULL; =20 - if (virStrToLong_ui(virtPortTypeIDVersion, NULL, 0, &val)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot parse value of typeidversion paramete= r")); - return NULL; - } - if (val > 0xff) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("value of typeidversion out of range")); - return NULL; + if (tempUInt > 0xff) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("value of typeidversion out of range")); + return NULL; + } + virtPort->typeIDVersion =3D (uint8_t)tempUInt; + virtPort->typeIDVersion_specified =3D true; } - virtPort->typeIDVersion =3D (uint8_t)val; - virtPort->typeIDVersion_specified =3D true; - } =20 - if (virtPortInstanceID) { - if (virUUIDParse(virtPortInstanceID, virtPort->instanceID) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot parse instanceid parameter as a uuid"= )); - return NULL; + if ((ret =3D virXMLPropUUID(parameters, "instanceid", VIR_XML_PROP= _NONE, virtPort->instanceID))) { + if (ret < 0) + return NULL; + + virtPort->instanceID_specified =3D true; } - virtPort->instanceID_specified =3D true; - } =20 - if (virtPortProfileID && - virStrcpyStatic(virtPort->profileID, virtPortProfileID) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("profileid parameter too long")); - return NULL; - } + if ((ret =3D virXMLPropUUID(parameters, "interfaceid", VIR_XML_PRO= P_NONE, virtPort->interfaceID))) { + if (ret < 0) + return NULL; + + virtPort->interfaceID_specified =3D true; + } =20 - if (virtPortInterfaceID) { - if (virUUIDParse(virtPortInterfaceID, virtPort->interfaceID) < 0) { + if (virtPortProfileID && + virStrcpyStatic(virtPort->profileID, virtPortProfileID) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot parse interfaceid parameter as a uuid= ")); + _("profileid parameter too long")); return NULL; } - virtPort->interfaceID_specified =3D true; } =20 /* generate default instanceID/interfaceID if appropriate */ --=20 2.49.0