From nobody Tue Dec 16 11:43:22 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1740065462276706.1190579316557; Thu, 20 Feb 2025 07:31:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2B48C21EC; Thu, 20 Feb 2025 10:31:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 95A322243; Thu, 20 Feb 2025 10:27:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 114122224; Thu, 20 Feb 2025 10:26:53 -0500 (EST) 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 AAA6B1F66 for ; Thu, 20 Feb 2025 10:26:38 -0500 (EST) 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-660-PnjgmrXGOfuYrUIKglAjag-1; Thu, 20 Feb 2025 10:26:37 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 555F91801A2E for ; Thu, 20 Feb 2025 15:26:36 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D8EE41800362 for ; Thu, 20 Feb 2025 15:26:35 +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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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=1740065198; 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=rt11ByWzbL+rRoLrcaTKj9TYL3TzajXWUo0XtCe3PqU=; b=FAxi5+hN6SjMY/fefkyw2UniCnZoIowJKKTUsM+nF9So3uiJ9tnTLrfpPoneQoHgxms2Tl F9KBf54+l6+hAJ4yu2kCrEkPjcpIXgnZsnsNpwKQq0fAXxhRNeh100c+dSNdyQNMcQj0js jgLbSLc6dQdrQE2GU8mVTViI/CcNWb8= X-MC-Unique: PnjgmrXGOfuYrUIKglAjag-1 X-Mimecast-MFC-AGG-ID: PnjgmrXGOfuYrUIKglAjag_1740065196 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH 09/13] virsh: Properly mark all error messages for translation Date: Thu, 20 Feb 2025 16:26:11 +0100 Message-ID: <505b7df8dc5a665abfbb81b0543a67cad538467b.1740064957.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sN4KXjkZczYpuvbxGUy2_9S6rdYmL06qKiKKMt_h3kM_1740065196 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HOPDJWURT73BM3KDDJFVYFNK3BGFHTV6 X-Message-ID-Hash: HOPDJWURT73BM3KDDJFVYFNK3BGFHTV6 X-MailFrom: jdenemar@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 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1740065463992019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- tools/virsh-domain-monitor.c | 6 ++--- tools/virsh-domain.c | 12 ++++----- tools/virsh-host.c | 2 +- tools/virsh-nodedev.c | 6 ++--- tools/virsh-secret.c | 2 +- tools/virsh.c | 4 +-- tools/virt-admin.c | 4 +-- tools/vsh.c | 50 +++++++++++++++++++----------------- 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 76843005b2..150e6ec806 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -452,7 +452,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) =20 all =3D vshCommandOptBool(cmd, "all"); if (!all && vshCommandOptStringQuiet(ctl, cmd, "device", &device) <=3D= 0) { - vshError(ctl, "command 'domblkinfo' requires option"); + vshError(ctl, "%s", _("command 'domblkinfo' requires opti= on")); return false; } =20 @@ -604,7 +604,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) =20 target =3D virXPathString("string(./target/@dev)", ctxt); if (!target) { - vshError(ctl, "unable to query block list"); + vshError(ctl, "%s", _("unable to query block list")); return false; } =20 @@ -616,7 +616,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) if (!(namespace =3D virXPathString("string(./source/@namespace= )", ctxt)) || !(addrNode =3D virXPathNode("./source/address", ctxt)) || virPCIDeviceAddressParseXML(addrNode, &addr) < 0) { - vshError(ctl, "Unable to query NVMe disk address"); + vshError(ctl, "%s", _("Unable to query NVMe disk address")= ); return false; } =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 171bc0ce17..e20888f2c2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7915,7 +7915,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) goto failed_stats; =20 if (cpu >=3D max_id) { - vshError(ctl, "Start CPU %d is out of range (min: 0, max: %d)", + vshError(ctl, _("Start CPU %1$d is out of range (min: 0, max: %2$d= )"), cpu, max_id - 1); goto cleanup; } @@ -9787,7 +9787,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) resultjson =3D virJSONValueFromString(result); =20 if (returnval && !resultjson) { - vshError(ctl, "failed to parse JSON returned by qemu"); + vshError(ctl, "%s", _("failed to parse JSON returned by qemu")= ); return false; } } @@ -9800,7 +9800,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) =20 if (returnval) { if (!(formatjson =3D virJSONValueObjectGet(resultjson, "return")))= { - vshError(ctl, "'return' member missing"); + vshError(ctl, "%s", _("'return' member missing")); return false; } } else { @@ -10859,7 +10859,7 @@ doMigrate(void *opaque) =20 if (flags & VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES && !(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_IN= C))) { - vshError(ctl, "'--copy-storage-synchronous-writes' requires one of= '--copy-storage-all', '--copy-storage-inc'"); + vshError(ctl, "%s", _("'--copy-storage-synchronous-writes' require= s one of '--copy-storage-all', '--copy-storage-inc'")); goto out; } =20 @@ -10918,7 +10918,7 @@ doMigrate(void *opaque) g_autofree char **val =3D NULL; =20 if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARE= D_INC))) { - vshError(ctl, "'--migrate-disks' requires one of '--copy-stora= ge-all', '--copy-storage-inc'"); + vshError(ctl, "%s", _("'--migrate-disks' requires one of '--co= py-storage-all', '--copy-storage-inc'")); goto out; } =20 @@ -10939,7 +10939,7 @@ doMigrate(void *opaque) g_autofree char **val =3D NULL; =20 if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARE= D_INC))) { - vshError(ctl, "'--migrate-disks-detect-zeroes' requires one of= '--copy-storage-all', '--copy-storage-inc'"); + vshError(ctl, "%s", _("'--migrate-disks-detect-zeroes' require= s one of '--copy-storage-all', '--copy-storage-inc'")); goto out; } =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 418bd995da..1b992e70f6 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -455,7 +455,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) =20 if (rv =3D=3D 0) { vshError(ctl, - "Could not get count of free %uKiB pages, no data ret= urned", + _("Could not get count of free %1$uKiB pages, no data= returned"), *pagesize); goto cleanup; } diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index e759b9f629..7ae6127513 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -129,7 +129,7 @@ vshFindNodeDevice(vshControl *ctl, const char *value) } =20 if (!dev) { - vshError(ctl, "%s '%s'", _("Could not find matching device"), valu= e); + vshError(ctl, _("Could not find matching device '%1$s'"), value); return NULL; } =20 @@ -969,8 +969,8 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) =20 if (device_value) { if (!(dev =3D virNodeDeviceLookupByName(priv->conn, device_value))= ) { - vshError(ctl, "%s '%s'", - _("Could not find matching device"), device_value); + vshError(ctl, _("Could not find matching device '%1$s'"), + device_value); goto cleanup; } } diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 7c81c10845..3a4160107b 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -320,7 +320,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) if (plain) { if (fwrite(value, 1, value_size, stdout) !=3D value_size) { virSecureErase(value, value_size); - vshError(ctl, "failed to write secret"); + vshError(ctl, "%s", _("failed to write secret")); return false; } } else { diff --git a/tools/virsh.c b/tools/virsh.c index 6abae3dae9..090fdb2017 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -657,8 +657,8 @@ virshParseArgv(vshControl *ctl, int argc, char **argv) break; case 'd': if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) { - vshError(ctl, _("option %1$s takes a numeric argument"), - longindex =3D=3D -1 ? "-d" : "--debug"); + const char *optStr =3D longindex =3D=3D -1 ? "-d" : "--deb= ug"; + vshError(ctl, _("option %1$s takes a numeric argument"), o= ptStr); exit(EXIT_FAILURE); } if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 16c9b2173a..fe2868d379 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1271,8 +1271,8 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **arg= v) break; case 'd': if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) { - vshError(ctl, _("option %1$s takes a numeric argument"), - longindex =3D=3D -1 ? "-d" : "--debug"); + const char *optStr =3D longindex =3D=3D -1 ? "-d" : "--deb= ug"; + vshError(ctl, _("option %1$s takes a numeric argument"), o= ptStr); exit(EXIT_FAILURE); } if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) diff --git a/tools/vsh.c b/tools/vsh.c index fb00cc40a6..fd6156ea76 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -280,34 +280,34 @@ vshCmddefCheckInternals(vshControl *ctl, const vshCmdDef *alias; =20 if (!(alias =3D vshCmddefSearch(cmd->alias))) { - vshError(ctl, "command alias '%s' is pointing to a non-existen= t command '%s'", + vshError(ctl, _("command alias '%1$s' is pointing to a non-exi= stent command '%2$s'"), cmd->name, cmd->alias); return -1; } =20 if (alias->alias) { - vshError(ctl, "command alias '%s' is pointing to another comma= nd alias '%s'", + vshError(ctl, _("command alias '%1$s' is pointing to another c= ommand alias '%2$s'"), cmd->name, cmd->alias); return -1; } =20 if (cmd->handler) { - vshError(ctl, "command '%s' has handler set", cmd->name); + vshError(ctl, _("command '%1$s' has handler set"), cmd->name); return -1; } =20 if (cmd->opts) { - vshError(ctl, "command '%s' has options set", cmd->name); + vshError(ctl, _("command '%1$s' has options set"), cmd->name); return -1; } =20 if (cmd->info) { - vshError(ctl, "command '%s' has info set", cmd->name); + vshError(ctl, _("command '%1$s' has info set"), cmd->name); return -1; } =20 if (cmd->flags !=3D 0) { - vshError(ctl, "command '%s' has multiple flags set", cmd->name= ); + vshError(ctl, _("command '%1$s' has multiple flags set"), cmd-= >name); return -1; } =20 @@ -317,7 +317,7 @@ vshCmddefCheckInternals(vshControl *ctl, =20 /* Each command has to provide a non-empty help string. */ if (!cmd->info || !cmd->info->help || !*cmd->info->help) { - vshError(ctl, "command '%s' lacks help", cmd->name); + vshError(ctl, _("command '%1$s' lacks help"), cmd->name); return -1; } =20 @@ -348,7 +348,7 @@ vshCmddefCheckInternals(vshControl *ctl, /* allow at most one optional positional option */ if (opt->positional && !opt->required) { if (seenOptionalPositionalOption) { - vshError(ctl, "multiple optional positional arguments (%s,= %s) of command '%s' are not allowed", + vshError(ctl, _("multiple optional positional arguments (%= 1$s, %2$s) of command '%3$s' are not allowed"), seenOptionalPositionalOption, opt->name, cmd->nam= e); return -1; } @@ -358,45 +358,45 @@ vshCmddefCheckInternals(vshControl *ctl, =20 /* all optional positional arguments must be defined after the req= uired ones */ if (seenOptionalPositionalOption && opt->positional && opt->requir= ed) { - vshError(ctl, "required positional argument '%s' declared afte= r an optional positional argument '%s' of command '%s'", + vshError(ctl, _("required positional argument '%1$s' declared = after an optional positional argument '%2$s' of command '%3$s'"), opt->name, seenOptionalPositionalOption, cmd->name); return -1; } =20 /* Mandate no completer flags if no completer is specified */ if (opt->completer_flags !=3D 0 && !opt->completer) { - vshError(ctl, "completer_flags of argument '%s' of command '%s= ' must be 0 if no completer is used", + vshError(ctl, _("completer_flags of argument '%1$s' of command= '%2$s' must be 0 if no completer is used"), opt->name, cmd->name); return -1; } =20 if (opt->unwanted_positional && opt->positional) { - vshError(ctl, "unwanted_positional flag of argument '%s' of co= mmand '%s' must not be used together with positional", + vshError(ctl, _("unwanted_positional flag of argument '%1$s' o= f command '%2$s' must not be used together with positional"), opt->name, cmd->name); return -1; } =20 switch (opt->type) { case VSH_OT_NONE: - vshError(ctl, "invalid type 'NONE' of option '%s' of command '= %s'", + vshError(ctl, _("invalid type 'NONE' of option '%1$s' of comma= nd '%2$s'"), opt->name, cmd->name); return -1; =20 case VSH_OT_BOOL: if (opt->completer) { - vshError(ctl, "bool parameter '%s' of command '%s' has com= pleter set", + vshError(ctl, _("bool parameter '%1$s' of command '%2$s' h= as completer set"), opt->name, cmd->name); return -1; } =20 if (opt->positional || opt->unwanted_positional) { - vshError(ctl, "boolean parameter '%s' of command '%s' must= not be positional", + vshError(ctl, _("boolean parameter '%1$s' of command '%2$s= ' must not be positional"), opt->name, cmd->name); return -1; } =20 if (opt->required) { - vshError(ctl, "parameter '%s' of command '%s' misused 'req= uired' flag", + vshError(ctl, _("parameter '%1$s' of command '%2$s' misuse= d 'required' flag"), opt->name, cmd->name); return -1; /* bool can't be mandatory */ } @@ -413,7 +413,7 @@ vshCmddefCheckInternals(vshControl *ctl, opt->unwanted_positional || opt->completer || !opt->help) { - vshError(ctl, "parameter '%s' of command '%s' has incorrec= t alias option", + vshError(ctl, _("parameter '%1$s' of command '%2$s' has in= correct alias option"), opt->name, cmd->name); return -1; } @@ -429,13 +429,13 @@ vshCmddefCheckInternals(vshControl *ctl, if (p) { /* If alias comes with value, replacement must not be bool= */ if (cmd->opts[j].type =3D=3D VSH_OT_BOOL) { - vshError(ctl, "alias '%s' of command '%s' has mismatch= ed alias type", + vshError(ctl, _("alias '%1$s' of command '%2$s' has mi= smatched alias type"), opt->name, cmd->name); return -1; } } if (!cmd->opts[j].name) { - vshError(ctl, "alias '%s' of command '%s' has missing alia= s option", + vshError(ctl, _("alias '%1$s' of command '%2$s' has missin= g alias option"), opt->name, cmd->name); return -1; } @@ -444,7 +444,7 @@ vshCmddefCheckInternals(vshControl *ctl, =20 case VSH_OT_ARGV: if (cmd->opts[i + 1].name) { - vshError(ctl, "parameter '%s' of command '%s' must be list= ed last", + vshError(ctl, _("parameter '%1$s' of command '%2$s' must b= e listed last"), opt->name, cmd->name); return -1; } @@ -453,7 +453,7 @@ vshCmddefCheckInternals(vshControl *ctl, case VSH_OT_INT: case VSH_OT_STRING: if (opt->positional && seenOptionalOption) { - vshError(ctl, "parameter '%s' of command '%s' must be list= ed before optional parameters", + vshError(ctl, _("parameter '%1$s' of command '%2$s' must b= e listed before optional parameters"), opt->name, cmd->name); return -1; } @@ -2424,9 +2424,13 @@ vshCloseLogFile(vshControl *ctl) { /* log file close */ if (VIR_CLOSE(ctl->log_fd) < 0) { - vshError(ctl, _("%1$s: failed to write log file: %2$s"), - ctl->logfile ? ctl->logfile : "?", - g_strerror(errno)); + if (ctl->logfile) { + vshError(ctl, _("%1$s: failed to write log file: %2$s"), + ctl->logfile, g_strerror(errno)); + } else { + vshError(ctl, _("failed to write log file: %1$s"), + g_strerror(errno)); + } } =20 g_clear_pointer(&ctl->logfile, g_free); --=20 2.48.1