From nobody Mon Feb 9 05:38:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1681373769; cv=none; d=zohomail.com; s=zohoarc; b=gZZ3UAa1gazs/eZZYi2fGkpb7PwNjWumBI8QAKV8XtqAWOmeGTUChDkvV8980S5RyhuWISc1Cus1OUCDuo8ExJG6JWjlnDXfwTHT7zR5sWuisShCq0+5Do3HGN5/Vua00LxrRWlhU8KiC5/yEmP3hS8a9Zyxv+YpNaRuVdmFORE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373769; 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=4BkFWAMNBcfRd0nPatxIKleAh258Va3Oh2Dn5yz/FPI=; b=UspTb2a1Po2gaQhqpYMoh0Kn+M1H2uPBZuttQDO4Y5ZHCakVNjfZbaXY2MlbGo/0TA4TJapRojAA/nFU9l3TUMhccqZKy/GgzfVjXCiXeAQu1xrFtwEkwiZmep6kQf6OrvBzpsLfSlKJFx3n6T0TSm+d+M7GTF2O6gNirNaIZuo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 168137376981240.94142282171049; Thu, 13 Apr 2023 01:16:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-ZdfkiJZGNByF-NzI4QN4Ag-1; Thu, 13 Apr 2023 04:16:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B9CE3C0C8BB; Thu, 13 Apr 2023 08:16:04 +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 337FE8576A; Thu, 13 Apr 2023 08:16:04 +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 4C70419472D2; Thu, 13 Apr 2023 08:16:02 +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 CA9A71946597 for ; Thu, 13 Apr 2023 08:15:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6D7112166B2A; Thu, 13 Apr 2023 08:15:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D32652166B26 for ; Thu, 13 Apr 2023 08:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373768; 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=4BkFWAMNBcfRd0nPatxIKleAh258Va3Oh2Dn5yz/FPI=; b=UjHv0Dpic4Iw9QSPs+QeEq0GTG27A9sCKbDGU5gtLT/JCOdSrETeAA6hA/aOz/gJBRbuoo dXnBWUt2JrZ1ppzIKjAJjXteRgBuUmYOkUGWIS2SNJ0KooAg0BY/ebb3aO08GCZ5zOy6hk Bg7prE/DPmUMOCxYv6jJXWe1XneacfQ= X-MC-Unique: ZdfkiJZGNByF-NzI4QN4Ag-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 1/8] virCgroupV1GetBlkioIo(Device)Serviced: Refactor extraction of cgroup data Date: Thu, 13 Apr 2023 10:15:49 +0200 Message-Id: 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.5 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: 1681373771101100001 Content-Type: text/plain; charset="utf-8" Rewrite the code to improve maintainability and also re-do construction of error messages which are assembled from non-translatable parts. Closes: https://gitlab.com/libvirt/libvirt/-/issues/455 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/vircgroupv1.c | 264 ++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 147 deletions(-) diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index c0cac2a6b6..77c7e209ce 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1051,189 +1051,159 @@ virCgroupV1GetBlkioWeight(virCgroup *group, } + static int -virCgroupV1GetBlkioIoServiced(virCgroup *group, - long long *bytes_read, - long long *bytes_write, - long long *requests_read, - long long *requests_write) +virCgroupV1GetBlkioIoServicedOne(virCgroup *group, + const char *field, + const char *devpath, + long long *dataRead, + long long *dataWrite) { - long long stats_val; - g_autofree char *str1 =3D NULL; - g_autofree char *str2 =3D NULL; - char *p1 =3D NULL; - char *p2 =3D NULL; - size_t i; + g_autofree char *serviced =3D NULL; + g_autofree char *filterWrite =3D NULL; + g_autofree char *filterRead =3D NULL; + unsigned long long tmpval; + char *tmp; + size_t len; - const char *value_names[] =3D { - "Read ", - "Write " - }; - long long *bytes_ptrs[] =3D { - bytes_read, - bytes_write - }; - long long *requests_ptrs[] =3D { - requests_read, - requests_write - }; - - *bytes_read =3D 0; - *bytes_write =3D 0; - *requests_read =3D 0; - *requests_write =3D 0; - - if (virCgroupGetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.io_service_bytes", &str1) < 0) - return -1; + *dataRead =3D 0; + *dataWrite =3D 0; - if (virCgroupGetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.io_serviced", &str2) < 0) + if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_BLKIO, field, &s= erviced) < 0) return -1; - /* sum up all entries of the same kind, from all devices */ - for (i =3D 0; i < G_N_ELEMENTS(value_names); i++) { - p1 =3D str1; - p2 =3D str2; - - while ((p1 =3D strstr(p1, value_names[i]))) { - p1 +=3D strlen(value_names[i]); - if (virStrToLong_ll(p1, &p1, 10, &stats_val) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse byte %1$sstat '%2$s'"), - value_names[i], - p1); - return -1; - } + if (devpath) { + g_autofree char *devstr =3D NULL; - if (stats_val < 0 || - (stats_val > 0 && *bytes_ptrs[i] > (LLONG_MAX - stats_val)= )) - { - virReportError(VIR_ERR_OVERFLOW, - _("Sum of byte %1$sstat overflows"), - value_names[i]); - return -1; - } - *bytes_ptrs[i] +=3D stats_val; - } + if (!(devstr =3D virCgroupGetBlockDevString(devpath))) + return -1; - while ((p2 =3D strstr(p2, value_names[i]))) { - p2 +=3D strlen(value_names[i]); - if (virStrToLong_ll(p2, &p2, 10, &stats_val) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse %1$srequest stat '%2$s'"), - value_names[i], - p2); - return -1; - } + filterWrite =3D g_strdup_printf("%sWrite ", devstr); + filterRead =3D g_strdup_printf("%sRead ", devstr); - if (stats_val < 0 || - (stats_val > 0 && *requests_ptrs[i] > (LLONG_MAX - stats_v= al))) - { - virReportError(VIR_ERR_OVERFLOW, - _("Sum of %1$srequest stat overflows"), - value_names[i]); - return -1; - } - *requests_ptrs[i] +=3D stats_val; + if (!strstr(serviced, filterWrite) || + !strstr(serviced, filterRead)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot find blkio cgroup stats (%1$s) for bl= ock device '%2$s' (%3$s)"), + field, devstr, devpath); + return -1; } + } else { + filterWrite =3D g_strdup("Write "); + filterRead =3D g_strdup("Read "); } - return 0; -} - - -static int -virCgroupV1GetBlkioIoDeviceServiced(virCgroup *group, - const char *path, - long long *bytes_read, - long long *bytes_write, - long long *requests_read, - long long *requests_write) -{ - g_autofree char *str1 =3D NULL; - g_autofree char *str2 =3D NULL; - g_autofree char *str3 =3D NULL; - char *p1 =3D NULL; - char *p2 =3D NULL; - size_t i; - - const char *value_names[] =3D { - "Read ", - "Write " - }; - long long *bytes_ptrs[] =3D { - bytes_read, - bytes_write - }; - long long *requests_ptrs[] =3D { - requests_read, - requests_write - }; - - if (virCgroupGetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.io_service_bytes", &str1) < 0) - return -1; + len =3D strlen(filterRead); - if (virCgroupGetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.io_serviced", &str2) < 0) - return -1; + for (tmp =3D strstr(serviced, filterRead); tmp; tmp =3D strstr(tmp, fi= lterRead)) { + char *cur =3D tmp; + tmp +=3D len; - if (!(str3 =3D virCgroupGetBlockDevString(path))) - return -1; + VIR_DEBUG("filter=3D'%s' line=3D'%.*s'", filterRead, (int) (strchr= (tmp, '\n') - tmp), tmp); - if (!(p1 =3D strstr(str1, str3))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find byte stats for block device '%1$s'"), - str3); - return -1; - } + if (virStrToLong_ullp(tmp, &tmp, 10, &tmpval) < 0) { + char *eol; - if (!(p2 =3D strstr(str2, str3))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find request stats for block device '%1$s= '"), - str3); - return -1; - } + if ((eol =3D strchr(cur, '\n'))) + *eol =3D '\0'; - for (i =3D 0; i < G_N_ELEMENTS(value_names); i++) { - if (!(p1 =3D strstr(p1, value_names[i]))) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find byte %1$sstats for block device = '%2$s'"), - value_names[i], str3); + _("Cannot parse blkio cgroup (%1$s) entry '%2$s= '"), + field, cur); return -1; } - if (virStrToLong_ll(p1 + strlen(value_names[i]), &p1, 10, bytes_pt= rs[i]) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse %1$sstat '%2$s'"), - value_names[i], p1 + strlen(value_names[i])); + if (tmpval + *dataRead > LLONG_MAX) { + virReportError(VIR_ERR_OVERFLOW, + _("overflow in sum of statistic for blkio cgrou= p (%1$s) field '%2$s'"), + field, filterRead); return -1; } - if (!(p2 =3D strstr(p2, value_names[i]))) { + *dataRead +=3D tmpval; + } + + len =3D strlen(filterWrite); + + for (tmp =3D strstr(serviced, filterWrite); tmp; tmp =3D strstr(tmp, f= ilterWrite)) { + char *cur =3D tmp; + tmp +=3D len; + + VIR_DEBUG("filter=3D'%s' line=3D'%.*s'", filterWrite, (int) (strch= r(cur, '\n') - cur), cur); + + if (virStrToLong_ullp(tmp, &tmp, 10, &tmpval) < 0) { + char *eol; + + if ((eol =3D strchr(cur, '\n'))) + *eol =3D '\0'; + virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find request %1$sstats for block devi= ce '%2$s'"), - value_names[i], str3); + _("Cannot parse blkio cgroup ('%1$s') entry '%2= $s'"), + field, cur); return -1; } - if (virStrToLong_ll(p2 + strlen(value_names[i]), &p2, 10, requests= _ptrs[i]) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse %1$sstat '%2$s'"), - value_names[i], p2 + strlen(value_names[i])); + if (tmpval + *dataWrite > LLONG_MAX) { + virReportError(VIR_ERR_OVERFLOW, + _("overflow in sum of statistic for blkio cgrou= p (%1$s) field '%2$s'"), + field, filterWrite); return -1; } + + *dataWrite +=3D tmpval; } return 0; } +static int +virCgroupV1GetBlkioIoServicedInternal(virCgroup *group, + const char *devpath, + long long *bytes_read, + long long *bytes_write, + long long *requests_read, + long long *requests_write) +{ + if (virCgroupV1GetBlkioIoServicedOne(group, "blkio.throttle.io_service= _bytes", + devpath, bytes_read, bytes_write)= < 0) + return -1; + + if (virCgroupV1GetBlkioIoServicedOne(group, "blkio.throttle.io_service= d", + devpath, requests_read, requests_= write) < 0) + return -1; + + return 0; +} + + +static int +virCgroupV1GetBlkioIoServiced(virCgroup *group, + long long *bytes_read, + long long *bytes_write, + long long *requests_read, + long long *requests_write) +{ + return virCgroupV1GetBlkioIoServicedInternal(group, NULL, + bytes_read, bytes_write, + requests_read, requests_w= rite); +} + + +static int +virCgroupV1GetBlkioIoDeviceServiced(virCgroup *group, + const char *path, + long long *bytes_read, + long long *bytes_write, + long long *requests_read, + long long *requests_write) +{ + return virCgroupV1GetBlkioIoServicedInternal(group, path, + bytes_read, bytes_write, + requests_read, requests_w= rite); +} + + static int virCgroupV1SetBlkioDeviceWeight(virCgroup *group, const char *devPath, --=20 2.39.2 From nobody Mon Feb 9 05:38:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1681373770; cv=none; d=zohomail.com; s=zohoarc; b=SBa6F/VWpSpn6qaIh9gJFeKN/ShHMF7dHxEfZ74kJZkFFlwOdoEj8N5HWaQbN9+go+/+M/JpEg+Rr740FMoFSRlF66cbslgs8iFQ8QtNcpqkfEuZ2IRgaIezxpcqsqz2P5nvzr1KUhjEJHJORlnPbMQ4W8vplRTc9IabGnT/4X0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373770; 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=L4jjspSRv98DmhWdmw/9knRl1svI9vVW7g/8R7FM2D0=; b=Gkz5SA1bnDlB3EttJ5zQCxvfCEyqQMM/VGCNFC22KGUYKk6I3KB5yrIEg08OFSRoq+p9Qz/PynlhOOUidqoqXlgMXS9SYwm8zlo2ijLaEa2euXx71Q0vwOe59cndmWW3zykzUoZkgOVTYgd4leNq8tqtbVQ+ZQS5C8g7WHpeyLs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1681373770665885.7316137495017; Thu, 13 Apr 2023 01:16:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643--4zoZyP0P1Cjv__529hUPg-1; Thu, 13 Apr 2023 04:16:05 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18E2D2807D6A; Thu, 13 Apr 2023 08:16:03 +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 309E9492C13; Thu, 13 Apr 2023 08:16:02 +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 D3DB019465A2; Thu, 13 Apr 2023 08:16:01 +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 CAAF319465A2 for ; Thu, 13 Apr 2023 08:15:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 45C5A2166B2B; Thu, 13 Apr 2023 08:15:59 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFB0D2166B26 for ; Thu, 13 Apr 2023 08:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373769; 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=L4jjspSRv98DmhWdmw/9knRl1svI9vVW7g/8R7FM2D0=; b=fqgOnbNo168Ld53O0TMZ8lUYTDjCAojv2OZ2Bqnnb/kIIYbHJqCa2ZAk6Iz+9qPltK+zLR A8zNwdGwUYw60B2AIf8wCrKFvblYAS3gJia3IsA0lXW/hmT4r/wwqjyB8t+JBnP+EWAJ2F UWBgDXdogK67Hn3yVZAyn5vIyUgGqkk= X-MC-Unique: -4zoZyP0P1Cjv__529hUPg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 2/8] Don't translate strings used with VIR_DEBUG Date: Thu, 13 Apr 2023 10:15:50 +0200 Message-Id: <70e330bf8a950d00f7b5fa274bbf2639b9968fc9.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.9 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: 1681373771901100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virnetlink.c | 6 +++--- src/vz/vz_driver.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index f18a08c277..866f4d8f2b 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -1300,7 +1300,7 @@ virNetlinkGetNeighbor(void **nlData G_GNUC_UNUSED, */ int virNetlinkEventServiceStop(unsigned int protocol G_GNUC_UNUSED) { - VIR_DEBUG("%s", _(unsupported)); + VIR_DEBUG("%s", unsupported); return 0; } @@ -1310,7 +1310,7 @@ int virNetlinkEventServiceStop(unsigned int protocol = G_GNUC_UNUSED) */ int virNetlinkEventServiceStopAll(void) { - VIR_DEBUG("%s", _(unsupported)); + VIR_DEBUG("%s", unsupported); return 0; } @@ -1321,7 +1321,7 @@ int virNetlinkEventServiceStopAll(void) int virNetlinkEventServiceStart(unsigned int protocol G_GNUC_UNUSED, unsigned int groups G_GNUC_UNUSED) { - VIR_DEBUG("%s", _(unsupported)); + VIR_DEBUG("%s", unsupported); return 0; } diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 56dc236233..401ca041ed 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -4101,7 +4101,7 @@ vzStateInitialize(bool privileged, return VIR_DRV_STATE_INIT_ERROR; if (prlsdkInit() < 0) { - VIR_DEBUG("%s", _("Can't initialize Parallels SDK")); + VIR_DEBUG("Can't initialize Parallels SDK"); return VIR_DRV_STATE_INIT_ERROR; } @@ -4144,7 +4144,7 @@ vzRegister(void) prlctl_path =3D virFindFileInPath(PRLCTL); if (!prlctl_path) { - VIR_DEBUG("%s", _("Can't find prlctl command in the PATH env")); + VIR_DEBUG("Can't find prlctl command in the PATH env"); return 0; } --=20 2.39.2 From nobody Mon Feb 9 05:38:44 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=1681373773; cv=none; d=zohomail.com; s=zohoarc; b=GBWJBd/z7p39Ma28yG/gTlzPh5DA+s3HQz9YUNMg0NA+8aXXeQ/9+q01HeAbbCn/4dsPnEzS+R7Ah1qeDb9nLvUlU1RNUl1NWH6z1ZeVhYTNPT0ntvFMvM4VK5TYxUbtZagd9X0UHpRFUjgaFWiiPXFHP69+PplCePuQdUOmXww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373773; 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=TiCtL+EOF2SqsG9EqI/NrEa8s5hkQtVJxm8vzphkpDs=; b=k4nolDAveRLJle2irat6Ij7Fj4ft5t9ARcENFoFNxLfS2lJd4SjCOjCA2v1HVeKRnfUJwhFyNkUmmmnRgTGPpxziHE9V+CVtS4+EzelpkRmjX7Wy3GbbKDYWHSZ/FsmWfDkvRcXQ/mrxhmrk19fAu0aMCvb91tXX6U9zciAjnV0= 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 1681373773320821.978852251632; Thu, 13 Apr 2023 01:16:13 -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-480-a50Sg4qIOPmFvkVwKP5teQ-1; Thu, 13 Apr 2023 04:16:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE77F109DD00; Thu, 13 Apr 2023 08:16:04 +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 AF7F92027044; Thu, 13 Apr 2023 08:16:04 +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 8B44019472E5; Thu, 13 Apr 2023 08:16:02 +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 CD5B219465B6 for ; Thu, 13 Apr 2023 08:16:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 197802166B2C; Thu, 13 Apr 2023 08:16:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91BC92166B26 for ; Thu, 13 Apr 2023 08:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373772; 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=TiCtL+EOF2SqsG9EqI/NrEa8s5hkQtVJxm8vzphkpDs=; b=GSnYneT4K+bPFgan/k1gonwjwuEE5R6FKtagNuG7NwAcLQpdQhoEDPAK+O2bVK2vl79+X7 Pi7tpB06pA7tKNZ7Lh5ovUwRvBC40sIXR+5A1/mFl08zCBQu32KRvEsVs7htp0+Ck89KE6 8F49US5PdcF9MF8GIIt8PyXId0RMLI4= X-MC-Unique: a50Sg4qIOPmFvkVwKP5teQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 3/8] virshGraphicsAddressToString: Remove pointless translation Date: Thu, 13 Apr 2023 10:15:51 +0200 Message-Id: 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.4 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: 1681373773728100005 Content-Type: text/plain; charset="utf-8" There's no point in marking the protocol name as translatable. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-domain-event.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 2ad4573ee9..1ed204fa9a 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -211,15 +211,19 @@ virshGraphicsPhaseToString(int phase) VIR_ENUM_DECL(virshGraphicsAddress); VIR_ENUM_IMPL(virshGraphicsAddress, VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_LAST, - N_("IPv4"), - N_("IPv6"), - N_("unix")); + "IPv4", + "IPv6", + "unix"); static const char * virshGraphicsAddressToString(int family) { const char *str =3D virshGraphicsAddressTypeToString(family); - return str ? _(str) : _("unknown"); + + if (str) + return str; + + return _("unknown"); } VIR_ENUM_DECL(virshDomainBlockJobStatus); --=20 2.39.2 From nobody Mon Feb 9 05:38:44 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=1681373826; cv=none; d=zohomail.com; s=zohoarc; b=V35ar3LYzH3Qxr/yF51yEitVXMb5QAKcs+zaOn8KQpTXPioiFP0ccPjpnG91TVD/mBTUrfN4dOh0Nx/V2s2NwkMN1/lPIFbrSnAumfD+Y+0Ar6vTBiAn4neFWa5q649m+9/1yN7+mqO2Nz+x+lJrMzyqqEOq2ZcJLn1zGd/tNBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373826; 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=1q9A+cOWj2hiRQK/ETUwK6bn2lrirk4SSpm9jvXVqs8=; b=jGPLW8teh+Bh/D54K8jgz8boxdhIZitObgf9k9a1xLyjN45s+j7BPslM2JYOkWyl0ZD/TxJKspoOpxJSD7yld4nAYJ3l3rdDq1gngUWCPTHljKOLS4iJGZ3LdBhvtKy2bCKXx0GL7z1cZIdk8Yeu17/4Cms1PLFSAZPgd/3zy8g= 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 1681373826140795.4591416312438; Thu, 13 Apr 2023 01:17:06 -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-244-W-IFONGlN_Wf6KfJvexpFQ-1; Thu, 13 Apr 2023 04:16:09 -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 8612A1871DB6; Thu, 13 Apr 2023 08:16:05 +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 6EC711121320; Thu, 13 Apr 2023 08:16:05 +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 CD02719472F4; Thu, 13 Apr 2023 08:16:02 +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 1877A1946597 for ; Thu, 13 Apr 2023 08:16:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EF7772166B29; Thu, 13 Apr 2023 08:16:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 711782166B26 for ; Thu, 13 Apr 2023 08:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373825; 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=1q9A+cOWj2hiRQK/ETUwK6bn2lrirk4SSpm9jvXVqs8=; b=MfJacay7d1G86sMMug/hQPxBpmz/JfRBprTDZqsq1WrWWl9VJjYoXSTaGGp4SqAQpttakr d0lw21KzofsQ+ZGYBBgFBf08wPW+yRB7WeB9qkbGXoEngPANtrDs4Tz+yP7aDie79d/8xT Sx3eHKGWJf1pG7Tgh+Df6MV2fDEghyo= X-MC-Unique: W-IFONGlN_Wf6KfJvexpFQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 4/8] vshPrint: Add version using 'va_list' Date: Thu, 13 Apr 2023 10:15:52 +0200 Message-Id: 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: 1681373828264100007 Content-Type: text/plain; charset="utf-8" Add a version for functions which may already need to take a printf format string. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/vsh.c | 32 ++++++++++++++++++++++---------- tools/vsh.h | 4 ++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 5b672b8edf..41f55a91fa 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1865,34 +1865,46 @@ vshDebug(vshControl *ctl, int level, const char *fo= rmat, ...) fflush(stdout); } + void -vshPrintExtra(vshControl *ctl, const char *format, ...) +vshPrintVa(vshControl *ctl G_GNUC_UNUSED, + const char *format, + va_list ap) { - va_list ap; g_autofree char *str =3D NULL; + str =3D g_strdup_vprintf(format, ap); + fputs(str, stdout); + fflush(stdout); +} + + +void +vshPrintExtra(vshControl *ctl, + const char *format, + ...) +{ + va_list ap; + if (ctl && ctl->quiet) return; va_start(ap, format); - str =3D g_strdup_vprintf(format, ap); + vshPrintVa(ctl, format, ap); va_end(ap); - fputs(str, stdout); - fflush(stdout); } void -vshPrint(vshControl *ctl G_GNUC_UNUSED, const char *format, ...) +vshPrint(vshControl *ctl, + const char *format, + ...) { va_list ap; - g_autofree char *str =3D NULL; va_start(ap, format); - str =3D g_strdup_vprintf(format, ap); + vshPrintVa(ctl, format, ap); va_end(ap); - fputs(str, stdout); - fflush(stdout); } diff --git a/tools/vsh.h b/tools/vsh.h index 51f09cd2b0..377c5947c1 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -302,6 +302,10 @@ const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, co= nst vshCmd *cmd, bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv); int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *time= out); +void vshPrintVa(vshControl *ctl, + const char *format, + va_list ap) + G_GNUC_PRINTF(2, 0); void vshPrint(vshControl *ctl, const char *format, ...) G_GNUC_PRINTF(2, 3); void vshPrintExtra(vshControl *ctl, const char *format, ...) --=20 2.39.2 From nobody Mon Feb 9 05:38:44 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 Reviewed-by: Michal Privoznik --- 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 From nobody Mon Feb 9 05:38:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1681373775; cv=none; d=zohomail.com; s=zohoarc; b=VzTlzaw5i8O2x1trmeEFOd1RfHBxKS+mrQmiLQC7A16eHa8YSJjFP5XdtjIr5BPeF5EcVXjziFs9FCnB+KN5qhZGZYccXGmDBWJxz5wM9ftACnunQM8Mk9fG5TMs+23yXebfMP5VoHFbB86G5vlvUJZilD7SwrQdVMh0x6YKIY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373775; 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=mHQqI/O9SC1rQcsWfaawOB991nLAi+xwaof6d7zvGtE=; b=YShuf+JdE7BnrN+tn3IieB58pijWKgUXmMtqKUm5DSxONjEAqxJtEy/kG8QHFkqSi6IsVc7HHdkWDPMOlp2C2V8ofNC0JJa5sSDeUzaWEjxd+5eChr5sIwkST1yKIpS0Aq1LkaTfmfcGkSGTL04leVaUk6DJyqTVHEFk9w6IXOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 168137377535537.13049067419752; Thu, 13 Apr 2023 01:16:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-21-gavV2icSO6O8srjJXfFChQ-1; Thu, 13 Apr 2023 04:16:10 -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 400191C0757A; Thu, 13 Apr 2023 08:16:06 +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 22191112132D; Thu, 13 Apr 2023 08:16:06 +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 5630F19466DF; Thu, 13 Apr 2023 08:16:03 +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 B65DC19472F4 for ; Thu, 13 Apr 2023 08:16:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9C4BB2166B29; Thu, 13 Apr 2023 08:16:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EF6D2166B26 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=1681373774; 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=mHQqI/O9SC1rQcsWfaawOB991nLAi+xwaof6d7zvGtE=; b=go1eiLs9mLMBPRgrv7ZjFLM86RxBZt+arPjzmfQli6DLlsZxm8N6Qpzd8WYRs/lC5IlHm1 8WV3U/n0u8KyRY1JAd+pVtevGOazyHlVxcZFo+BBDbgjmmeGu6VBLyfDqvgsQT6cuVoZ3g P0uzz+3vipxYneQyGvAQNNY2pXSpdpA= X-MC-Unique: gavV2icSO6O8srjJXfFChQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 6/8] virsh-domain-event: Make 'virshEventTrayChangePrint' translation friendly Date: Thu, 13 Apr 2023 10:15:54 +0200 Message-Id: <4ff72f71129ea92a0cf88c02890384830c5fb236.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: 1681373775581100007 Content-Type: text/plain; charset="utf-8" Remove construction of the event string from sub-strings marked as translatable. Without context it's impossible to translate it correctly. This slightly increases verbosity of the code but actually makes it more readable as everything is inline. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-domain-event.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index a8a321590c..c522d79dd7 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -254,20 +254,6 @@ virshDomainEventDiskChangeToString(int reason) return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(virshDomainEventTrayChange); -VIR_ENUM_IMPL(virshDomainEventTrayChange, - VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST, - N_("opened"), - N_("closed")); - -static const char * -virshDomainEventTrayChangeToString(int reason) -{ - const char *str =3D virshDomainEventTrayChangeTypeToString(reason); - return str ? _(str) : _("unknown"); -} - - struct virshDomainEventCallback { const char *name; virConnectDomainEventGenericCallback cb; @@ -511,13 +497,23 @@ virshEventTrayChangePrint(virConnectPtr conn G_GNUC_U= NUSED, int reason, void *opaque) { - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + switch ((virDomainEventTrayChangeReason) reason) { + case VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN: + virshEventPrintf(opaque, _("event 'tray-change' for domain '%1$s' = disk %2$s: opened\n"), + virDomainGetName(dom), alias); + break; - virBufferAsprintf(&buf, _("event 'tray-change' for domain '%1$s' disk = %2$s: %3$s\n"), - virDomainGetName(dom), - alias, - virshDomainEventTrayChangeToString(reason)); - virshEventPrint(opaque, &buf); + case VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE: + virshEventPrintf(opaque, _("event 'tray-change' for domain '%1$s' = disk %2$s: closed\n"), + virDomainGetName(dom), alias); + break; + + case VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST: + default: + virshEventPrintf(opaque, _("event 'tray-change' for domain '%1$s' = disk %2$s: unknown\n"), + virDomainGetName(dom), alias); + break; + } } static void --=20 2.39.2 From nobody Mon Feb 9 05:38:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1681373826; cv=none; d=zohomail.com; s=zohoarc; b=FHHxqN+GapnQZ2ioSAtDHikcHkb4kuH5OGBvbRBo8RhsyhYP3fmmbAV0/KIxtfnSYH8SR+3jn59OD0z7hCom7lhwgpFvMfIHHVzo5YktK+xUhq+3AYbyd0SDoPsqbMx5bJEdwsOteeOuQ3P5Ga1iubRlv4eVbc7KTXn/dyBqpRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373826; 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=PjyodVGW1Kqj26B3SDYmVuX5g3PmVTjHpp8z9grZ6sU=; b=AeQI9+vy5yWa2EtfDRBl5BzNMaJAFI+tUGoG8KMAhPuHdTT7r+GlH/DDv4EfP8/COiydUk8L+hQC7/ijSHqpYRhgOTu/LAL1OalNCDzDTV3GducUPHiJRIx3NasOxXGjSPxhxI5oNQl7CTmeuZQStboa8LRZ4injkfd6nRGuiyg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1681373826388214.16088211572048; Thu, 13 Apr 2023 01:17:06 -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-295-QEaFDXJKMQmtWExvlvdKIw-1; Thu, 13 Apr 2023 04:16:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9E5A88434A; Thu, 13 Apr 2023 08:16:06 +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 ADEFA2027061; Thu, 13 Apr 2023 08:16:06 +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 1EB331946A75; Thu, 13 Apr 2023 08:16:05 +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 805281949738 for ; Thu, 13 Apr 2023 08:16:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 769EE2166B2B; Thu, 13 Apr 2023 08:16:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E92C42166B29 for ; Thu, 13 Apr 2023 08:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373825; 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=PjyodVGW1Kqj26B3SDYmVuX5g3PmVTjHpp8z9grZ6sU=; b=aZWizE3O4BBmd6tWkA706oxQJclIzvCmlM6ynDyCfbc3BkK4x8Wmgojq5rdpRKwyW8jOYI 3ZbmAVg4lTV8Yo/a+2fEgaCVuWO6UgTxyqbUguDwUjvVikzgpYBXJpLw3+rdr4psis0FgR GUWf4XwI4LkzwISzwdPuk3xYlnJeTn0= X-MC-Unique: QEaFDXJKMQmtWExvlvdKIw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 7/8] virsh-domain-event: Make 'virshEventWatchdogPrint' translation friendly Date: Thu, 13 Apr 2023 10:15:55 +0200 Message-Id: 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.4 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: 1681373827180100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-domain-event.c | 59 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index c522d79dd7..8656b0fa09 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -162,24 +162,6 @@ virshDomainEventDetailToString(int event, int detail) return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(virshDomainEventWatchdog); -VIR_ENUM_IMPL(virshDomainEventWatchdog, - VIR_DOMAIN_EVENT_WATCHDOG_LAST, - N_("none"), - N_("pause"), - N_("reset"), - N_("poweroff"), - N_("shutdown"), - N_("debug"), - N_("inject-nmi")); - -static const char * -virshDomainEventWatchdogToString(int action) -{ - const char *str =3D virshDomainEventWatchdogTypeToString(action); - return str ? _(str) : _("unknown"); -} - VIR_ENUM_DECL(virshDomainEventIOError); VIR_ENUM_IMPL(virshDomainEventIOError, VIR_DOMAIN_EVENT_IO_ERROR_LAST, @@ -371,12 +353,41 @@ virshEventWatchdogPrint(virConnectPtr conn G_GNUC_UNU= SED, int action, void *opaque) { - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - - virBufferAsprintf(&buf, _("event 'watchdog' for domain '%1$s': %2$s\n"= ), - virDomainGetName(dom), - virshDomainEventWatchdogToString(action)); - virshEventPrint(opaque, &buf); + switch ((virDomainEventWatchdogAction) action) { + case VIR_DOMAIN_EVENT_WATCHDOG_NONE: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': no= ne\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_PAUSE: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': pa= use\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_RESET: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': re= set\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': po= weroff\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': sh= utdown\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_DEBUG: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': de= bug\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_INJECTNMI: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': in= ject-nmi\n"), + virDomainGetName(dom)); + break; + case VIR_DOMAIN_EVENT_WATCHDOG_LAST: + default: + virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': un= known\n"), + virDomainGetName(dom)); + break; + } } static void --=20 2.39.2 From nobody Mon Feb 9 05:38:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1681373827; cv=none; d=zohomail.com; s=zohoarc; b=G1DHnWf9uitBvvzYgCDVC88yq7EkFW7aAAxUV72CsV4+QyXY/9G6XSTX1Z9HAnP/sgLq2xBojLHpsFv+AoblcF6vXY6OgA5W66CVU+JlPfBJQxZi4XEr2s8W7yEYuUTsPMubJOJIkg29ZU8Njo6GkaTZY41Vq7Tf2J/2OogZ+cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681373827; 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=nUO5A6VmPw4F5BHFNlXGu4VDEUdfy469GbFy43iQWtM=; b=TwqUvY6UoJjAfVdoOZ8eGSostmcXe50FpXrqDsumFXhRFOGWp33IDhX97hlMWA5gf9gtGZZVmqGiY1IFOfUjf9fsRTPUKsOOtQxZhPPjgKG9G5RST6CfJL2UBFFB2ISE3xCZs25kA5xU0Ig17D0pjmcKbHuB2QJD9ES1Pq4vOJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1681373827460860.4675434483321; Thu, 13 Apr 2023 01:17:07 -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-274-xnUugD3GPxCp2Tv5a6hgxw-1; Thu, 13 Apr 2023 04:16:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 210E1109DD03; 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 0C0A040C6F88; 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 54B9019472D2; Thu, 13 Apr 2023 08:16:05 +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 66CD21946A75 for ; Thu, 13 Apr 2023 08:16:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4C8DB2166B2B; Thu, 13 Apr 2023 08:16:04 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C55482166B26 for ; Thu, 13 Apr 2023 08:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681373826; 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=nUO5A6VmPw4F5BHFNlXGu4VDEUdfy469GbFy43iQWtM=; b=cAAfoQJeGO3Raaj1FYn0wZyfIoFPlbtCCUmAZmrh29dYJoZXnS/zrU87uWjtsc8PQSMxSb f0s2kLKXs0gucxcBzbHJkaQFtCA7KpoUpvjMN9YH+3bpfw1F6eLes1TGnDCM0GrofNCA8x 31DX/vkycZQkz/dCsrpjd70vEKahSEM= X-MC-Unique: xnUugD3GPxCp2Tv5a6hgxw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 8/8] virsh-domain-event: Make 'virshEventIOError(Reason)Print' translation friendly Date: Thu, 13 Apr 2023 10:15:56 +0200 Message-Id: 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.2 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: 1681373828001100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/virsh-domain-event.c | 70 +++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 8656b0fa09..2969c22a91 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -162,20 +162,6 @@ virshDomainEventDetailToString(int event, int detail) return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(virshDomainEventIOError); -VIR_ENUM_IMPL(virshDomainEventIOError, - VIR_DOMAIN_EVENT_IO_ERROR_LAST, - N_("none"), - N_("pause"), - N_("report")); - -static const char * -virshDomainEventIOErrorToString(int action) -{ - const char *str =3D virshDomainEventIOErrorTypeToString(action); - return str ? _(str) : _("unknown"); -} - VIR_ENUM_DECL(virshGraphicsPhase); VIR_ENUM_IMPL(virshGraphicsPhase, VIR_DOMAIN_EVENT_GRAPHICS_LAST, @@ -398,14 +384,25 @@ virshEventIOErrorPrint(virConnectPtr conn G_GNUC_UNUS= ED, int action, void *opaque) { - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - - virBufferAsprintf(&buf, _("event 'io-error' for domain '%1$s': %2$s (%= 3$s) %4$s\n"), - virDomainGetName(dom), - srcPath, - devAlias, - virshDomainEventIOErrorToString(action)); - virshEventPrint(opaque, &buf); + switch ((virDomainEventIOErrorAction) action) { + case VIR_DOMAIN_EVENT_IO_ERROR_NONE: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) none\n"), + virDomainGetName(dom), srcPath, devAlias); + break; + case VIR_DOMAIN_EVENT_IO_ERROR_PAUSE: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) pause\n"), + virDomainGetName(dom), srcPath, devAlias); + break; + case VIR_DOMAIN_EVENT_IO_ERROR_REPORT: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) report\n"), + virDomainGetName(dom), srcPath, devAlias); + break; + case VIR_DOMAIN_EVENT_IO_ERROR_LAST: + default: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) unknown\n"), + virDomainGetName(dom), srcPath, devAlias); + break; + } } static void @@ -449,16 +446,25 @@ virshEventIOErrorReasonPrint(virConnectPtr conn G_GNU= C_UNUSED, const char *reason, void *opaque) { - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - - virBufferAsprintf(&buf, _("event 'io-error-reason' for domain '%1$s': " - "%2$s (%3$s) %4$s due to %5$s\n"), - virDomainGetName(dom), - srcPath, - devAlias, - virshDomainEventIOErrorToString(action), - reason); - virshEventPrint(opaque, &buf); + switch ((virDomainEventIOErrorAction) action) { + case VIR_DOMAIN_EVENT_IO_ERROR_NONE: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) none due to %4$s\n"), + virDomainGetName(dom), srcPath, devAlias, reason); + break; + case VIR_DOMAIN_EVENT_IO_ERROR_PAUSE: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) pause due to %4$s\n"), + virDomainGetName(dom), srcPath, devAlias, reason); + break; + case VIR_DOMAIN_EVENT_IO_ERROR_REPORT: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) report due to %4$s\n"), + virDomainGetName(dom), srcPath, devAlias, reason); + break; + case VIR_DOMAIN_EVENT_IO_ERROR_LAST: + default: + virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2= $s (%3$s) unknown due to %4$s\n"), + virDomainGetName(dom), srcPath, devAlias, reason); + break; + } } static void --=20 2.39.2