]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Avoid using translated messages without format
authorJiri Denemark <jdenemar@redhat.com>
Thu, 20 Feb 2025 13:23:33 +0000 (14:23 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 24 Feb 2025 10:14:11 +0000 (11:14 +0100)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain-monitor.c
tools/virsh-domain.c
tools/virsh-host.c
tools/virsh-secret.c
tools/virsh-snapshot.c
tools/virsh-util.c
tools/virsh-volume.c
tools/virsh.c
tools/virt-admin.c

index 150e6ec806c9b7f72d0373f9e27fe1df70fe639d..fa1c05ac77c9fbd88ed6dbacb7f51cb5d74bca41 100644 (file)
@@ -783,7 +783,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
                             iface);
 
     if ((ninterfaces = virXPathNodeSet(xpath, ctxt, &interfaces)) < 0) {
-        vshError(ctl, _("Failed to extract interface information"));
+        vshError(ctl, "%s", _("Failed to extract interface information"));
         return false;
     }
 
@@ -795,7 +795,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
 
         return false;
     } else if (ninterfaces > 1) {
-        vshError(ctl, _("multiple matching interfaces found"));
+        vshError(ctl, "%s", _("multiple matching interfaces found"));
         return false;
     }
 
@@ -1386,7 +1386,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
 
     if (doSet || now || rtcSync) {
         if (now && ((seconds = time(NULL)) == (time_t) -1)) {
-            vshError(ctl, _("Unable to get current time"));
+            vshError(ctl, "%s", _("Unable to get current time"));
             return false;
         }
 
@@ -2288,7 +2288,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0) {
-        vshError(ctl, _("Failed to query for interfaces addresses"));
+        vshError(ctl, "%s", _("Failed to query for interfaces addresses"));
         goto cleanup;
     }
 
index e20888f2c28b13fb479065eaf5e569c9d270e651..2db88a1a7dcd666024e99d1c9a7ff9470ccfdf98 100644 (file)
@@ -540,7 +540,7 @@ cmdAttachDiskFormatAddress(vshControl *ctl,
     struct virshAddress diskAddr;
 
     if (virshAddressParse(straddr, multifunction, &diskAddr) < 0) {
-        vshError(ctl, _("Invalid address."));
+        vshError(ctl, "%s", _("Invalid address."));
         return -1;
     }
 
@@ -689,7 +689,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     }
 
     if ((type == VIRSH_ATTACH_DISK_SOURCE_TYPE_NETWORK) != !!source_protocol) {
-        vshError(ctl, _("--source-protocol option requires --sourcetype network"));
+        vshError(ctl, "%s", _("--source-protocol option requires --sourcetype network"));
         return false;
     }
 
@@ -992,7 +992,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
         if (virshParseRateStr(ctl, inboundStr, &inbound) < 0)
             return false;
         if (!inbound.average && !inbound.floor) {
-            vshError(ctl, _("either inbound average or floor is mandatory"));
+            vshError(ctl, "%s", _("either inbound average or floor is mandatory"));
             return false;
         }
     }
@@ -1000,11 +1000,11 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
         if (virshParseRateStr(ctl, outboundStr, &outbound) < 0)
             return false;
         if (outbound.average == 0) {
-            vshError(ctl, _("outbound average is mandatory"));
+            vshError(ctl, "%s", _("outbound average is mandatory"));
             return false;
         }
         if (outbound.floor) {
-            vshError(ctl, _("outbound floor is unsupported yet"));
+            vshError(ctl, "%s", _("outbound floor is unsupported yet"));
             return false;
         }
     }
