summaryrefslogtreecommitdiffstats
path: root/sys/amd64/vmm/vmm.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-05-31 23:37:34 +0000
committerneel <neel@FreeBSD.org>2014-05-31 23:37:34 +0000
commit9c2a9423876303af6b7757283943735603cdacf7 (patch)
tree7c418a681bb97d7aaf33db6bbb701d15bf078026 /sys/amd64/vmm/vmm.c
parent7f92c4861a4aba3ec77c8d72e941a081d86a2d1a (diff)
downloadFreeBSD-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 'sys/amd64/vmm/vmm.c')
-rw-r--r--sys/amd64/vmm/vmm.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index 8ebdfd7..e84359d 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -342,8 +342,6 @@ vm_create(const char *name, struct vm **retvm)
struct vm *vm;
struct vmspace *vmspace;
- const int BSP = 0;
-
/*
* If vmm.ko could not be successfully initialized then don't attempt
* to create the virtual machine.
@@ -373,8 +371,6 @@ vm_create(const char *name, struct vm **retvm)
guest_msrs_init(vm, i);
}
- vm_activate_cpu(vm, BSP);
-
*retvm = vm;
return (0);
}
@@ -1294,6 +1290,12 @@ vm_run(struct vm *vm, struct vm_run *vmrun)
if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
return (EINVAL);
+ if (!CPU_ISSET(vcpuid, &vm->active_cpus))
+ return (EINVAL);
+
+ if (CPU_ISSET(vcpuid, &vm->suspended_cpus))
+ return (EINVAL);
+
rptr = &vm->rendezvous_func;
sptr = &vm->suspend;
pmap = vmspace_pmap(vm->vmspace);
@@ -1708,17 +1710,19 @@ vcpu_get_state(struct vm *vm, int vcpuid, int *hostcpu)
return (state);
}
-void
+int
vm_activate_cpu(struct vm *vm, int vcpuid)
{
- KASSERT(vcpuid >= 0 && vcpuid < VM_MAXCPU,
- ("vm_activate_cpu: invalid vcpuid %d", vcpuid));
- KASSERT(!CPU_ISSET(vcpuid, &vm->active_cpus),
- ("vm_activate_cpu: vcpuid %d is already active", vcpuid));
+ if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
+ return (EINVAL);
+
+ if (CPU_ISSET(vcpuid, &vm->active_cpus))
+ return (EBUSY);
VCPU_CTR0(vm, vcpuid, "activated");
CPU_SET_ATOMIC(vcpuid, &vm->active_cpus);
+ return (0);
}
cpuset_t
@@ -1728,6 +1732,13 @@ vm_active_cpus(struct vm *vm)
return (vm->active_cpus);
}
+cpuset_t
+vm_suspended_cpus(struct vm *vm)
+{
+
+ return (vm->suspended_cpus);
+}
+
void *
vcpu_stats(struct vm *vm, int vcpuid)
{
OpenPOWER on IntegriCloud