diff options
author | neel <neel@FreeBSD.org> | 2014-05-02 00:33:56 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2014-05-02 00:33:56 +0000 |
commit | b735ae5b9adff0d10136045496841e43c66321d8 (patch) | |
tree | c9e34c0b9f63561e459eb852037551ba78022645 /usr.sbin | |
parent | 19952369c8b5e849c3ff139fe19892c47382f9bc (diff) | |
download | FreeBSD-src-b735ae5b9adff0d10136045496841e43c66321d8.zip FreeBSD-src-b735ae5b9adff0d10136045496841e43c66321d8.tar.gz |
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.
Tested by executing "halt" inside a RHEL7-beta guest.
Discussed with: grehan@
Reviewed by: jhb@, tychon@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/bhyverun.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 5c38601..b54e714 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -453,7 +453,6 @@ vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) enum vm_suspend_how how; how = vmexit->u.suspended.how; - assert(how == VM_SUSPEND_RESET || how == VM_SUSPEND_POWEROFF); fbsdrun_deletecpu(ctx, *pvcpu); @@ -470,10 +469,17 @@ vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) } pthread_mutex_unlock(&resetcpu_mtx); - if (how == VM_SUSPEND_RESET) + switch (how) { + case VM_SUSPEND_RESET: exit(0); - if (how == VM_SUSPEND_POWEROFF) + case VM_SUSPEND_POWEROFF: exit(1); + case VM_SUSPEND_HALT: + exit(2); + default: + fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how); + exit(100); + } return (0); /* NOTREACHED */ } |