From c82e3fd26488adf5d5cf02331fe71220a2584d84 Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Thu, 20 Jun 2019 10:00:24 +0000 Subject: [PATCH] HV: Debug: Add version command When debugging the HV, we may want to check the HV version information frequently. In current HV shell command, there is no such kind of command to check this information. We can only scroll up the HV console log to get the information. If there are very huge amount of lines of log, it will be very time-wasting to get the HV version information. So, this patch adds 'version' command to get the HV version information conveniently. Tracked-On: #3310 Acked-by: Anthony Xu Signed-off-by: Kaige Fu --- hypervisor/debug/shell.c | 23 +++++++++++++++++++++++ hypervisor/debug/shell_priv.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 59d9f275b..aeb514c0d 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -18,6 +18,7 @@ #include #include #include +#include #define TEMP_STR_SIZE 60U #define MAX_STR_SIZE 256U @@ -32,6 +33,7 @@ static char shell_log_buf[SHELL_LOG_BUF_SIZE]; #define SHELL_INPUT_LINE_OTHER(v) (((v) + 1U) & 0x1U) static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv); +static int32_t shell_version(__unused int32_t argc, __unused char **argv); static int32_t shell_list_vm(__unused int32_t argc, __unused char **argv); static int32_t shell_list_vcpu(__unused int32_t argc, __unused char **argv); static int32_t shell_vcpu_dumpreg(int32_t argc, char **argv); @@ -54,6 +56,12 @@ static struct shell_cmd shell_cmds[] = { .help_str = SHELL_CMD_HELP_HELP, .fcn = shell_cmd_help, }, + { + .str = SHELL_CMD_VERSION, + .cmd_param = SHELL_CMD_VERSION_PARAM, + .help_str = SHELL_CMD_VERSION_HELP, + .fcn = shell_version, + }, { .str = SHELL_CMD_VM_LIST, .cmd_param = SHELL_CMD_VM_LIST_PARAM, @@ -552,6 +560,21 @@ static int32_t shell_cmd_help(__unused int32_t argc, __unused char **argv) return 0; } +static int32_t shell_version(__unused int32_t argc, __unused char **argv) +{ + char temp_str[MAX_STR_SIZE]; + + snprintf(temp_str, MAX_STR_SIZE, "HV version %s-%s-%s %s (daily tag: %s) build by %s\r\n", + HV_FULL_VERSION, HV_BUILD_TIME, HV_BUILD_VERSION, HV_BUILD_TYPE, HV_DAILY_TAG, HV_BUILD_USER); + shell_puts(temp_str); + + (void)memset((void *)temp_str, 0, MAX_STR_SIZE); + snprintf(temp_str, MAX_STR_SIZE, "API version %u.%u\r\n", HV_API_MAJOR_VERSION, HV_API_MINOR_VERSION); + shell_puts(temp_str); + + return 0; +} + static int32_t shell_list_vm(__unused int32_t argc, __unused char **argv) { char temp_str[MAX_STR_SIZE]; diff --git a/hypervisor/debug/shell_priv.h b/hypervisor/debug/shell_priv.h index d4f31ab0e..c5aa170b0 100644 --- a/hypervisor/debug/shell_priv.h +++ b/hypervisor/debug/shell_priv.h @@ -40,6 +40,10 @@ struct shell { #define SHELL_CMD_HELP_PARAM NULL #define SHELL_CMD_HELP_HELP "Display information about supported hypervisor shell commands" +#define SHELL_CMD_VERSION "version" +#define SHELL_CMD_VERSION_PARAM NULL +#define SHELL_CMD_VERSION_HELP "Display the HV version information" + #define SHELL_CMD_VM_LIST "vm_list" #define SHELL_CMD_VM_LIST_PARAM NULL #define SHELL_CMD_VM_LIST_HELP "List all VMs, displaying the VM UUID, ID, name and state"