git: 390e44988aea - main - bhyve: Fix handling of -r

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 29 Apr 2024 14:18:13 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=390e44988aeaa824a9ea4f0e352f9a252093c170

commit 390e44988aeaa824a9ea4f0e352f9a252093c170
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-04-29 14:13:50 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-04-29 14:13:50 +0000

    bhyve: Fix handling of -r
    
    Just make "restore_file" a global variable so that it can be set by the
    MD option handler.
    
    Reviewed by:    corvink
    Reported by:    bdrewery
    Fixes:          981f9f7495bb ("bhyve: Push option parsing down into bhyverun_machdep.c")
    Differential Revision:  https://reviews.freebsd.org/D44974
---
 usr.sbin/bhyve/bhyverun.c | 7 ++++---
 usr.sbin/bhyve/bhyverun.h | 4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 1c3b810efb02..d199c32cc54b 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -100,6 +100,10 @@ uint16_t cpu_cores, cpu_sockets, cpu_threads;
 
 int raw_stdio = 0;
 
+#ifdef BHYVE_SNAPSHOT
+char *restore_file;
+#endif
+
 static const int BSP = 0;
 
 static cpuset_t cpumask;
@@ -656,10 +660,7 @@ main(int argc, char *argv[])
 	size_t memsize;
 	const char *value, *vmname;
 #ifdef BHYVE_SNAPSHOT
-	char *restore_file;
 	struct restore_state rstate;
-
-	restore_file = NULL;
 #endif
 
 	bhyve_init_config();
diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h
index e6ff90e5daa0..005de6dc5410 100644
--- a/usr.sbin/bhyve/bhyverun.h
+++ b/usr.sbin/bhyve/bhyverun.h
@@ -37,6 +37,10 @@
 extern int guest_ncpus;
 extern uint16_t cpu_cores, cpu_sockets, cpu_threads;
 
+#ifdef BHYVE_SNAPSHOT
+extern char *restore_file;
+#endif
+
 struct vcpu;
 struct vmctx;
 struct vm_run;