]> xenbits.xensource.com Git - xen.git/commitdiff
xl: introduce a function to get shutdown action name
authorWei Liu <wei.liu2@citrix.com>
Mon, 27 Feb 2017 17:28:17 +0000 (17:28 +0000)
committerWei Liu <wei.liu2@citrix.com>
Tue, 28 Feb 2017 10:40:07 +0000 (10:40 +0000)
The array to map libxl_shutdown_action_to_shutdown to string is going to
be moved to a dedicated file.

Provide a function to do the translation so that we don't need to make
the array globally visible.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xl/xl_cmdimpl.c

index 86c70f5a22a4d44c53ec284bb3299bbb69fb352c..d027d53a3f27b2002258aafd5c1516d403c1581c 100644 (file)
@@ -101,6 +101,11 @@ static const char *action_on_shutdown_names[] = {
     [LIBXL_ACTION_ON_SHUTDOWN_SOFT_RESET] = "soft-reset",
 };
 
+static const char *get_action_on_shutdown_name(libxl_action_on_shutdown a)
+{
+    return action_on_shutdown_names[a];
+}
+
 /* Optional data, in order:
  *   4 bytes uint32_t  config file size
  *   n bytes           config file in Unix text file format
@@ -2442,7 +2447,7 @@ static domain_restart_type handle_domain_death(uint32_t *r_domid,
 
     LOG("Action for shutdown reason code %d is %s",
         event->u.domain_shutdown.shutdown_reason,
-        action_on_shutdown_names[action]);
+        get_action_on_shutdown_name(action));
 
     if (action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY || action == LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART) {
         char *corefile;