summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Biernacki <kaktus@FreeBSD.org>2020-06-25 12:35:20 +0000
committerPawel Biernacki <kaktus@FreeBSD.org>2020-06-25 12:35:20 +0000
commit0a1016f9e8a84edc8eb21e4f776b18b19fdd26ce (patch)
tree729d1e2babb6a9760ed514c5b6a023eb800b6b12
parenteb8a06388c53a8b26fd2264f50e5f9d302e04f23 (diff)
Notes
-rw-r--r--usr.sbin/bhyve/bhyve.86
-rw-r--r--usr.sbin/bhyve/bhyverun.c13
2 files changed, 14 insertions, 5 deletions
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index 5ecd33b703de..e92b39cc6825 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 18, 2020
+.Dd Jun 25, 2020
.Dt BHYVE 8
.Os
.Sh NAME
@@ -32,7 +32,7 @@
.Nd "run a guest operating system inside a virtual machine"
.Sh SYNOPSIS
.Nm
-.Op Fl AabCeHhPSuWwxY
+.Op Fl AabCDeHhPSuWwxY
.Oo
.Sm off
.Fl c\~
@@ -131,6 +131,8 @@ If a
is specified more than once the last one has precedence.
.It Fl C
Include guest memory in core file.
+.It Fl D
+Destroy the VM on guest initiated power-off.
.It Fl e
Force
.Nm
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 482c2501e36d..a2b8acdb752d 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -197,6 +197,7 @@ static int gdb_port = 0;
static int guest_vmexit_on_hlt, guest_vmexit_on_pause;
static int virtio_msix = 1;
static int x2apic_mode = 0; /* default is xAPIC */
+static int destroy_on_poweroff = 0;
static int strictio;
static int strictmsr = 1;
@@ -236,7 +237,7 @@ usage(int code)
{
fprintf(stderr,
- "Usage: %s [-abehuwxACHPSWY]\n"
+ "Usage: %s [-abehuwxACDHPSWY]\n"
" %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n"
" %*s [-g <gdb port>] [-l <lpc>]\n"
" %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n"
@@ -244,6 +245,7 @@ usage(int code)
" -A: create ACPI tables\n"
" -c: number of cpus and/or topology specification\n"
" -C: include guest memory in core file\n"
+ " -D: destroy on power-off\n"
" -e: exit on unhandled I/O access\n"
" -g: gdb port\n"
" -h: help\n"
@@ -815,6 +817,8 @@ vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
case VM_SUSPEND_RESET:
exit(0);
case VM_SUSPEND_POWEROFF:
+ if (destroy_on_poweroff)
+ vm_destroy(ctx);
exit(1);
case VM_SUSPEND_HALT:
exit(2);
@@ -1101,9 +1105,9 @@ main(int argc, char *argv[])
memflags = 0;
#ifdef BHYVE_SNAPSHOT
- optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:U:r:";
+ optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:r:";
#else
- optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:U:";
+ optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:";
#endif
while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) {
@@ -1116,6 +1120,9 @@ main(int argc, char *argv[])
case 'b':
bvmcons = 1;
break;
+ case 'D':
+ destroy_on_poweroff = 1;
+ break;
case 'p':
if (pincpu_parse(optarg) != 0) {
errx(EX_USAGE, "invalid vcpu pinning "