Skip to content

Commit 3edde26

Browse files
Shuo A Liuwenlingz
authored andcommitted
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 <shuo.a.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent db708fc commit 3edde26

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

hypervisor/debug/shell.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,12 @@ static int32_t shell_list_vcpu(__unused int32_t argc, __unused char **argv)
637637
char temp_str[MAX_STR_SIZE];
638638
struct acrn_vm *vm;
639639
struct acrn_vcpu *vcpu;
640-
char state[32];
640+
char vcpu_state_str[32], thread_state_str[32];
641641
uint16_t i;
642642
uint16_t idx;
643643

644-
shell_puts("\r\nVM ID PCPU ID VCPU ID VCPU ROLE VCPU STATE"
645-
"\r\n===== ======= ======= ========= ==========\r\n");
644+
shell_puts("\r\nVM ID PCPU ID VCPU ID VCPU ROLE VCPU STATE THREAD STATE"
645+
"\r\n===== ======= ======= ========= ========== ==========\r\n");
646646

647647
for (idx = 0U; idx < CONFIG_MAX_VM_NUM; idx++) {
648648
vm = get_vm_from_vmid(idx);
@@ -652,31 +652,47 @@ static int32_t shell_list_vcpu(__unused int32_t argc, __unused char **argv)
652652
foreach_vcpu(i, vm, vcpu) {
653653
switch (vcpu->state) {
654654
case VCPU_INIT:
655-
(void)strncpy_s(state, 32U, "Init", 32U);
655+
(void)strncpy_s(vcpu_state_str, 32U, "Init", 32U);
656656
break;
657657
case VCPU_PAUSED:
658-
(void)strncpy_s(state, 32U, "Paused", 32U);
658+
(void)strncpy_s(vcpu_state_str, 32U, "Paused", 32U);
659659
break;
660660
case VCPU_RUNNING:
661-
(void)strncpy_s(state, 32U, "Running", 32U);
661+
(void)strncpy_s(vcpu_state_str, 32U, "Running", 32U);
662662
break;
663663
case VCPU_ZOMBIE:
664-
(void)strncpy_s(state, 32U, "Zombie", 32U);
664+
(void)strncpy_s(vcpu_state_str, 32U, "Zombie", 32U);
665665
break;
666666
default:
667-
(void)strncpy_s(state, 32U, "Unknown", 32U);
667+
(void)strncpy_s(vcpu_state_str, 32U, "Unknown", 32U);
668+
break;
669+
}
670+
671+
switch (vcpu->thread_obj.status) {
672+
case THREAD_STS_RUNNING:
673+
(void)strncpy_s(thread_state_str, 32U, "RUNNING", 32U);
674+
break;
675+
case THREAD_STS_RUNNABLE:
676+
(void)strncpy_s(thread_state_str, 32U, "RUNNABLE", 32U);
677+
break;
678+
case THREAD_STS_BLOCKED:
679+
(void)strncpy_s(thread_state_str, 32U, "BLOCKED", 32U);
680+
break;
681+
default:
682+
(void)strncpy_s(thread_state_str, 32U, "UNKNOWN", 32U);
683+
break;
668684
}
669685
/* Create output string consisting of VM name
670686
* and VM id
671687
*/
672688
snprintf(temp_str, MAX_STR_SIZE,
673-
" %-9d %-10d %-7hu %-12s %-16s\r\n",
689+
" %-9d %-10d %-7hu %-12s %-16s %-16s\r\n",
674690
vm->vm_id,
675691
pcpuid_from_vcpu(vcpu),
676692
vcpu->vcpu_id,
677693
is_vcpu_bsp(vcpu) ?
678694
"PRIMARY" : "SECONDARY",
679-
state);
695+
vcpu_state_str, thread_state_str);
680696
/* Output information for this task */
681697
shell_puts(temp_str);
682698
}

0 commit comments

Comments
 (0)