From owner-dev-commits-src-all@freebsd.org Fri May 21 19:40:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE07063A4FA; Fri, 21 May 2021 19:40:27 +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 4Fmxlv5VpGz4g8l; Fri, 21 May 2021 19:40:27 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 966961731C; Fri, 21 May 2021 19:40:27 +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 14LJeRqP091575; Fri, 21 May 2021 19:40:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LJeRaL091574; Fri, 21 May 2021 19:40:27 GMT (envelope-from git) Date: Fri, 21 May 2021 19:40:27 GMT Message-Id: <202105211940.14LJeRaL091574@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: fdbc86cf7978 - main - bhyve/snapshot: split up mutex/cond initialization from socket creation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fdbc86cf79784f56fab8115f2d565962e1111b2e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 19:40:27 -0000 The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=fdbc86cf79784f56fab8115f2d565962e1111b2e commit fdbc86cf79784f56fab8115f2d565962e1111b2e Author: Robert Wing AuthorDate: 2021-05-15 19:58:21 +0000 Commit: Robert Wing CommitDate: 2021-05-21 19:23:06 +0000 bhyve/snapshot: split up mutex/cond initialization from socket creation Move initialization of the mutex/condition variables required by the save/restore feature to their own function. The unix domain socket that facilitates communication between bhyvectl and bhyve doesn't rely on these variables in order to be functional. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D30281 --- usr.sbin/bhyve/bhyverun.c | 3 +++ usr.sbin/bhyve/snapshot.c | 25 ++++++++++++++++--------- usr.sbin/bhyve/snapshot.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index d14219bbef65..acf0df6cc9bf 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -1540,6 +1540,9 @@ main(int argc, char *argv[]) if (restore_file != NULL) destroy_restore_state(&rstate); + /* initialize mutex/cond variables */ + init_snapshot(); + /* * checkpointing thread for communication with bhyvectl */ diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 019f4fdd6cb0..1a06c3e8d065 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -1493,6 +1493,22 @@ checkpoint_thread(void *param) return (NULL); } +void +init_snapshot(void) +{ + int err; + + err = pthread_mutex_init(&vcpu_lock, NULL); + if (err != 0) + errc(1, err, "checkpoint mutex init"); + err = pthread_cond_init(&vcpus_idle, NULL); + if (err != 0) + errc(1, err, "checkpoint cv init (vcpus_idle)"); + err = pthread_cond_init(&vcpus_can_run, NULL); + if (err != 0) + errc(1, err, "checkpoint cv init (vcpus_can_run)"); +} + /* * Create the listening socket for IPC with bhyvectl */ @@ -1508,15 +1524,6 @@ init_checkpoint_thread(struct vmctx *ctx) memset(&addr, 0, sizeof(addr)); - err = pthread_mutex_init(&vcpu_lock, NULL); - if (err != 0) - errc(1, err, "checkpoint mutex init"); - err = pthread_cond_init(&vcpus_idle, NULL); - if (err == 0) - err = pthread_cond_init(&vcpus_can_run, NULL); - if (err != 0) - errc(1, err, "checkpoint cv init"); - socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0); if (socket_fd < 0) { EPRINTLN("Socket creation failed: %s", strerror(errno)); diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h index f28b56cf0a7f..3ffd42fbeabc 100644 --- a/usr.sbin/bhyve/snapshot.h +++ b/usr.sbin/bhyve/snapshot.h @@ -127,6 +127,7 @@ int vm_resume_user_devs(struct vmctx *ctx); int get_checkpoint_msg(int conn_fd, struct vmctx *ctx); void *checkpoint_thread(void *param); int init_checkpoint_thread(struct vmctx *ctx); +void init_snapshot(void); int load_restore_file(const char *filename, struct restore_state *rstate);