From nobody Thu Apr 28 15:44:52 2022 X-Original-To: dev-commits-src-main@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 0F8F01AAEBC2; Thu, 28 Apr 2022 15:44:53 +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 4Kq0LD71lnz4ccX; Thu, 28 Apr 2022 15:44:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651160693; 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=woiqZI80nC2hdP8HpViO7ygjDaQKnTaXvdtzYvXedvk=; b=cpYkI/PJ8i5yDlG4PN4H91YYSv/hBqhKAbMS/OeU33sbX7NWxSXoc0zV5ZwXhYsClBoEwM jvBSRftdCvo8jQ3tMmNPKi/gBRexWKGZGxV7j3/dOie2CD89ZVLuMp4R28l8pgVr6q0rPZ 4QqYYfFUH+FFdhJabzsWyOVHEOL2aJgSTAJQzPmkB4rTsO0QYG6vXL5u7idhNh/puU/4zf P23+mklk6W+zi3glLfwmFtCZic1AN0lVk2U+ZeDzuX+u1J4E1tpOMzGDLPvU4mtcBJghTv QjLr3JupIHDiwBRyf3WLiNwwRFMTaAo9UwSQaHeBaAAqS1ubvLNOoGTD8KEpiA== 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 C6C821B149; Thu, 28 Apr 2022 15:44:52 +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 23SFiqAT095107; Thu, 28 Apr 2022 15:44:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23SFiqB6095106; Thu, 28 Apr 2022 15:44:52 GMT (envelope-from git) Date: Thu, 28 Apr 2022 15:44:52 GMT Message-Id: <202204281544.23SFiqB6095106@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: 690b7ea08179 - main - bhyve/snapshot: ..back to SOCK_STREAM List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org 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: 690b7ea081790eef2c890f63a4fe7e195cf51df0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651160693; 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=woiqZI80nC2hdP8HpViO7ygjDaQKnTaXvdtzYvXedvk=; b=YXuM4p0OX0V3aDdmjeIKsyTOSQ2WfKBkW7IxcVFXSWB4XvybajaqDY047XHIXPZGo39nm9 nyuznycMlTCMD1aJAwwxaq8C5nLh6dUd48XelxISI2RDINVfLXn96xQniN+2n3REoTkmAw VaeD/VofKn1FUgQypGhWV13icIcblbG4O1AFm11i35pZ2/ahFmJjigDboIZgyzRBJv7rtj WU2D2ilowAedB22O8+gtamJ5lpu/MKFfYUcjkB1tdlCgQj3AYVnZvu7xi8zz284EpNESW/ RMk3NP4R4QyKvXUn7ldEAQvR/okmKxoC2FneWllF+8+vJYbw3yfoFUIyGLlCbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651160693; a=rsa-sha256; cv=none; b=riXHXisIbUVlHDGDa62brj7bhZz6Q9aB7c7Fc8bAVTVWorg2A/ToPNeVjoXqrkpAzQ+VKD fpHMEFHnVyq0I42sHHvCELbE9GBZxGdg63CUXTr7+R+I506jhiVlQt6ZLBCYFduGnFZwl6 ABsmD8qsyrh+tSTILtesrxXM+SmVE630it7E9rM9zw7AkG/mGu5nCTIxxl8UOKxPnXXU6U 6WqrRhAWCCqCNGbR/DcOHrYX+l/zU15EaxdiD1LLGT9VzTwq7pPXoQEV/55q5UALhEXzF9 tp7JEG+QFJmXYlAjvNWOTmKQMkx/3YAg67alb24z2sUgg10DAWkzRjBIydSS0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=690b7ea081790eef2c890f63a4fe7e195cf51df0 commit 690b7ea081790eef2c890f63a4fe7e195cf51df0 Author: Robert Wing AuthorDate: 2022-04-28 15:43:01 +0000 Commit: Robert Wing CommitDate: 2022-04-28 15:43:01 +0000 bhyve/snapshot: ..back to SOCK_STREAM Now that nvlist_send()/nvlist_recv() are being used, ditch the datagram socket. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D34863 --- usr.sbin/bhyve/snapshot.c | 14 +++++++++++--- usr.sbin/bhyvectl/bhyvectl.c | 9 +++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index f17a3f2dd2df..37486ba368e3 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -1450,19 +1450,21 @@ handle_message(struct vmctx *ctx, nvlist_t *nvl) void * checkpoint_thread(void *param) { + int fd; struct checkpoint_thread_info *thread_info; nvlist_t *nvl; pthread_set_name_np(pthread_self(), "checkpoint thread"); thread_info = (struct checkpoint_thread_info *)param; - for (;;) { - nvl = nvlist_recv(thread_info->socket_fd, 0); + while ((fd = accept(thread_info->socket_fd, NULL, NULL)) != -1) { + nvl = nvlist_recv(fd, 0); if (nvl != NULL) handle_message(thread_info->ctx, nvl); else EPRINTLN("nvlist_recv() failed: %s", strerror(errno)); + close(fd); nvlist_destroy(nvl); } @@ -1515,7 +1517,7 @@ init_checkpoint_thread(struct vmctx *ctx) memset(&addr, 0, sizeof(addr)); - socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0); + socket_fd = socket(PF_UNIX, SOCK_STREAM, 0); if (socket_fd < 0) { EPRINTLN("Socket creation failed: %s", strerror(errno)); err = -1; @@ -1536,6 +1538,12 @@ init_checkpoint_thread(struct vmctx *ctx) goto fail; } + if (listen(socket_fd, 10) < 0) { + EPRINTLN("ipc socket listen: %s\n", strerror(errno)); + err = errno; + goto fail; + } + checkpoint_info = calloc(1, sizeof(*checkpoint_info)); checkpoint_info->ctx = ctx; checkpoint_info->socket_fd = socket_fd; diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index 06ab05cd48e1..14ab6c7ad33e 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -1687,7 +1687,7 @@ send_message(const char *vmname, nvlist_t *nvl) struct sockaddr_un addr; int err, socket_fd; - socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0); + socket_fd = socket(PF_UNIX, SOCK_STREAM, 0); if (socket_fd < 0) { perror("Error creating bhyvectl socket"); err = -1; @@ -1695,11 +1695,12 @@ send_message(const char *vmname, nvlist_t *nvl) } memset(&addr, 0, sizeof(struct sockaddr_un)); + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", + BHYVE_RUN_DIR, vmname); addr.sun_family = AF_UNIX; + addr.sun_len = SUN_LEN(&addr); - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", BHYVE_RUN_DIR, vmname); - - if (connect(socket_fd, (struct sockaddr *)&addr, SUN_LEN(&addr)) != 0) { + if (connect(socket_fd, (struct sockaddr *)&addr, addr.sun_len) != 0) { perror("connect() failed"); err = errno; goto done;