aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Wing <rew@FreeBSD.org>2021-02-19 02:48:40 +0000
committerRobert Wing <rew@FreeBSD.org>2021-02-22 20:31:07 +0000
commit5ce2d4a1c2922821b9940473213c0d75469755fc (patch)
treef9f76609c34dc5d58b1d148dbb702768375d19a3
parent811e27fa3c445664e36071a7d08228fc7fb85676 (diff)
downloadsrc-5ce2d4a1c2922821b9940473213c0d75469755fc.tar.gz
src-5ce2d4a1c2922821b9940473213c0d75469755fc.zip
bhyve/snapshot: drop mkdir when creating the unix domain socket
Add /var/run/bhyve/ to BSD.var.dist so we don't have to call mkdir when creating the unix domain socket for a given bhyve vm. The path to the unix domain socket for a bhyve vm will now be /var/run/bhyve/vmname instead of /var/run/bhyve/checkpoint/vmname Move BHYVE_RUN_DIR from snapshot.c to snapshot.h so it can be shared to bhyvectl(8). Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D28783
-rw-r--r--etc/mtree/BSD.var.dist2
-rw-r--r--share/man/man7/hier.74
-rw-r--r--usr.sbin/bhyve/snapshot.c32
-rw-r--r--usr.sbin/bhyve/snapshot.h1
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c3
5 files changed, 9 insertions, 33 deletions
diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist
index 6483df4a297d..f0d6f8694449 100644
--- a/etc/mtree/BSD.var.dist
+++ b/etc/mtree/BSD.var.dist
@@ -74,6 +74,8 @@
preserve
..
run
+ bhyve
+ ..
dhclient
..
ppp gname=network mode=0770
diff --git a/share/man/man7/hier.7 b/share/man/man7/hier.7
index 845c4a8a8f7c..d134e84f4c48 100644
--- a/share/man/man7/hier.7
+++ b/share/man/man7/hier.7
@@ -28,7 +28,7 @@
.\" @(#)hier.7 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
-.Dd January 9, 2021
+.Dd February 22, 2021
.Dt HIER 7
.Os
.Sh NAME
@@ -832,6 +832,8 @@ system information files describing various info about
system since it was booted
.Pp
.Bl -tag -width Fl -compact
+.It Pa bhyve/
+bhyve vm unix domain sockets
.It Pa ppp/
writable by the
.Dq network
diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c
index 4ffdb315883c..11ff963ae1fd 100644
--- a/usr.sbin/bhyve/snapshot.c
+++ b/usr.sbin/bhyve/snapshot.c
@@ -115,8 +115,6 @@ static sig_t old_winch_handler;
#define SNAPSHOT_CHUNK (4 * MB)
#define PROG_BUF_SZ (8192)
-#define BHYVE_RUN_DIR "/var/run/bhyve"
-#define CHECKPOINT_RUN_DIR BHYVE_RUN_DIR "/checkpoint"
#define MAX_VMNAME 100
#define MAX_MSG_SIZE 1024
@@ -1506,26 +1504,6 @@ checkpoint_thread(void *param)
}
/*
- * Create directory tree to store runtime specific information:
- * i.e. UNIX sockets for IPC with bhyvectl.
- */
-static int
-make_checkpoint_dir(void)
-{
- int err;
-
- err = mkdir(BHYVE_RUN_DIR, 0755);
- if (err < 0 && errno != EEXIST)
- return (err);
-
- err = mkdir(CHECKPOINT_RUN_DIR, 0755);
- if (err < 0 && errno != EEXIST)
- return (err);
-
- return 0;
-}
-
-/*
* Create the listening socket for IPC with bhyvectl
*/
int
@@ -1556,12 +1534,6 @@ init_checkpoint_thread(struct vmctx *ctx)
goto fail;
}
- err = make_checkpoint_dir();
- if (err < 0) {
- perror("Failed to create checkpoint runtime directory");
- goto fail;
- }
-
addr.sun_family = AF_UNIX;
err = vm_get_name(ctx, vmname_buf, MAX_VMNAME - 1);
@@ -1570,8 +1542,8 @@ init_checkpoint_thread(struct vmctx *ctx)
goto fail;
}
- snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s",
- CHECKPOINT_RUN_DIR, vmname_buf);
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s",
+ BHYVE_RUN_DIR, vmname_buf);
addr.sun_len = SUN_LEN(&addr);
unlink(addr.sun_path);
diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h
index eba46c497ab2..caa7256ffbfa 100644
--- a/usr.sbin/bhyve/snapshot.h
+++ b/usr.sbin/bhyve/snapshot.h
@@ -42,6 +42,7 @@
#include <libxo/xo.h>
#include <ucl.h>
+#define BHYVE_RUN_DIR "/var/run/bhyve/"
#define MAX_SNAPSHOT_VMNAME 100
struct vmctx;
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index b404f9f3c255..7b3a73cc3668 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$");
#define NO_ARG no_argument
#define OPT_ARG optional_argument
-#define CHECKPOINT_RUN_DIR "/var/run/bhyve/checkpoint"
#define MAX_VMNAME 100
static const char *progname;
@@ -1708,7 +1707,7 @@ send_checkpoint_op_req(struct vmctx *ctx, struct checkpoint_op *op)
goto done;
}
- snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s", CHECKPOINT_RUN_DIR, vmname_buf);
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", BHYVE_RUN_DIR, vmname_buf);
if (connect(socket_fd, (struct sockaddr *)&addr,
sizeof(struct sockaddr_un)) != 0) {