From nobody Tue Feb 10 07:40:47 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681373845; cv=none; d=zohomail.com; s=zohoarc; b=Jvqpc4K57Ue+8u2JvaE0tUi4L2Ux6tmY9VgtdXpVthpxzgY0k1MHql3ZhcSgnS7NOXAzstpdJMFAYCuvC3f7OX5qlG8my5JH3RGsVE0qKtznv90fA9wLEDxZUHRS3eUzwwM1oUT356mDpWMGM7ycKtmXf4EKOL2OaFEOVjBGVzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373845; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6bb9aaIvZyYR9HxYMKZJ7COZO+iAp/XrVbAgl/qn3rs=; b=hygXjlyoGWXtol3veGgVKIz/idr512X26H0Rx7X87ymYq4wGQsy8ijoRL4qTBRTbR3zSLkY8YYXWgnrrp9x3eYUbi0e1dD0hQwqIY1TNCoey+YtK3EiokWEyFnvbgXKm0P6HWR51+4H7B0oRMorg/xVwyEnrF7WXZkOct0nU+8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1681373845353726.3256506869235; Thu, 13 Apr 2023 01:17:25 -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-518-6K4WGzvrPWWvgINzQmaIEw-1; Thu, 13 Apr 2023 04:16:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93B8E857FB8; Thu, 13 Apr 2023 08:16:07 +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 7BAB3112132E; Thu, 13 Apr 2023 08:16:07 +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 9AA4C19465B7; Thu, 13 Apr 2023 08:16:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E33A61946A6D for ; Thu, 13 Apr 2023 08:16:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C39E42166B26; Thu, 13 Apr 2023 08:16:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4986E2166B29 for ; Thu, 13 Apr 2023 08:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373844; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6bb9aaIvZyYR9HxYMKZJ7COZO+iAp/XrVbAgl/qn3rs=; b=NfqeM6zvpzgKPlmGr4y7HRNazkAsiLNCwSYTqpTZtR1S4e1iUrKwmh+1zS9O6vNwqQevam ya6I5N1pGz1/JQZmGmiWKzNZK7DiT3lVNmIwPuyOShaw2hX0MFNrBB37ISuohxlbLKBrfS b1uvas0RXb/wSOJO9jgwpQmUVV0hq5k= X-MC-Unique: 6K4WGzvrPWWvgINzQmaIEw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 5/8] virsh: event: Introduce virshEventPrintf Date: Thu, 13 Apr 2023 10:15:53 +0200 Message-Id: <39666f32127c109b1576d413a8e106ea8a6167d6.1681373548.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681373847332100001 Content-Type: text/plain; charset="utf-8" Extract internals of virshEventPrint into a function that can take the format string. The function will be used in upcoming patches which make the event formatting translatable. Signed-off-by: Peter Krempa --- tools/virsh-domain-event.c | 46 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 1ed204fa9a..a8a321590c 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -286,6 +286,33 @@ struct virshDomEventData { }; typedef struct virshDomEventData virshDomEventData; + +static void G_GNUC_PRINTF(2, 3) +virshEventPrintf(virshDomEventData *data, + const char *fmt, + ...) +{ + va_list ap; + + if (!data->loop && *data->count) + return; + + if (data->timestamp) { + char timestamp[VIR_TIME_STRING_BUFLEN] =3D ""; + + ignore_value(virTimeStringNowRaw(timestamp)); + vshPrint(data->ctl, "%s: ", timestamp); + } + + va_start(ap, fmt); + vshPrintVa(data->ctl, fmt, ap); + va_end(ap); + + (*data->count)++; + if (!data->loop) + vshEventDone(data->ctl); +} + /** * virshEventPrint: * @@ -305,25 +332,10 @@ virshEventPrint(virshDomEventData *data, if (!(msg =3D virBufferContentAndReset(buf))) return; - if (!data->loop && *data->count) - return; - - if (data->timestamp) { - char timestamp[VIR_TIME_STRING_BUFLEN]; - - if (virTimeStringNowRaw(timestamp) < 0) - timestamp[0] =3D '\0'; - - vshPrint(data->ctl, "%s: %s", timestamp, msg); - } else { - vshPrint(data->ctl, "%s", msg); - } - - (*data->count)++; - if (!data->loop) - vshEventDone(data->ctl); + virshEventPrintf(data, "%s", msg); } + static void virshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED, virDomainPtr dom, --=20 2.39.2