From nobody Tue Oct 28 17:33:26 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=1760424022; cv=none; d=zohomail.com; s=zohoarc; b=UzDIVQxd9Z4jOz0mYbbt1tI7czDxfJHyFLqyHkWE3Ay6pLNYwKh4y3ynDnKOo9un+OVvibC1ki0Nijn/H31brXc4MdkrIJIj2Farma3NW3h9LBmd9xeI6f3DTBrqnZE+r7+FHDizub0TS2sJ6ehf0aQ63PK9nBzkubf6/3xoe1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760424022; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=GKIt35lXEK5mu9rRXHHsPmkkZwahyE3hNPsS++53IRk=; b=lsb5DNbzZTyUOF05LTtR/onSwcyOFCT1Iargd/BlWRd9fTe3uwYSlmzgs/Ign2YaG3kkwtCBc/8cozLhaHNlBLoy65Vqpst6JI4qqDF2mCTnvTp92fB9FcNwlvPpSMbU6jplO65UxQBWLz4Vxfzp1JNX3iLTPvA4KJZ7VB5Ob/I= 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 1760424022692817.8740953728724; Mon, 13 Oct 2025 23:40:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id CD67844263; Tue, 14 Oct 2025 02:40:19 -0400 (EDT) Received: from [172.19.199.20] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id B6549442D8; Tue, 14 Oct 2025 02:37:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id F136A41B73; Tue, 14 Oct 2025 02:32:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3646643DB1 for ; Tue, 14 Oct 2025 02:32:02 -0400 (EDT) Received: from mx-prod-mc-08.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-444-Qzs17vxcMvyDByVm9tHDUA-1; Tue, 14 Oct 2025 02:32:00 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C01D1800452 for ; Tue, 14 Oct 2025 06:31:59 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A859B300018D for ; Tue, 14 Oct 2025 06:31:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760423521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GKIt35lXEK5mu9rRXHHsPmkkZwahyE3hNPsS++53IRk=; b=I/dQEri0xMNZgtGGmuBQMvVa2NXEc53hzJ8ylzqHLpn6pDOZV2l3O5TcmHfZl28CwrutUF A1T7KXNWXcEfvFX2fOuhg/iRnTflfGsL1xytijsjDNoSEo8G8DnniIhe/fVogTJ0UrKPeD 7aTs2yqmScsoMP8xbBNTDUu/WR4q03U= X-MC-Unique: Qzs17vxcMvyDByVm9tHDUA-1 X-Mimecast-MFC-AGG-ID: Qzs17vxcMvyDByVm9tHDUA_1760423519 To: devel@lists.libvirt.org Subject: [PATCH 6/8] wireshark: Introduce and use vir_val_to_str() Date: Tue, 14 Oct 2025 08:31:45 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7MnQ7No6GpsLBRTNNQp4urTvA7Lw7w3WRz2lEiae-Ps_1760423519 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CUWV2A3CWSPLJ3NTLOBJA6CF5WBQHS4P X-Message-ID-Hash: CUWV2A3CWSPLJ3NTLOBJA6CF5WBQHS4P X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1760424023510158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Wireshark offers val_to_str() function which converts numeric value to string by looking up value ('val') in an array ('vs') of pairs. If no corresponding string is found, then the value is formatted using given 'fmt' string. Starting from wireshark-4.6.0 not only this function gained another argument but also returns a strdup()-ed string. To keep our code simple, let's introduce a wrapper so which can be then adjusted as needed. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/wireshark/src/packet-libvirt.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/pac= ket-libvirt.c index 6c729801d4..f6ad2c4578 100644 --- a/tools/wireshark/src/packet-libvirt.c +++ b/tools/wireshark/src/packet-libvirt.c @@ -140,6 +140,15 @@ static const value_string status_strings[] =3D { { -1, NULL } }; =20 +static const char * +G_GNUC_PRINTF(3, 0) +vir_val_to_str(const uint32_t val, + const value_string *vs, + const char *fmt) +{ + return val_to_str(val, vs, fmt); +} + static gboolean dissect_xdr_string(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf, guint32 maxlen) @@ -466,14 +475,14 @@ dissect_libvirt_message(tvbuff_t *tvb, packet_info *p= info, proto_tree *tree, status =3D tvb_get_ntohil(tvb, offset); offset +=3D 4; =20 col_add_fstr(pinfo->cinfo, COL_INFO, "Prog=3D%s", - val_to_str(prog, program_strings, "%x")); + vir_val_to_str(prog, program_strings, "%x")); =20 vs =3D get_program_data(prog, VIR_PROGRAM_PROCSTRINGS); - col_append_fstr(pinfo->cinfo, COL_INFO, " Proc=3D%s", val_to_str(proc,= vs, "%d")); + col_append_fstr(pinfo->cinfo, COL_INFO, " Proc=3D%s", vir_val_to_str(p= roc, vs, "%d")); =20 col_append_fstr(pinfo->cinfo, COL_INFO, " Type=3D%s Serial=3D%u Status= =3D%s", - val_to_str(type, type_strings, "%d"), serial, - val_to_str(status, status_strings, "%d")); + vir_val_to_str(type, type_strings, "%d"), serial, + vir_val_to_str(status, status_strings, "%d")); =20 if (tree) { gint *hf_proc; --=20 2.49.1