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
This commit is contained in:
Robert Wing 2022-04-28 07:43:01 -08:00
parent 25768526bb
commit 690b7ea081
2 changed files with 16 additions and 7 deletions

View File

@ -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;

View File

@ -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;