]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-domain-event: Make 'virshEventWatchdogPrint' translation friendly
authorPeter Krempa <pkrempa@redhat.com>
Thu, 13 Apr 2023 06:39:22 +0000 (08:39 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 14 Apr 2023 13:22:02 +0000 (15:22 +0200)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain-event.c

index c522d79dd788c75b3d1bdb0b7fef376ee1a6d18e..8656b0fa092ba594fdf221b2aeb316bcf1d554d3 100644 (file)
@@ -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 = 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_UNUSED,
                         int action,
                         void *opaque)
 {
-    g_auto(virBuffer) buf = 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': none\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_PAUSE:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': pause\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_RESET:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': reset\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': poweroff\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': shutdown\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_DEBUG:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': debug\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_INJECTNMI:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': inject-nmi\n"),
+                         virDomainGetName(dom));
+        break;
+    case VIR_DOMAIN_EVENT_WATCHDOG_LAST:
+    default:
+        virshEventPrintf(opaque, _("event 'watchdog' for domain '%1$s': unknown\n"),
+                         virDomainGetName(dom));
+        break;
+    }
 }
 
 static void