@@ -1048,7 +1048,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 
     case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
         if (sourceMode < 0) {
-            vshError(ctl, _("source-mode is mandatory"));
+            vshError(ctl, "%s", _("source-mode is mandatory"));
             return false;
         }
         virBufferAsprintf(&buf, "<source type='unix' path='%s' mode='%s'/>\n",
@@ -3144,7 +3144,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if ((nnodes = virXPathNodeSet("/domain/devices/interface", ctxt, &nodes)) <= 0) {
-        vshError(ctl, _("Failed to extract interface information or no interfaces found"));
+        vshError(ctl, "%s", _("Failed to extract interface information or no interfaces found"));
         return false;
     }
 
@@ -3177,7 +3177,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
     /* try to find <link> element or create new one */
     if (!(linkNode = virXPathNode("./link", ctxt))) {
         if (!(linkNode = xmlNewChild(ifaceNode, NULL, BAD_CAST "link", NULL))) {
-            vshError(ctl, _("failed to create XML node"));
+            vshError(ctl, "%s", _("failed to create XML node"));
             return false;
         }
     }
@@ -3188,13 +3188,13 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
         stateAttr = xmlNewProp(linkNode, BAD_CAST "state", BAD_CAST state);
 
     if (!stateAttr) {
-        vshError(ctl, _("Failed to create or modify the state XML attribute"));
+        vshError(ctl, "%s", _("Failed to create or modify the state XML attribute"));
         return false;
     }
 
     if (!(xml_buf = virXMLNodeToString(xml, ifaceNode))) {
         vshSaveLibvirtError();
-        vshError(ctl, _("Failed to create XML"));
+        vshError(ctl, "%s", _("Failed to create XML"));
         return false;
     }
 
@@ -3204,7 +3204,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (virDomainUpdateDeviceFlags(dom, xml_buf, flags) < 0) {
-        vshError(ctl, _("Failed to update interface link state"));
+        vshError(ctl, "%s", _("Failed to update interface link state"));
         return false;
     }
 
@@ -3297,7 +3297,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
 
         if ((!inbound.average && (inbound.burst || inbound.peak)) &&
             !inbound.floor) {
-            vshError(ctl, _("either inbound average or floor is mandatory"));
+            vshError(ctl, "%s", _("either inbound average or floor is mandatory"));
             goto cleanup;
         }
 
@@ -3335,12 +3335,12 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
         }
         if (outbound.average == 0 && (outbound.burst || outbound.peak)) {
-            vshError(ctl, _("outbound average is mandatory"));
+            vshError(ctl, "%s", _("outbound average is mandatory"));
             goto cleanup;
         }
 
         if (outbound.floor) {
-            vshError(ctl, _("outbound floor is unsupported yet"));
+            vshError(ctl, "%s", _("outbound floor is unsupported yet"));
             goto cleanup;
         }
 
