git: 4fc5b31e2f31 - stable/13 - libvmm: clean up vmmapi.h

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 26 Jan 2023 18:54:15 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4fc5b31e2f31fcc30788c27532ca8dfff987d7bc

commit 4fc5b31e2f31fcc30788c27532ca8dfff987d7bc
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2021-01-29 08:30:31 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-01-26 18:37:19 +0000

    libvmm: clean up vmmapi.h
    
    struct checkpoint_op, enum checkpoint_opcodes, and
    MAX_SNAPSHOT_VMNAME are not vmm specific, move them out of the vmmapi
    header.
    
    They are used for the save/restore functionality that bhyve(8)
    provides and are better suited in usr.sbin/bhyve/snapshot.h
    
    Since bhyvectl(8) requires these, the Makefile for bhyvectl has been
    modified to include usr.sbin/bhyve/snapshot.h
    
    Reviewed by:    kevans, grehan
    Differential Revision:  https://reviews.freebsd.org/D28410
    
    (cherry picked from commit 4f4065e0a220a57afa03420d4f8fa97dbcb5644c)
---
 lib/libvmmapi/vmmapi.h       | 13 -------------
 usr.sbin/bhyve/snapshot.h    | 12 ++++++++++++
 usr.sbin/bhyvectl/Makefile   |  4 ++++
 usr.sbin/bhyvectl/bhyvectl.c |  4 ++++
 4 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 064875f26818..586392a0ff29 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -260,19 +260,6 @@ void	vm_setup_freebsd_gdt(uint64_t *gdtr);
 /*
  * Save and restore
  */
-
-#define MAX_SNAPSHOT_VMNAME 100
-
-enum checkpoint_opcodes {
-	START_CHECKPOINT = 0,
-	START_SUSPEND = 1,
-};
-
-struct checkpoint_op {
-	unsigned int op;
-	char snapshot_filename[MAX_SNAPSHOT_VMNAME];
-};
-
 int	vm_snapshot_req(struct vm_snapshot_meta *meta);
 int	vm_restore_time(struct vmctx *ctx);
 
diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h
index f9ea3d573089..eba46c497ab2 100644
--- a/usr.sbin/bhyve/snapshot.h
+++ b/usr.sbin/bhyve/snapshot.h
@@ -42,6 +42,8 @@
 #include <libxo/xo.h>
 #include <ucl.h>
 
+#define MAX_SNAPSHOT_VMNAME 100
+
 struct vmctx;
 
 struct restore_state {
@@ -57,6 +59,16 @@ struct restore_state {
 	ucl_object_t *meta_root_obj;
 };
 
+enum checkpoint_opcodes {
+	START_CHECKPOINT = 0,
+	START_SUSPEND = 1,
+};
+
+struct checkpoint_op {
+	unsigned int op;
+	char snapshot_filename[MAX_SNAPSHOT_VMNAME];
+};
+
 struct checkpoint_thread_info {
 	struct vmctx *ctx;
 	int socket_fd;
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index 58eaf49dae3a..12fdb706cadb 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -18,6 +18,10 @@ CFLAGS+= -I${SRCTOP}/sys/amd64/vmm
 
 .if ${MK_BHYVE_SNAPSHOT} != "no"
 CFLAGS+= -DBHYVE_SNAPSHOT
+
+# usr.sbin/bhyve/snapshot.h needs ucl header
+CFLAGS+= -I${SRCTOP}/contrib/libucl/include
+CFLAGS+= -I${SRCTOP}/usr.sbin/bhyve
 .endif
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 1b882e1e0504..9613efdd0a88 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -63,6 +63,10 @@ __FBSDID("$FreeBSD$");
 #include "amd/vmcb.h"
 #include "intel/vmcs.h"
 
+#ifdef BHYVE_SNAPSHOT
+#include "snapshot.h"
+#endif
+
 #define	MB	(1UL << 20)
 #define	GB	(1UL << 30)