git: 8caac07ce933 - stable/13 - bhyvectl: Add '--get-debug-cpus' command

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Fri, 18 Aug 2023 07:18:49 UTC
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=8caac07ce933a5d8c3a57e12d6b1537c6235d712

commit 8caac07ce933a5d8c3a57e12d6b1537c6235d712
Author:     Vitaliy Gusev <gusev.vitaliy@gmail.com>
AuthorDate: 2023-07-25 12:03:54 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-08-18 07:04:26 +0000

    bhyvectl: Add '--get-debug-cpus' command
    
    vmm and libvmmapi already have handlers for that. When adding debug
    cpus, they were only used for the debug stub. Over time, they were
    reused by other parts like snapshots or idle APs.
    
    Reviewed by:            corvink, jhb
    MFC after:              1 week
    Sponsored by:           vStack
    Differential Revision:  https://reviews.freebsd.org/D40804
    
    (cherry picked from commit 65f8467e3351c38a9d57b538b85cf6c5fab5818e)
---
 usr.sbin/bhyvectl/bhyvectl.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 2a022c550d54..dfa523ea16c8 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -190,6 +190,7 @@ usage(bool cpu_intel)
 	"       [--set-rtc-nvram=<val>]\n"
 	"       [--rtc-nvram-offset=<offset>]\n"
 	"       [--get-active-cpus]\n"
+	"       [--get-debug-cpus]\n"
 	"       [--get-suspended-cpus]\n"
 	"       [--get-intinfo]\n"
 	"       [--get-eptp]\n"
@@ -265,7 +266,7 @@ static int force_reset, force_poweroff;
 static const char *capname;
 static int create, destroy, get_memmap, get_memseg;
 static int get_intinfo;
-static int get_active_cpus, get_suspended_cpus;
+static int get_active_cpus, get_debug_cpus, get_suspended_cpus;
 static uint64_t memsize;
 static int set_cr0, get_cr0, set_cr2, get_cr2, set_cr3, get_cr3;
 static int set_cr4, get_cr4;
@@ -1450,6 +1451,7 @@ setup_options(bool cpu_intel)
 		{ "force-reset",	NO_ARG,	&force_reset,		1 },
 		{ "force-poweroff", 	NO_ARG,	&force_poweroff, 	1 },
 		{ "get-active-cpus", 	NO_ARG,	&get_active_cpus, 	1 },
+		{ "get-debug-cpus",	NO_ARG,	&get_debug_cpus,	1 },
 		{ "get-suspended-cpus", NO_ARG,	&get_suspended_cpus, 	1 },
 		{ "get-intinfo", 	NO_ARG,	&get_intinfo,		1 },
 		{ "get-cpu-topology",	NO_ARG, &get_cpu_topology,	1 },
@@ -2324,6 +2326,12 @@ main(int argc, char *argv[])
 			print_cpus("active cpus", &cpus);
 	}
 
+	if (!error && (get_debug_cpus || get_all)) {
+		error = vm_debug_cpus(ctx, &cpus);
+		if (!error)
+			print_cpus("debug cpus", &cpus);
+	}
+
 	if (!error && (get_suspended_cpus || get_all)) {
 		error = vm_suspended_cpus(ctx, &cpus);
 		if (!error)