diff options
author | neel <neel@FreeBSD.org> | 2014-05-31 23:37:34 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2014-05-31 23:37:34 +0000 |
commit | 9c2a9423876303af6b7757283943735603cdacf7 (patch) | |
tree | 7c418a681bb97d7aaf33db6bbb701d15bf078026 /usr.sbin/bhyve | |
parent | 7f92c4861a4aba3ec77c8d72e941a081d86a2d1a (diff) | |
download | FreeBSD-src-9c2a9423876303af6b7757283943735603cdacf7.zip FreeBSD-src-9c2a9423876303af6b7757283943735603cdacf7.tar.gz |
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.
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r-- | usr.sbin/bhyve/bhyverun.c | 13 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_lpc.c | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index f9a67cb..1e5d3b3 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -242,6 +242,15 @@ fbsdrun_addcpu(struct vmctx *ctx, int fromcpu, int newcpu, uint64_t rip) assert(fromcpu == BSP); + /* + * The 'newcpu' must be activated in the context of 'fromcpu'. If + * vm_activate_cpu() is delayed until newcpu's pthread starts running + * then vmm.ko is out-of-sync with bhyve and this can create a race + * with vm_suspend(). + */ + error = vm_activate_cpu(ctx, newcpu); + assert(error == 0); + CPU_SET_ATOMIC(newcpu, &cpumask); /* @@ -532,6 +541,7 @@ vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) int error, rc, prevcpu; enum vm_exitcode exitcode; enum vm_suspend_how how; + cpuset_t active_cpus; if (vcpumap[vcpu] != NULL) { error = pthread_setaffinity_np(pthread_self(), @@ -539,6 +549,9 @@ vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) assert(error == 0); } + error = vm_active_cpus(ctx, &active_cpus); + assert(CPU_ISSET(vcpu, &active_cpus)); + while (1) { error = vm_run(ctx, vcpu, rip, &vmexit[vcpu]); if (error != 0) diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/pci_lpc.c index 6b61b7a..e98b141 100644 --- a/usr.sbin/bhyve/pci_lpc.c +++ b/usr.sbin/bhyve/pci_lpc.c @@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <machine/vmm.h> -#include <machine/vmm_dev.h> #include <stdio.h> #include <stdlib.h> |