aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bhyvectl
diff options
context:
space:
mode:
authorNeel Natu <neel@FreeBSD.org>2014-05-31 23:37:34 +0000
committerNeel Natu <neel@FreeBSD.org>2014-05-31 23:37:34 +0000
commit95ebc360efc984cab758d634f1c357b73650f651 (patch)
tree7c418a681bb97d7aaf33db6bbb701d15bf078026 /usr.sbin/bhyvectl
parent2ceda70233797308c9428775ba5c761c0e0fc859 (diff)
downloadsrc-95ebc360efc984cab758d634f1c357b73650f651.tar.gz
src-95ebc360efc984cab758d634f1c357b73650f651.zip
Activate vcpus from bhyve(8) using the ioctl VM_ACTIVATE_CPU instead of doing
it implicitly in vmm.ko. Add ioctl VM_GET_CPUS to get the current set of 'active' and 'suspended' cpus and display them via /usr/sbin/bhyvectl using the "--get-active-cpus" and "--get-suspended-cpus" options. This is in preparation for being able to reset virtual machine state without having to destroy and recreate it.
Notes
Notes: svn path=/head/; revision=266933
Diffstat (limited to 'usr.sbin/bhyvectl')
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index ceee33a2aeeb..e77f0d77df6f 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -193,7 +193,9 @@ usage(void)
" [--assert-lapic-lvt=<pin>]\n"
" [--inject-nmi]\n"
" [--force-reset]\n"
- " [--force-poweroff]\n",
+ " [--force-poweroff]\n"
+ " [--get-active-cpus]\n"
+ " [--get-suspended-cpus]\n",
progname);
exit(1);
}
@@ -203,6 +205,7 @@ static int inject_nmi, assert_lapic_lvt;
static int force_reset, force_poweroff;
static const char *capname;
static int create, destroy, get_lowmem, get_highmem;
+static int get_active_cpus, get_suspended_cpus;
static uint64_t memsize;
static int set_cr0, get_cr0, set_cr3, get_cr3, set_cr4, get_cr4;
static int set_efer, get_efer;
@@ -390,6 +393,25 @@ enum {
ASSERT_LAPIC_LVT,
};
+static void
+print_cpus(const char *banner, const cpuset_t *cpus)
+{
+ int i, first;
+
+ first = 1;
+ printf("%s:\t", banner);
+ if (!CPU_EMPTY(cpus)) {
+ for (i = 0; i < CPU_SETSIZE; i++) {
+ if (CPU_ISSET(i, cpus)) {
+ printf("%s%d", first ? " " : ", ", i);
+ first = 0;
+ }
+ }
+ } else
+ printf(" (none)");
+ printf("\n");
+}
+
int
main(int argc, char *argv[])
{
@@ -401,6 +423,7 @@ main(int argc, char *argv[])
uint64_t ctl, eptp, bm, addr, u64, pteval[4], *pte;
struct vmctx *ctx;
int wired;
+ cpuset_t cpus;
uint64_t cr0, cr3, cr4, dr7, rsp, rip, rflags, efer, pat;
uint64_t rax, rbx, rcx, rdx, rsi, rdi, rbp;
@@ -570,6 +593,8 @@ main(int argc, char *argv[])
{ "inject-nmi", NO_ARG, &inject_nmi, 1 },
{ "force-reset", NO_ARG, &force_reset, 1 },
{ "force-poweroff", NO_ARG, &force_poweroff, 1 },
+ { "get-active-cpus", NO_ARG, &get_active_cpus, 1 },
+ { "get-suspended-cpus", NO_ARG, &get_suspended_cpus, 1 },
{ NULL, 0, NULL, 0 }
};
@@ -1529,6 +1554,18 @@ main(int argc, char *argv[])
}
}
+ if (!error && (get_active_cpus || get_all)) {
+ error = vm_active_cpus(ctx, &cpus);
+ if (!error)
+ print_cpus("active cpus", &cpus);
+ }
+
+ if (!error && (get_suspended_cpus || get_all)) {
+ error = vm_suspended_cpus(ctx, &cpus);
+ if (!error)
+ print_cpus("suspended cpus", &cpus);
+ }
+
if (!error && run) {
error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RIP, &rip);
assert(error == 0);