From nobody Thu Jan 26 18:54:16 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P2qcm5Wttz3bNxN; Thu, 26 Jan 2023 18:54:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P2qcm5358z45Zk; Thu, 26 Jan 2023 18:54:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674759256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ms9i2qHhxDRpuNryGtXMBugCyhKBuhSOa+AAGbGE4IE=; b=EdWRXWWoZihDZ0+o2BgdB4FH4wn0FReDFkWTbjNZI2r2Nf21VBjBNovUutLuJOZAcJ0K3/ aEH+BX9Zw9jtzOSlYsTwL5VusDa2+igIHtCY4Xpl+uDAEK5gBERFXy0Oq70K3pqzbzNmln 5g1kLP3Z/QMO9ay+D/3taPcHsFjQsufYdcxr3ZnQ81Q4fC408MKDUaCOPSPJRS84oiS/eS qQvMv3CMnc7Np0XdbK4bj+fU9FJ2RJ6fXsDb/AWkw/SoCs4dfFee2IWoU48eW1RxydgGC+ v0BvcO8vf5+Z695D6pFEkRCz4Xof1CHbCdHVdZz3Xk6kzvVbhuSF06r0W1yw+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674759256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ms9i2qHhxDRpuNryGtXMBugCyhKBuhSOa+AAGbGE4IE=; b=mY6ZCxiN+oBYRH/PSKlvTz7bWvUnCBvkrXmt7dGJTRtQbyR3tDQ5I9IGhIK6+fr8o+D73L +U/5DgFO/rOeg94++hUn8iAXOZJ5rGCODE9hzhSjXVEpT9h3Mjyf8vDtMfxRmFOG1KDWzD 2XBtAW0nTdZ7xv0IT5EelavCJuryu+5jpiXuXuquVgOL52LziRJ0odOQchnMIMrKhQix3K i3KAr4c9oESydynDNwwLHhb+4Xi7GKOx2u9IyHHJZRfHW7ebCfzsfU/s6PEBOBaiB+zUZt BusMsPNSzeN+CJMp1WPZfSYyvClBxjVEpx2G5NG1370PssoOypFRvMH8d21ukQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674759256; a=rsa-sha256; cv=none; b=HNgZiayFcmweMF4bTkYQLATpc/IyHNX7/MzWtd+W87GIMKAyhOrosq0lalaI2U6xQn9P3M S/wOw2rKC9Zyve1MT1X+xO0aHsoUDWfFUuCY7IC6NRp3azeSAFZu7Auob19JygKCHm4xAS 9//5lFAYrIH4SVK1+ndoGNRWk+inuIH3WTbqgrdU/1KWqoKdZhDvCJ3b8V4s0bUuxmHDyt vpTJqNF6MMJc6v98VLbWMwMo/5gBwnc6yrwrwXxMdtmbnHO+Act8+NDvekexV/w9fYVsH7 3CjYuuTyFonhwEFhvEp3/hAHq/HxYZIK183tKZjICEgBSgkvLlDCCkiJlJQ9Rg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P2qcm3hmVzgKt; Thu, 26 Jan 2023 18:54:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30QIsGk4033981; Thu, 26 Jan 2023 18:54:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QIsGht033980; Thu, 26 Jan 2023 18:54:16 GMT (envelope-from git) Date: Thu, 26 Jan 2023 18:54:16 GMT Message-Id: <202301261854.30QIsGht033980@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 89c376406b5b - stable/13 - bhyve/snapshot: drop mkdir when creating the unix domain socket List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 89c376406b5b993b85d76bc2f061c679129077d2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=89c376406b5b993b85d76bc2f061c679129077d2 commit 89c376406b5b993b85d76bc2f061c679129077d2 Author: Robert Wing AuthorDate: 2021-02-19 02:48:40 +0000 Commit: John Baldwin CommitDate: 2023-01-26 18:40:37 +0000 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 (cherry picked from commit 5ce2d4a1c2922821b9940473213c0d75469755fc) --- etc/mtree/BSD.var.dist | 2 ++ share/man/man7/hier.7 | 2 ++ usr.sbin/bhyve/snapshot.c | 32 ++------------------------------ usr.sbin/bhyve/snapshot.h | 1 + usr.sbin/bhyvectl/bhyvectl.c | 3 +-- 5 files changed, 8 insertions(+), 32 deletions(-) diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist index 6570d5324cd0..e1978f341408 100644 --- a/etc/mtree/BSD.var.dist +++ b/etc/mtree/BSD.var.dist @@ -76,6 +76,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 d87e91f8c4c5..00784986062a 100644 --- a/share/man/man7/hier.7 +++ b/share/man/man7/hier.7 @@ -718,6 +718,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 029c291a3cd1..2938a0e84c88 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 @@ -1505,26 +1503,6 @@ checkpoint_thread(void *param) return (NULL); } -/* - * 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 */ @@ -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 #include +#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 9613efdd0a88..6cf5db0ef42f 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) {