Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jul 2020 20:55:18 +0000 (UTC)
From:      Pawel Biernacki <kaktus@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r363059 - stable/11/usr.sbin/bhyve
Message-ID:  <202007092055.069KtIP2047388@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kaktus
Date: Thu Jul  9 20:55:18 2020
New Revision: 363059
URL: https://svnweb.freebsd.org/changeset/base/363059

Log:
  MFC r362612
  
  bhyve: allow for automatic destruction on power-off

Modified:
  stable/11/usr.sbin/bhyve/bhyve.8
  stable/11/usr.sbin/bhyve/bhyverun.c

Modified: stable/11/usr.sbin/bhyve/bhyve.8
==============================================================================
--- stable/11/usr.sbin/bhyve/bhyve.8	Thu Jul  9 20:54:16 2020	(r363058)
+++ stable/11/usr.sbin/bhyve/bhyve.8	Thu Jul  9 20:55:18 2020	(r363059)
@@ -112,6 +112,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

Modified: stable/11/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- stable/11/usr.sbin/bhyve/bhyverun.c	Thu Jul  9 20:54:16 2020	(r363058)
+++ stable/11/usr.sbin/bhyve/bhyverun.c	Thu Jul  9 20:55:18 2020	(r363059)
@@ -171,6 +171,7 @@ char *guest_uuid_str;
 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;
@@ -210,7 +211,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"
@@ -218,6 +219,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"
@@ -788,6 +790,8 @@ vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmex
 	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);
@@ -1021,7 +1025,7 @@ main(int argc, char *argv[])
 	rtc_localtime = 1;
 	memflags = 0;
 
-	optstr = "abehuwxACHIPSWYp:g:c:s:m:l:U:";
+	optstr = "abehuwxACDHIPSWYp:g:c:s:m:l:U:";
 	while ((c = getopt(argc, argv, optstr)) != -1) {
 		switch (c) {
 		case 'a':
@@ -1032,6 +1036,9 @@ main(int argc, char *argv[])
 			break;
 		case 'b':
 			bvmcons = 1;
+			break;
+		case 'D':
+			destroy_on_poweroff = 1;
 			break;
 		case 'p':
                         if (pincpu_parse(optarg) != 0) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007092055.069KtIP2047388>