From nobody Mon Dec 15 11:29:01 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 From nobody Mon Dec 15 11:29:01 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=1751904356; cv=none; d=zohomail.com; s=zohoarc; b=JCaXL8dQGiSU5I++5VWTTMcrzQXqu+ZjVQHL8H+6JkRi/6VdkioWKlzc+YcdEpJKjiJQd99qyca2yuOtqJ2A0dJQNTUv4kdb0ZPlbEEMKVoPr6Aoz1ejY4CsM7Mj5xqkDNomBnUE5OVtQpjr0EfrPyvrOTm0YQrzsBa5/k9lMiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751904356; 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=/DvlEwnE/wxlWBX27gMz/in/ccBvMhr6tWsSedci3XA=; b=jvgEQIowKtFoCGGrTGf+bU39WGTf+BF6M7y2/G3dUrcO7QJf+rErhSPhWGD/1o+MjbIWfjY+Ckw1M9/qWG4vr5WAor2O8HrB57f9PIjrSP2F+nkZQMVz2KNfN0F56D71DnT55mJRpl4S81BVVOfzUDYDYJ8CxN5B4BB/G3/6OYk= 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 1751904356441738.753450822558; Mon, 7 Jul 2025 09:05:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A7BD14FC; Mon, 7 Jul 2025 12:05:55 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3FBBF1375; Mon, 7 Jul 2025 12:04:50 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 960D91258; Mon, 7 Jul 2025 12:04:45 -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 20EB9BD5 for ; Mon, 7 Jul 2025 12:04:45 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-im_WxTeNPEKZ18r3arJrhw-1; Mon, 07 Jul 2025 12:04:43 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F2C7B1800287 for ; Mon, 7 Jul 2025 16:04:42 +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 07C9D1956087; Mon, 7 Jul 2025 16:04:41 +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=1751904284; 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=uXZjcrH/Hw9x97pi6LYKThAkWPYGamkBHiWr/HsjUak=; b=Fj1Fe5I8koLhTN535zWqw9ozgAjCbO3zVE5oZre13To5lZ3YX2a4dh8fzorXHVlJ3l51e9 0a7oJhL6XK7nGkCBQezsLVVFdrPeA/MugxozVDyw4VhtnxzavHnJ+pMo0HhnNqQujKmXh2 QppDUn4Abi/aUrsUwzqrc+74FIA+ELU= X-MC-Unique: im_WxTeNPEKZ18r3arJrhw-1 X-Mimecast-MFC-AGG-ID: im_WxTeNPEKZ18r3arJrhw_1751904283 To: devel@lists.libvirt.org Subject: [PATCH 2/5] conf: virDomainHostdevSubsysMediatedDevDefParseXML refactor Date: Mon, 7 Jul 2025 18:03:47 +0200 Message-ID: <20250707160426.184333-3-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: OwutgNT27879z36scwdLqURTx9ksghZykPQH-QfXkfA_1751904283 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PWMJW2PBPFNSGJ7E2GEKUO4UPR43CIG2 X-Message-ID-Hash: PWMJW2PBPFNSGJ7E2GEKUO4UPR43CIG2 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: 1751904358559116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Refactored the virDomainHostdevSubsysMediatedDevDefParseXML function to use virXMLPropUUID fuction instead of getting a string and parsing it later. Due to parsing function change the missing uuid error reporter and message were changed and changed error message was also reflected in tests' outputs. Signed-off-by: Kirill Shchetiniuk Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 13 +------------ ...stdev-mdev-src-address-invalid.x86_64-latest.err | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1e24e41a48..bfc62b6270 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6348,7 +6348,6 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomai= nHostdevDef *def, unsigned char uuid[VIR_UUID_BUFLEN] =3D {0}; xmlNodePtr node =3D NULL; virDomainHostdevSubsysMediatedDev *mdevsrc =3D &def->source.subsys.u.m= dev; - g_autofree char *uuidxml =3D NULL; =20 if (!(node =3D virXPathNode("./source/address", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -6356,18 +6355,8 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDoma= inHostdevDef *def, return -1; } =20 - if (!(uuidxml =3D virXMLPropString(node, "uuid"))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Missing 'uuid' attribute for element
")= ); - return -1; - } - - if (virUUIDParse(uuidxml, uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("Cannot parse uuid attribute of element
= ")); + if (virXMLPropUUID(node, "uuid", VIR_XML_PROP_REQUIRED, uuid) < 0) return -1; - } =20 virUUIDFormat(uuid, mdevsrc->uuidstr); return 0; diff --git a/tests/qemuxmlconfdata/hostdev-mdev-src-address-invalid.x86_64-= latest.err b/tests/qemuxmlconfdata/hostdev-mdev-src-address-invalid.x86_64-= latest.err index 20a91e7fa6..29dfbfb1ce 100644 --- a/tests/qemuxmlconfdata/hostdev-mdev-src-address-invalid.x86_64-latest.= err +++ b/tests/qemuxmlconfdata/hostdev-mdev-src-address-invalid.x86_64-latest.= err @@ -1 +1 @@ -unsupported configuration: Missing 'uuid' attribute for element
+XML error: Missing required attribute 'uuid' in element 'address' --=20 2.49.0 From nobody Mon Dec 15 11:29:01 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=1751904386; cv=none; d=zohomail.com; s=zohoarc; b=Pg1Ev9EPxMYoj+5lwyPX6OWhNRboIUwIv6QL76KJY7BPebtt3j/E8jdFpuxBdQh4FBx4seNGKcX008V5scF/jSl8YwnnI0tYBmv41UJzOnKJ12GxrJvmZ9XN93WR4dA8G2kEWefcdbPyDi6UYNAG2biTPXE4bj6Yr9mVPt6KNnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751904386; 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=BhdalNIB4P4pjUKT8kAkyfXgN80Nah19lGNKpEZCzB4=; b=Uo6sE1maUq1C0TXxSGvaT537uVh+dP3Iv4dv9JGV7gXMUJ7hw3qecO/R23sWihMlgQVqeKooGixWGPir+6Xnbv6h8DcwFgW5nVURrCfNJMlVRhklAlcXqSfI5zFcWPH0UEcgkTpfN9EIcI4Qschteig0toYeC38ArTkDt/VHW7I= 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 175190438615184.1051569153866; Mon, 7 Jul 2025 09:06:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1816415C8; Mon, 7 Jul 2025 12:06:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 65FCB1515; Mon, 7 Jul 2025 12:04:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CDE6113D9; Mon, 7 Jul 2025 12:04:52 -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 9FFE61367 for ; Mon, 7 Jul 2025 12:04:46 -0400 (EDT) Received: from mx-prod-mc-03.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-472-kOH2IL8-NM261jhYg22USQ-1; Mon, 07 Jul 2025 12:04:45 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 888F818DA5CF for ; Mon, 7 Jul 2025 16:04:44 +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 74F401956087; Mon, 7 Jul 2025 16:04:43 +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=1751904286; 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=r74nrL3vpgEXDiLLdipS4uHdwYA3SCOL4Gya7QXo94Q=; b=Ah9K8sOwjDBYnSG8LfZkyo4fAUD9zIzHavDO67I/KpgJFsEJCF6KJm6jVXzp6AFevRFSVW pKq/CfrHr7ymCEBawwL/0+7zAEyoLGg45/JWmuYCr34l3PxQMCr34LYPTDfcGSNasZm+Bl mHb1fK7ntsXkoR2bxtVKTa3tBQCv6Gg= X-MC-Unique: kOH2IL8-NM261jhYg22USQ-1 X-Mimecast-MFC-AGG-ID: kOH2IL8-NM261jhYg22USQ_1751904284 To: devel@lists.libvirt.org Subject: [PATCH 3/5] util: virSecretLookupParseSecret refactor Date: Mon, 7 Jul 2025 18:03:48 +0200 Message-ID: <20250707160426.184333-4-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: M-8MoF4kWeGuWbyHOPbE3lMUWmZXs_inyvH6Evlb6Pw_1751904284 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LYL6LHFE6USM2FZI6I7CEUQUZ56PQWJC X-Message-ID-Hash: LYL6LHFE6USM2FZI6I7CEUQUZ56PQWJC 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: 1751904392874116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Refactored the virSecretLookupParseSecret fucntion to use the virXMLPropUUID fucntion, avoid getting the string and parsing it later. Previously two separate error states merged into one by using boolean NXOR operation. Signed-off-by: Kirill Shchetiniuk --- src/util/virsecret.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/util/virsecret.c b/src/util/virsecret.c index 8a220a37ec..c5eb1055be 100644 --- a/src/util/virsecret.c +++ b/src/util/virsecret.c @@ -64,34 +64,27 @@ int virSecretLookupParseSecret(xmlNodePtr secretnode, virSecretLookupTypeDef *def) { - g_autofree char *uuid =3D NULL; g_autofree char *usage =3D NULL; + int ret; =20 - uuid =3D virXMLPropString(secretnode, "uuid"); usage =3D virXMLPropString(secretnode, "usage"); - if (uuid =3D=3D NULL && usage =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing secret uuid or usage attribute")); + + if ((ret =3D virXMLPropUUID(secretnode, "uuid", VIR_XML_PROP_NONE, def= ->u.uuid)) < 0) return -1; - } =20 - if (uuid && usage) { + if (!(usage) =3D=3D !(ret)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("either secret uuid or usage expected")); return -1; } =20 - if (uuid) { - if (virUUIDParse(uuid, def->u.uuid) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid secret uuid '%1$s'"), uuid); - return -1; - } + if (ret) { def->type =3D VIR_SECRET_LOOKUP_TYPE_UUID; } else { def->u.usage =3D g_steal_pointer(&usage); def->type =3D VIR_SECRET_LOOKUP_TYPE_USAGE; } + return 0; } =20 --=20 2.49.0 From nobody Mon Dec 15 11:29:01 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=1751904404; cv=none; d=zohomail.com; s=zohoarc; b=NwOHUPz7XD68Fzx/gHeTopRjOq27Tj2Cl8K7iO4KBLiARD0rRQXY+hKrVn0dWHfjBUloSKBiw7HLwbGT3nUnod3tIjJLJW5wugSR74Q/uZB1x9QTyGHMxvXKffxC/I+vO/+L7/kzE/0whzQPo1A17OvCPmww0pwKtvTUyYGZtEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751904404; 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=9YlgbV+GpCnz0fV/ZDoZaLP3DlMdGZkIlk08DtD9Iec=; b=fGkuzzuR2kZ7fS4fca2P5Doa8v4scxlE0zfp9uopxxdnD+gynCk7+8OzodEMrEcuSz0IAdU8sV/h9KwsqrGc55AvIszg3l3gRO60PGIFRRxsJ2oNXG0PAhFD35zIf+tLyhtn87KgG9FKJHDGQDQL3+rFmU2kY4v2L5dza3eNOVs= 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 1751904404203960.4379661106186; Mon, 7 Jul 2025 09:06:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 373B51458; Mon, 7 Jul 2025 12:06:43 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id ED03A1602; Mon, 7 Jul 2025 12:04:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B14CD1544; Mon, 7 Jul 2025 12:04:55 -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 3F3D31516 for ; Mon, 7 Jul 2025 12:04:48 -0400 (EDT) Received: from mx-prod-mc-05.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-160-Qx0_ssggO4qhCXWuEJHkzA-1; Mon, 07 Jul 2025 12:04:46 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0DACB193F058 for ; Mon, 7 Jul 2025 16:04:46 +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 16EE71956087; Mon, 7 Jul 2025 16:04:44 +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=1751904288; 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=NjgWMcmXTt+4HBuuKOcbseAYT8RADdyMONGM6fHQqCg=; b=D6IjpQ3AtwDKmhTj0iojpn3lZGAUIFGyoN6UUWnfoIN3PuaOp4cV3yG0axwljh4cxr06JJ llIZZ0+4RGtC4XMVkGl0MBmYhvCTwZrw3ixZeJjrlv+TpjTNyN/8/9llbXvEavgzOpAP5N 2oFxowtjZb5fIuG/SQ4p8y7WSCl/Yz0= X-MC-Unique: Qx0_ssggO4qhCXWuEJHkzA-1 X-Mimecast-MFC-AGG-ID: Qx0_ssggO4qhCXWuEJHkzA_1751904286 To: devel@lists.libvirt.org Subject: [PATCH 4/5] conf: virDomainChrDefParseTargetXML refactor Date: Mon, 7 Jul 2025 18:03:49 +0200 Message-ID: <20250707160426.184333-5-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: qUCJy2YBNifN_UxzcH7Smcdd89YpzG1C_OEywfvBBQ4_1751904286 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FUSCS3C5HO6PADJTN32JPCKK6NNACEH3 X-Message-ID-Hash: FUSCS3C5HO6PADJTN32JPCKK6NNACEH3 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: 1751904405177116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Refactored the default case port option parsing logic to use the appropriate virXMLPropInt function. Signed-off-by: Kirill Shchetiniuk --- src/conf/domain_conf.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bfc62b6270..42e3db5547 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10469,7 +10469,6 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, g_autofree char *targetType =3D virXMLPropString(cur, "type"); g_autofree char *targetModel =3D NULL; g_autofree char *addrStr =3D NULL; - g_autofree char *portStr =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 ctxt->node =3D cur; @@ -10540,20 +10539,8 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def, break; =20 default: - portStr =3D virXMLPropString(cur, "port"); - if (portStr =3D=3D NULL) { - /* Set to negative value to indicate we should set it later */ - def->target.port =3D -1; - break; - } - - if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %1$s"), - portStr); + if (virXMLPropInt(cur, "port", 10, VIR_XML_PROP_NONNEGATIVE, &def-= >target.port, -1) < 0) return -1; - } - def->target.port =3D port; break; } =20 --=20 2.49.0 From nobody Mon Dec 15 11:29:01 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=1751904421; cv=none; d=zohomail.com; s=zohoarc; b=ZNDJZ88+RevKeL1153VUCKZ0LCwqGGfa9iujf3oZBLOd+2woy/i6xq5FfhC4QScMSnwSF0JVqBufNpm8j3dRrVzd2/qULqjTmMs6lKJN+g81MptkNBhZ6d24Qs+x3R1WMr2uslD7gY89UpjUPHqJ791oGJIIfiWA7yvFYnXuM14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751904421; 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=ylLInG6sbkjpoTcMbSFOZbm0gl2TJDPPSaVzi7eq0/M=; b=Kgu7Dg+4sOSzZBCVwQwyU/aShYF5qXSNyfMGkKAGpwgHg/KhufC07iIqBG1/AyLa/cC7fxpIWy8b+YMHgRlkHkzc4BUIDgrMpC+RPrRh0HQukKKHtJ0osxU5cCOrTXwQMq5zNVf+Y9g3NYIM1IF6LR4kUPzt2p45C8mBvts0tnE= 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 1751904421129871.6031179964662; Mon, 7 Jul 2025 09:07:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 19574BD5; Mon, 7 Jul 2025 12:06:59 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E82D41589; Mon, 7 Jul 2025 12:05:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 913D014A2; Mon, 7 Jul 2025 12:05:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 46224138E for ; Mon, 7 Jul 2025 12:04:50 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-NcI-ZTJXPoGpriZTZEL20Q-1; Mon, 07 Jul 2025 12:04:48 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7BEEC180028C for ; Mon, 7 Jul 2025 16:04:47 +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 7C445195609D; Mon, 7 Jul 2025 16:04:46 +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=1751904289; 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=bCfdKlPDgFKKQpIqxMrh2zjL4m28Kpo5rjekWiv9nnA=; b=KsxeZlTo6c6u/K79JLoN/6iloSsQrkPxknsjEdLORgUUtKc+9+gMrbE1FTzuINREKYw5JP /DxNHrSbOEii9V3uxqhXqKhSCgQZrtdAKwJE0JEJyNTUp0G0fAVIRiPyr9HOr7itf+nBfy mLxoytXj8Dpju8bAh8rWXu6YwANuF3E= X-MC-Unique: NcI-ZTJXPoGpriZTZEL20Q-1 X-Mimecast-MFC-AGG-ID: NcI-ZTJXPoGpriZTZEL20Q_1751904287 To: devel@lists.libvirt.org Subject: [PATCH 5/5] qemu: qemuDomainObjPrivateXMLParseVcpu refactor Date: Mon, 7 Jul 2025 18:03:50 +0200 Message-ID: <20250707160426.184333-6-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: R9zBrJ3c13swrPXW0Cb_snaXOzWVK0mnBqK46iTF8Fs_1751904287 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UMSN4E4XZSRH3UUHG27M3AIIR3TCC2KE X-Message-ID-Hash: UMSN4E4XZSRH3UUHG27M3AIIR3TCC2KE 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: 1751904423286116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Refactored the qemuDomainObjPrivateXMLParseVcpu function to use the appropriate virXMLPropUInt function to parse unsigned integers, avoiding unccessery string parsing operations. Signed-off-by: Kirill Shchetiniuk --- src/qemu/qemu_domain.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2d62bcc62b..2b505fbddb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2811,28 +2811,18 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, virDomainDef *def) { virDomainVcpuDef *vcpu; - g_autofree char *idstr =3D NULL; - g_autofree char *pidstr =3D NULL; unsigned int tmp; =20 - idstr =3D virXMLPropString(node, "id"); - - if (idstr && - (virStrToLong_uip(idstr, NULL, 10, &idx) < 0)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vcpu index '%1$s'"), idstr); + if (virXMLPropUInt(node, "id", 10, VIR_XML_PROP_REQUIRED, &idx) < 0) return -1; - } + if (!(vcpu =3D virDomainDefGetVcpu(def, idx))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid vcpu index '%1$u'"), idx); return -1; } =20 - if (!(pidstr =3D virXMLPropString(node, "pid"))) - return -1; - - if (virStrToLong_uip(pidstr, NULL, 10, &tmp) < 0) + if (virXMLPropUInt(node, "pid", 10, VIR_XML_PROP_REQUIRED, &tmp) < 0) return -1; =20 QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->tid =3D tmp; --=20 2.49.0