From nobody Wed Sep 10 01:32:52 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=1753197280; cv=none; d=zohomail.com; s=zohoarc; b=hY209hl4oDKurNN52pWH3TR5zypU8dv+9JKAr6uaWo4MViPAXDzwK0kPYatv+UMyMdhIYhcV3z/smJ1rwo0i117XMTNiYt/K0pbP8WYfCn8mo6fAHHkSiXGuvbiPEGKd2vzupP/Q4o/PKFStl8N2zz2EnNuDizDbc/kOSIOcqyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753197280; 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=cvIWBDjs3PPPgc/4xLdnfBQDmkw7ucNdrxkO+Y+vZZM=; b=cQzY3vz/cXbR9TkkgfbMfE3VPh1hIR3E/RL/4lPoqnM/le8Ph9zO4cP68VS4pMFLcHtzZJ3TFonPAPEBZZES7M6LM7kPRuD/+8yz1zuyac5sQoR0w+NXxEsOpdoKHt66uF4mrDSTpVS6SSZEu8+Qvjw6QVx7URqQu2/6v3jbVTw= 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 1753197280939894.0040401400099; Tue, 22 Jul 2025 08:14:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0A837E69; Tue, 22 Jul 2025 11:14:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B49B91280; Tue, 22 Jul 2025 11:13:19 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D57351239; Tue, 22 Jul 2025 11:13:14 -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 6653D1212 for ; Tue, 22 Jul 2025 11:13:08 -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-357-BdPDMXeINXy1dXyeKwj50w-1; Tue, 22 Jul 2025 11:13:05 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 DED731956046 for ; Tue, 22 Jul 2025 15:13:04 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.csb (unknown [10.43.2.246]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 01AE419560AD; Tue, 22 Jul 2025 15:13:03 +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=-0.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_PASS 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=1753197188; 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=MHLkB21vipIP3W2+/ICpKiP3N/zLGxlRQegvUq+eXyU=; b=aMWExtaNbs8W2/omAhg2Kb3WHaS3D/K3oWgcNyKKc/hMPY0B4ooENVcYvup+02AcCmCFZx KnB+vHaKD0rnATjwaRvAIGnJx3x8c4NJBCR/goa+wsEeAqEgZsel33wq/vyS3zJpt7BYOF HE2bqWKYrVGvA++J9NSfWwFD9+CSrbE= X-MC-Unique: BdPDMXeINXy1dXyeKwj50w-1 X-Mimecast-MFC-AGG-ID: BdPDMXeINXy1dXyeKwj50w_1753197185 To: devel@lists.libvirt.org Subject: [PATCH v2 3/4] conf: virDomainChrDefParseTargetXML refactor Date: Tue, 22 Jul 2025 17:12:04 +0200 Message-ID: <20250722151250.32533-4-kshcheti@redhat.com> In-Reply-To: <20250722151250.32533-1-kshcheti@redhat.com> References: <20250722151250.32533-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uqeB4OtTNJjjVS_2Tappdo43xlNYVS0k3-SvzNmAqUw_1753197185 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4JPK45REILXCIW3VSOHM6IWQ4FXVQEPT X-Message-ID-Hash: 4JPK45REILXCIW3VSOHM6IWQ4FXVQEPT 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: 1753197281973116600 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 | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba0d4a7b12..49d041706e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10473,7 +10473,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; @@ -10544,20 +10543,9 @@ 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); + /* Set default to negative value to indicate we should set it late= r */ + 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