From owner-dev-commits-src-main@freebsd.org Thu May 13 04:39:49 2021 Return-Path: Delivered-To: dev-commits-src-main@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 74900630E9B; Thu, 13 May 2021 04:39:49 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fgf8P18Cbz4RNR; Thu, 13 May 2021 04:39:48 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 14D4dfTQ074721; Wed, 12 May 2021 21:39:41 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 14D4dfZ2074720; Wed, 12 May 2021 21:39:41 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202105130439.14D4dfZ2074720@gndrsh.dnsmgr.net> Subject: Re: git: d4870e3a7256 - main - bhyve/snapshot: provide a way to send other messages/data to bhyve In-Reply-To: To: Rob Wing Date: Wed, 12 May 2021 21:39:41 -0700 (PDT) CC: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4Fgf8P18Cbz4RNR X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 04:39:49 -0000 > shoot, I messed up - the differential revision is > https://reviews.freebsd.org/D29213 And it is going to take more than a comment here and remove a couple of subscribers to "undo" this mistake. If you go open https://reviews.freebsd.org/D30211 now you well see that this committed diff is what shows up in the review, and what you get if you try to download the rawdiff. I do not know how to clean this up, but the simple action of making a comment on the mailling list to "fix" these types of mistakes is leaving a lot of cruft around that can be very hard to sort out at a later date, especially since the "fix" is pretty much invisible to all the tools. > > On Wed, May 12, 2021 at 5:33 PM Robert Wing wrote: > > > The branch main has been updated by rew: > > > > URL: > > https://cgit.FreeBSD.org/src/commit/?id=d4870e3a7256704905655e997b37a866024c2894 > > > > commit d4870e3a7256704905655e997b37a866024c2894 > > Author: Robert Wing > > AuthorDate: 2021-03-03 06:05:47 +0000 > > Commit: Robert Wing > > CommitDate: 2021-05-13 01:20:15 +0000 > > > > bhyve/snapshot: provide a way to send other messages/data to bhyve > > > > This is a step towards sending messages (other than suspend/checkpoint) > > from bhyvectl to bhyve. > > > > Introduce a new struct, ipc_message - this struct stores the type of > > message and a union containing message specific structures for the type > > of message being sent. > > > > Reviewed by: grehan > > Differential Revision: https://reviews.freebsd.org/D30221 > > --- > > usr.sbin/bhyve/snapshot.c | 16 ++++++++-------- > > usr.sbin/bhyve/snapshot.h | 21 ++++++++++++++++++--- > > usr.sbin/bhyvectl/bhyvectl.c | 15 +++++++++------ > > 3 files changed, 35 insertions(+), 17 deletions(-) > > > > diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c > > index 221558b6f205..019f4fdd6cb0 100644 > > --- a/usr.sbin/bhyve/snapshot.c > > +++ b/usr.sbin/bhyve/snapshot.c > > @@ -1441,16 +1441,16 @@ done: > > } > > > > int > > -handle_message(struct checkpoint_op *checkpoint_op, struct vmctx *ctx) > > +handle_message(struct ipc_message *imsg, struct vmctx *ctx) > > { > > int err; > > > > - switch (checkpoint_op->op) { > > + switch (imsg->code) { > > case START_CHECKPOINT: > > - err = vm_checkpoint(ctx, > > checkpoint_op->snapshot_filename, false); > > + err = vm_checkpoint(ctx, > > imsg->data.op.snapshot_filename, false); > > break; > > case START_SUSPEND: > > - err = vm_checkpoint(ctx, > > checkpoint_op->snapshot_filename, true); > > + err = vm_checkpoint(ctx, > > imsg->data.op.snapshot_filename, true); > > break; > > default: > > EPRINTLN("Unrecognized checkpoint operation\n"); > > @@ -1469,7 +1469,7 @@ handle_message(struct checkpoint_op *checkpoint_op, > > struct vmctx *ctx) > > void * > > checkpoint_thread(void *param) > > { > > - struct checkpoint_op op; > > + struct ipc_message imsg; > > struct checkpoint_thread_info *thread_info; > > ssize_t n; > > > > @@ -1477,14 +1477,14 @@ checkpoint_thread(void *param) > > thread_info = (struct checkpoint_thread_info *)param; > > > > for (;;) { > > - n = recvfrom(thread_info->socket_fd, &op, sizeof(op), 0, > > NULL, 0); > > + n = recvfrom(thread_info->socket_fd, &imsg, sizeof(imsg), > > 0, NULL, 0); > > > > /* > > * slight sanity check: see if there's enough data to at > > * least determine the type of message. > > */ > > - if (n >= sizeof(op.op)) > > - handle_message(&op, thread_info->ctx); > > + if (n >= sizeof(imsg.code)) > > + handle_message(&imsg, thread_info->ctx); > > else > > EPRINTLN("Failed to receive message: %s\n", > > n == -1 ? strerror(errno) : "unknown error"); > > diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h > > index 8a6ee67ef19d..f28b56cf0a7f 100644 > > --- a/usr.sbin/bhyve/snapshot.h > > +++ b/usr.sbin/bhyve/snapshot.h > > @@ -60,14 +60,29 @@ struct restore_state { > > ucl_object_t *meta_root_obj; > > }; > > > > +/* Filename that will be used for save/restore */ > > +struct checkpoint_op { > > + char snapshot_filename[MAX_SNAPSHOT_FILENAME]; > > +}; > > + > > +/* Messages that a bhyve process understands. */ > > enum ipc_opcode { > > START_CHECKPOINT, > > START_SUSPEND, > > }; > > > > -struct checkpoint_op { > > - unsigned int op; > > - char snapshot_filename[MAX_SNAPSHOT_FILENAME]; > > +/* > > + * The type of message and associated data to > > + * send to a bhyve process. > > + */ > > +struct ipc_message { > > + enum ipc_opcode code; > > + union { > > + /* > > + * message specific structures > > + */ > > + struct checkpoint_op op; > > + } data; > > }; > > > > struct checkpoint_thread_info { > > diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c > > index df02f7caf345..017427db4d4f 100644 > > --- a/usr.sbin/bhyvectl/bhyvectl.c > > +++ b/usr.sbin/bhyvectl/bhyvectl.c > > @@ -1684,7 +1684,7 @@ show_memseg(struct vmctx *ctx) > > > > #ifdef BHYVE_SNAPSHOT > > static int > > -send_checkpoint_op_req(struct vmctx *ctx, struct checkpoint_op *op) > > +send_message(struct vmctx *ctx, void *data, size_t len) > > { > > struct sockaddr_un addr; > > ssize_t len_sent; > > @@ -1709,7 +1709,7 @@ send_checkpoint_op_req(struct vmctx *ctx, struct > > checkpoint_op *op) > > > > snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", > > BHYVE_RUN_DIR, vmname_buf); > > > > - len_sent = sendto(socket_fd, op, sizeof(*op), 0, > > + len_sent = sendto(socket_fd, data, len, 0, > > (struct sockaddr *)&addr, sizeof(struct sockaddr_un)); > > > > if (len_sent < 0) { > > @@ -1726,12 +1726,15 @@ done: > > static int > > snapshot_request(struct vmctx *ctx, const char *file, enum ipc_opcode > > code) > > { > > - struct checkpoint_op op; > > + struct ipc_message imsg; > > + size_t length; > > > > - op.op = code; > > - strlcpy(op.snapshot_filename, file, MAX_SNAPSHOT_FILENAME); > > + imsg.code = code; > > + strlcpy(imsg.data.op.snapshot_filename, file, > > MAX_SNAPSHOT_FILENAME); > > > > - return (send_checkpoint_op_req(ctx, &op)); > > + length = offsetof(struct ipc_message, data) + sizeof(imsg.data.op); > > + > > + return (send_message(ctx, (void *)&imsg, length)); > > } > > #endif > > > > -- Rod Grimes rgrimes@freebsd.org