From ccecd55075991a07013a7e0aa87d513f5f02ef39 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Mon, 8 Apr 2019 15:08:51 +0800 Subject: [PATCH] HV: show VM UUID in shell Enhance "vm_list" command in shell to Show VM UUID; Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- doc/user-guides/acrn-shell.rst | 2 +- hypervisor/debug/shell.c | 14 ++++++++++---- hypervisor/debug/shell_priv.h | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/user-guides/acrn-shell.rst b/doc/user-guides/acrn-shell.rst index 86c7bff70..e599e4005 100644 --- a/doc/user-guides/acrn-shell.rst +++ b/doc/user-guides/acrn-shell.rst @@ -14,7 +14,7 @@ The ACRN hypervisor shell supports the following commands: * - help - Display information about supported hypervisor shell commands * - vm_list - - List all VMs, displaying the VM name, ID, and state ("Started"=running) + - List all VMs, displaying the VM UUID, ID, name, and state ("Started"=running) * - vcpu_list - List all vCPUs in all VMs * - vcpu_dumpreg diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index ef45df383..ae3feaab6 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -561,8 +561,8 @@ static int32_t shell_list_vm(__unused int32_t argc, __unused char **argv) uint16_t vm_id; char state[32]; - shell_puts("\r\nVM NAME\t\t\t\tVM ID\t\tVM STATE" - "\r\n=======\t\t\t\t=====\t\t========\r\n"); + shell_puts("\r\nVM_UUID VM_ID VM_NAME VM_STATE" + "\r\n================================ ===== ================================ ========\r\n"); for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) { vm = get_vm_from_vmid(vm_id); @@ -581,8 +581,14 @@ static int32_t shell_list_vm(__unused int32_t argc, __unused char **argv) break; } vm_config = get_vm_config(vm_id); - if (vm_config->type != UNDEFINED_VM) { - snprintf(temp_str, MAX_STR_SIZE, "%-34s%-14d%-8s\r\n", vm_config->name, vm_id, state); + if (is_valid_vm(vm)) { + int8_t i; + + for (i = 0; i < 16; i++) { + snprintf(temp_str + 2 * i, 3U, "%02x", vm->uuid[i]); + } + snprintf(temp_str + 32, MAX_STR_SIZE - 32U, " %-3d %-32s %-8s\r\n", + vm_id, vm_config->name, state); /* Output information for this task */ shell_puts(temp_str); diff --git a/hypervisor/debug/shell_priv.h b/hypervisor/debug/shell_priv.h index 8bc6370f9..14ded89e6 100644 --- a/hypervisor/debug/shell_priv.h +++ b/hypervisor/debug/shell_priv.h @@ -40,7 +40,7 @@ struct shell { #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 name, ID, and state" +#define SHELL_CMD_VM_LIST_HELP "List all VMs, displaying the VM UUID, ID, name and state" #define SHELL_CMD_VCPU_LIST "vcpu_list" #define SHELL_CMD_VCPU_LIST_PARAM NULL