git: c8ec366fd73e - stable/13 - bhyve: init checkput before caph_enter

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Fri, 17 Mar 2023 10:29:34 UTC
The branch stable/13 has been updated by corvink:

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

commit c8ec366fd73ecf80348e2a7b019d56aeac0a9f00
Author:     Vitaliy Gusev <gusev.vitaliy@gmail.com>
AuthorDate: 2023-03-06 12:35:21 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-03-17 10:26:35 +0000

    bhyve: init checkput before caph_enter
    
    init_checkpoint_thread binds to a socket. Bhyve isn't allowed to do that
    after caph_enter.
    
    Reviewed by:            corvink, markj
    MFC after:              1 week
    Sponsored by:           vStack
    Differential Revision:  https://reviews.freebsd.org/D38857
    
    (cherry picked from commit 9a9a248964696f45260ea026aa5f9174cc86b137)
---
 usr.sbin/bhyve/bhyverun.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index bf7b4856a2b4..702ef0e12690 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -1562,6 +1562,17 @@ main(int argc, char *argv[])
 	 */
 	setproctitle("%s", vmname);
 
+#ifdef BHYVE_SNAPSHOT
+	/* initialize mutex/cond variables */
+	init_snapshot();
+
+	/*
+	 * checkpointing thread for communication with bhyvectl
+	 */
+	if (init_checkpoint_thread(ctx) != 0)
+		errx(EX_OSERR, "Failed to start checkpoint thread");
+#endif
+
 #ifndef WITHOUT_CAPSICUM
 	caph_cache_catpages();
 
@@ -1573,15 +1584,6 @@ main(int argc, char *argv[])
 #endif
 
 #ifdef BHYVE_SNAPSHOT
-	/* initialize mutex/cond variables */
-	init_snapshot();
-
-	/*
-	 * checkpointing thread for communication with bhyvectl
-	 */
-	if (init_checkpoint_thread(ctx) != 0)
-		errx(EX_OSERR, "Failed to start checkpoint thread");
-
 	if (restore_file != NULL) {
 		destroy_restore_state(&rstate);
 		if (vm_restore_time(ctx) < 0)