summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi/vmmapi.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2014-07-21 02:39:17 +0000
committerjhb <jhb@FreeBSD.org>2014-07-21 02:39:17 +0000
commit888f6511e321556007cf471f691cb84d9a817237 (patch)
tree84ace0524c020288c47a07096fb6abcb1d3387d4 /lib/libvmmapi/vmmapi.c
parentd034cf40e56b09120dc35d432b7fdc536c54f6ec (diff)
downloadFreeBSD-src-888f6511e321556007cf471f691cb84d9a817237.zip
FreeBSD-src-888f6511e321556007cf471f691cb84d9a817237.tar.gz
MFC 263780,264516,265062,265101,265203,265364:
Add an ioctl to suspend a virtual machine (VM_SUSPEND). Add logic in the HLT exit handler to detect if the guest has put all vcpus to sleep permanently by executing a HLT with interrupts disabled. When this condition is detected the guest with be suspended with a reason of VM_SUSPEND_HALT and the bhyve(8) process will exit. This logic can be disabled via the tunable 'hw.vmm.halt_detection'.
Diffstat (limited to 'lib/libvmmapi/vmmapi.c')
-rw-r--r--lib/libvmmapi/vmmapi.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 22b536a..4a7f852 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -342,6 +342,16 @@ vm_run(struct vmctx *ctx, int vcpu, uint64_t rip, struct vm_exit *vmexit)
return (error);
}
+int
+vm_suspend(struct vmctx *ctx, enum vm_suspend_how how)
+{
+ struct vm_suspend vmsuspend;
+
+ bzero(&vmsuspend, sizeof(vmsuspend));
+ vmsuspend.how = how;
+ return (ioctl(ctx->fd, VM_SUSPEND, &vmsuspend));
+}
+
static int
vm_inject_exception_real(struct vmctx *ctx, int vcpu, int vector,
int error_code, int error_code_valid)
OpenPOWER on IntegriCloud