summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-03-26 23:34:27 +0000
committerneel <neel@FreeBSD.org>2014-03-26 23:34:27 +0000
commit3e49998fdfce1f7d28cbd813dab17114caeb6392 (patch)
tree26d2d3b3da3f94b1b7988cb043cec70d34999f99 /lib/libvmmapi
parent0b79334339fb4e8a621ab2cb4ed45bb729778613 (diff)
downloadFreeBSD-src-3e49998fdfce1f7d28cbd813dab17114caeb6392.zip
FreeBSD-src-3e49998fdfce1f7d28cbd813dab17114caeb6392.tar.gz
Add an ioctl to suspend a virtual machine (VM_SUSPEND). The ioctl can be called
from any context i.e., it is not required to be called from a vcpu thread. The ioctl simply sets a state variable 'vm->suspend' to '1' and returns. The vcpus inspect 'vm->suspend' in the run loop and if it is set to '1' the vcpu breaks out of the loop with a reason of 'VM_EXITCODE_SUSPENDED'. The suspend handler waits until all 'vm->active_cpus' have transitioned to 'vm->suspended_cpus' before returning to userspace. Discussed with: grehan
Diffstat (limited to 'lib/libvmmapi')
-rw-r--r--lib/libvmmapi/vmmapi.c7
-rw-r--r--lib/libvmmapi/vmmapi.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 22b536a..60d3105 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -342,6 +342,13 @@ vm_run(struct vmctx *ctx, int vcpu, uint64_t rip, struct vm_exit *vmexit)
return (error);
}
+int
+vm_suspend(struct vmctx *ctx)
+{
+
+ return (ioctl(ctx->fd, VM_SUSPEND, 0));
+}
+
static int
vm_inject_exception_real(struct vmctx *ctx, int vcpu, int vector,
int error_code, int error_code_valid)
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 085af94..ce150d8 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -61,6 +61,7 @@ int vm_set_register(struct vmctx *ctx, int vcpu, int reg, uint64_t val);
int vm_get_register(struct vmctx *ctx, int vcpu, int reg, uint64_t *retval);
int vm_run(struct vmctx *ctx, int vcpu, uint64_t rip,
struct vm_exit *ret_vmexit);
+int vm_suspend(struct vmctx *ctx);
int vm_apicid2vcpu(struct vmctx *ctx, int apicid);
int vm_inject_exception(struct vmctx *ctx, int vcpu, int vec);
int vm_inject_exception2(struct vmctx *ctx, int vcpu, int vec, int errcode);
OpenPOWER on IntegriCloud