@@ -3659,7 +3659,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     ignore_value(vshCommandOptStringQuiet(ctl, cmd, "storage", &vol_string));
 
     if (!(vol_string || remove_all_storage) && wipe_storage) {
-        vshError(ctl,
+        vshError(ctl, "%s",
                  _("'--wipe-storage' requires '--storage <string>' or '--remove-all-storage'"));
         return false;
     }
@@ -3744,13 +3744,13 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     /* Stash domain description for later use */
     if (vol_string || remove_all_storage) {
         if (running) {
-            vshError(ctl,
+            vshError(ctl, "%s",
                      _("Storage volume deletion is supported only on stopped domains"));
             goto cleanup;
         }
 
         if (vol_string && remove_all_storage) {
-            vshError(ctl,
+            vshError(ctl, "%s",
                      _("Specified both --storage and --remove-all-storage"));
             goto cleanup;
         }
@@ -3923,7 +3923,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
                               vols[i].target, vols[i].source);
                 fflush(stdout);
                 if (virStorageVolWipe(vols[i].vol, 0) < 0) {
-                    vshError(ctl, _("Failed! Volume not removed."));
+                    vshError(ctl, "%s", _("Failed! Volume not removed."));
                     ret = false;
                     continue;
                 } else {
@@ -7206,7 +7206,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (count == 0) {
-        vshError(ctl, _("Can't set 0 processors for a VM"));
+        vshError(ctl, "%s", _("Can't set 0 processors for a VM"));
         return false;
     }
 
@@ -7272,7 +7272,7 @@ cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (cpulist && !(enable || disable)) {
-        vshError(ctl, _("One of options --enable or --disable is required by option --cpulist"));
+        vshError(ctl, "%s", _("One of options --enable or --disable is required by option --cpulist"));
         return false;
     }
 
@@ -7470,7 +7470,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0) {
-        vshError(ctl, _("Unable to get domain IOThreads information"));
+        vshError(ctl, "%s", _("Unable to get domain IOThreads information"));
         goto cleanup;
     }
     niothreads = rc;
@@ -7751,7 +7751,7 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (npar == 0) {
-        vshError(ctl, _("Not enough arguments passed, nothing to set"));
+        vshError(ctl, "%s", _("Not enough arguments passed, nothing to set"));
         return false;
     }
 
@@ -8593,7 +8593,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
 
     for (opt = vshCommandOptArgv(cmd, "keycode"); opt && *opt; opt++) {
         if (count == VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
-            vshError(ctl, _("too many keycodes"));
+            vshError(ctl, "%s", _("too many keycodes"));
             return false;
         }
 
@@ -8922,10 +8922,10 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML,
         vshSaveLibvirtError();
         return -1;
     } else if (nmems == 0) {
-        vshError(ctl, _("no memory device found"));
+        vshError(ctl, "%s", _("no memory device found"));
         return -1;
     } else if (nmems > 1) {
-        vshError(ctl, _("multiple memory devices found, use --alias or --node to select one"));
+        vshError(ctl, "%s", _("multiple memory devices found, use --alias or --node to select one"));
         return -1;
     }
 
@@ -8944,7 +8944,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML,
         requestedSizeNode = virXPathNode("./target/requested", ctxt);
 
         if (!requestedSizeNode) {
-            vshError(ctl, _("virtio-mem device is missing <requested/>"));
+            vshError(ctl, "%s", _("virtio-mem device is missing <requested/>"));
             return -1;
         }
 
@@ -11730,7 +11730,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (!virDomainIsActive(dom)) {
-        vshError(ctl, _("Domain is not running"));
+        vshError(ctl, "%s", _("Domain is not running"));
         return false;
     }
 
@@ -11767,7 +11767,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
         if (type)
             vshError(ctl, _("No graphical display with type '%1$s' found"), type);
         else
-            vshError(ctl, _("No graphical display found"));
+            vshError(ctl, "%s", _("No graphical display found"));
     }
 
     return ret;
@@ -11800,7 +11800,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
 
     /* Check if the domain is active and don't rely on -1 for this */
     if (!virDomainIsActive(dom)) {
-        vshError(ctl, _("Domain is not running"));
+        vshError(ctl, "%s", _("Domain is not running"));
         return false;
     }
 
@@ -11810,7 +11810,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
     /* Get the VNC port */
     if (virXPathInt("string(/domain/devices/graphics[@type='vnc']/@port)",
                     ctxt, &port)) {
-        vshError(ctl, _("Failed to get VNC port. Is this domain using VNC?"));
+        vshError(ctl, "%s", _("Failed to get VNC port. Is this domain using VNC?"));
         return false;
     }
 
@@ -12454,7 +12454,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
         source_block = false;
         new_source = NULL;
     } else if (!new_source) {
-        vshError(NULL, _("New disk media source was not specified"));
+        vshError(NULL, "%s", _("New disk media source was not specified"));
         return NULL;
     }
 
@@ -12861,7 +12861,7 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (virDomainFSTrim(dom, mountPoint, minimum, flags) < 0) {
-        vshError(ctl, _("Unable to invoke fstrim"));
+        vshError(ctl, "%s", _("Unable to invoke fstrim"));
         return false;
     }
 
@@ -12898,7 +12898,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
         nmountpoints = g_strv_length((GStrv) mountpoints);
 
     if ((count = virDomainFSFreeze(dom, mountpoints, nmountpoints, 0)) < 0) {
-        vshError(ctl, _("Unable to freeze filesystems"));
+        vshError(ctl, "%s", _("Unable to freeze filesystems"));
         return false;
     }
 
@@ -12936,7 +12936,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
         nmountpoints = g_strv_length((GStrv) mountpoints);
 
     if ((count = virDomainFSThaw(dom, mountpoints, nmountpoints, 0)) < 0) {
-        vshError(ctl, _("Unable to thaw filesystems"));
+        vshError(ctl, "%s", _("Unable to thaw filesystems"));
         return false;
     }
 
@@ -12970,7 +12970,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
 
     rc = virDomainGetFSInfo(dom, &info, 0);
     if (rc < 0) {
-        vshError(ctl, _("Unable to get filesystem information"));
+        vshError(ctl, "%s", _("Unable to get filesystem information"));
         goto cleanup;
     }
     ninfos = rc;
@@ -13252,7 +13252,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
             flags |= VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_APPEND;
 
             if (!from) {
-                vshError(ctl, _("Option --file is required"));
+                vshError(ctl, "%s", _("Option --file is required"));
                 return false;
             }
         }
