From 3edde2608cac6d7571ac772349239eda10470ea3 Mon Sep 17 00:00:00 2001 From: Shuo A Liu Date: Wed, 8 Jan 2020 09:20:18 +0800 Subject: [PATCH] hv: debug: show vcpu thread status in vcpu_list debug command Due to vcpu and its thread are two different perspective modules, each of them has its own status. Dump both states for better understanding of system status. Tracked-On: #4329 Signed-off-by: Shuo A Liu Acked-by: Eddie Dong --- hypervisor/debug/shell.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 9e8b1ae87..b58f92943 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -637,12 +637,12 @@ static int32_t shell_list_vcpu(__unused int32_t argc, __unused char **argv) char temp_str[MAX_STR_SIZE]; struct acrn_vm *vm; struct acrn_vcpu *vcpu; - char state[32]; + char vcpu_state_str[32], thread_state_str[32]; uint16_t i; uint16_t idx; - shell_puts("\r\nVM ID PCPU ID VCPU ID VCPU ROLE VCPU STATE" - "\r\n===== ======= ======= ========= ==========\r\n"); + shell_puts("\r\nVM ID PCPU ID VCPU ID VCPU ROLE VCPU STATE THREAD STATE" + "\r\n===== ======= ======= ========= ========== ==========\r\n"); for (idx = 0U; idx < CONFIG_MAX_VM_NUM; idx++) { vm = get_vm_from_vmid(idx); @@ -652,31 +652,47 @@ static int32_t shell_list_vcpu(__unused int32_t argc, __unused char **argv) foreach_vcpu(i, vm, vcpu) { switch (vcpu->state) { case VCPU_INIT: - (void)strncpy_s(state, 32U, "Init", 32U); + (void)strncpy_s(vcpu_state_str, 32U, "Init", 32U); break; case VCPU_PAUSED: - (void)strncpy_s(state, 32U, "Paused", 32U); + (void)strncpy_s(vcpu_state_str, 32U, "Paused", 32U); break; case VCPU_RUNNING: - (void)strncpy_s(state, 32U, "Running", 32U); + (void)strncpy_s(vcpu_state_str, 32U, "Running", 32U); break; case VCPU_ZOMBIE: - (void)strncpy_s(state, 32U, "Zombie", 32U); + (void)strncpy_s(vcpu_state_str, 32U, "Zombie", 32U); break; default: - (void)strncpy_s(state, 32U, "Unknown", 32U); + (void)strncpy_s(vcpu_state_str, 32U, "Unknown", 32U); + break; + } + + switch (vcpu->thread_obj.status) { + case THREAD_STS_RUNNING: + (void)strncpy_s(thread_state_str, 32U, "RUNNING", 32U); + break; + case THREAD_STS_RUNNABLE: + (void)strncpy_s(thread_state_str, 32U, "RUNNABLE", 32U); + break; + case THREAD_STS_BLOCKED: + (void)strncpy_s(thread_state_str, 32U, "BLOCKED", 32U); + break; + default: + (void)strncpy_s(thread_state_str, 32U, "UNKNOWN", 32U); + break; } /* Create output string consisting of VM name * and VM id */ snprintf(temp_str, MAX_STR_SIZE, - " %-9d %-10d %-7hu %-12s %-16s\r\n", + " %-9d %-10d %-7hu %-12s %-16s %-16s\r\n", vm->vm_id, pcpuid_from_vcpu(vcpu), vcpu->vcpu_id, is_vcpu_bsp(vcpu) ? "PRIMARY" : "SECONDARY", - state); + vcpu_state_str, thread_state_str); /* Output information for this task */ shell_puts(temp_str); }