index 1b992e70f665972579ad76690e349e620a6dac33..9e8f542c96770dadf624f4c5b97be31c8babdb89 100644 (file)
@@ -1146,7 +1146,7 @@ vshExtractCPUDefXMLs(vshControl *ctl,
             xmlNodeSetName(nodes[i], (const xmlChar *)"cpu");
             while (nodes[i]->properties) {
                 if (xmlRemoveProp(nodes[i]->properties) < 0) {
-                    vshError(ctl,
+                    vshError(ctl, "%s",
                              _("Cannot extract CPU definition from domain capabilities XML"));
                     return NULL;
                 }
index 3a4160107b31f645ff96ff4e236cd14ad79184fe..68b14a5276d0b594c9190984d92358d13f27e2a1 100644 (file)
@@ -235,7 +235,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
 
     if (base64) {
         /* warn users that the --base64 option passed from command line is wrong */
-        vshWarn(ctl, _("Passing secret value as command-line argument is insecure!"));
+        vshWarn(ctl, "%s", _("Passing secret value as command-line argument is insecure!"));
         secret_val = g_strdup(base64);
         secret_len = strlen(secret_val);
     } else if (filename) {
@@ -257,7 +257,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
         secret_len = strlen(secret_val);
         plain = true;
     } else {
-        vshError(ctl, _("Input secret value is missing"));
+        vshError(ctl, "%s", _("Input secret value is missing"));
         return false;
     }
 
index e0be8e758287c316ce2c6216e9a7cd51d9c49b15..2821cd9e26621c7c67cd26d3151ed5373e281bfd 100644 (file)
@@ -1140,7 +1140,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
 
     if (count < 0) {
         if (!last_error)
-            vshError(ctl, _("failed to collect snapshot list"));
+            vshError(ctl, "%s", _("failed to collect snapshot list"));
         goto cleanup;
     }
 
index 55ab71f26aca6034c0624b9acdec6d6c7ffa3833..a4ae5be08ce60ca1c58df37a1cfdfc27262def06 100644 (file)
@@ -383,14 +383,14 @@ virshDomainGetXMLFromDom(vshControl *ctl,
     g_autofree char *desc = NULL;
 
     if (!(desc = virDomainGetXMLDesc(dom, flags))) {
-        vshError(ctl, _("Failed to get domain description xml"));
+        vshError(ctl, "%s", _("Failed to get domain description xml"));
         return -1;
     }
 
     *xml = virXMLParseStringCtxt(desc, _("(domain_definition)"), ctxt);
 
     if (!(*xml)) {
-        vshError(ctl, _("Failed to parse domain description xml"));
+        vshError(ctl, "%s", _("Failed to parse domain description xml"));
         return -1;
     }
 
@@ -408,14 +408,14 @@ virshNetworkGetXMLFromNet(vshControl *ctl,
     g_autofree char *desc = NULL;
 
     if (!(desc = virNetworkGetXMLDesc(net, flags))) {
-        vshError(ctl, _("Failed to get network description xml"));
+        vshError(ctl, "%s", _("Failed to get network description xml"));
         return -1;
     }
 
     *xml = virXMLParseStringCtxt(desc, _("(network_definition)"), ctxt);
 
     if (!(*xml)) {
-        vshError(ctl, _("Failed to parse network description xml"));
+        vshError(ctl, "%s", _("Failed to parse network description xml"));
         return -1;
     }
 
index 430961fef2a5559aeda9bad841b50c14d15eff65..7b1847d7aeb7f91d1974b1f889dbf226157df9f2 100644 (file)
@@ -676,7 +676,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM;
 
     if (!(st = virStreamNew(priv->conn, 0))) {
-        vshError(ctl, _("cannot create a new stream"));
+        vshError(ctl, "%s", _("cannot create a new stream"));
         return false;
     }
 
@@ -793,7 +793,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
     cbData.isBlock = !!S_ISBLK(sb.st_mode);
 
     if (!(st = virStreamNew(priv->conn, 0))) {
-        vshError(ctl, _("cannot create a new stream"));
+        vshError(ctl, "%s", _("cannot create a new stream"));
         goto cleanup;
     }
 
index 090fdb2017023f8041dd665cd7fc34733977ce33..800e280c7a55160fd2203eb1278d5d49bcf74624 100644 (file)
@@ -757,7 +757,7 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
                 vshError(ctl, _("unsupported option '%1$s'. See --help."), argv[optind - 1]);
             exit(EXIT_FAILURE);
         default:
-            vshError(ctl, _("unknown option"));
+            vshError(ctl, "%s", _("unknown option"));
             exit(EXIT_FAILURE);
         }
         longindex = -1;
index fe2868d3798e27a62fc7d93a32e785d19feb2a12..2d630984441becfe3a36b64478240d1af2c3bc6a 100644 (file)
@@ -975,14 +975,14 @@ cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cmd)
         const char *filters = NULL;
         if ((vshCommandOptString(ctl, cmd, "filters", &filters) < 0 ||
              virAdmConnectSetLoggingFilters(priv->conn, filters, 0) < 0)) {
-            vshError(ctl, _("Unable to change daemon logging settings"));
+            vshError(ctl, "%s", _("Unable to change daemon logging settings"));
             return false;
         }
     } else {
         g_autofree char *filters = NULL;
         if (virAdmConnectGetLoggingFilters(priv->conn,
                                            &filters, 0) < 0) {
-            vshError(ctl, _("Unable to get daemon logging filters information"));
+            vshError(ctl, "%s", _("Unable to get daemon logging filters information"));
             return false;
         }
 
@@ -1024,13 +1024,13 @@ cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd)
         const char *outputs = NULL;
         if ((vshCommandOptString(ctl, cmd, "outputs", &outputs) < 0 ||
              virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) {
-            vshError(ctl, _("Unable to change daemon logging settings"));
+            vshError(ctl, "%s", _("Unable to change daemon logging settings"));
             return false;
         }
     } else {
         g_autofree char *outputs = NULL;
         if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) {
-            vshError(ctl, _("Unable to get daemon logging outputs information"));
+            vshError(ctl, "%s", _("Unable to get daemon logging outputs information"));
             return false;
         }
 
@@ -1320,7 +1320,7 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **argv)
                 vshError(ctl, _("unsupported option '%1$s'. See --help."), argv[optind - 1]);
             exit(EXIT_FAILURE);
         default:
-            vshError(ctl, _("unknown option"));
+            vshError(ctl, "%s", _("unknown option"));
             exit(EXIT_FAILURE);
         }
         longindex = -1;