git: ee0ebaa42028 - main - bhyvectl: drop vm_get_name()

From: Robert Wing <rew_at_FreeBSD.org>
Date: Fri, 18 Mar 2022 05:24:56 UTC
The branch main has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=ee0ebaa42028aee9886e06b6b995c8b2389e89f4

commit ee0ebaa42028aee9886e06b6b995c8b2389e89f4
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2022-03-18 05:22:43 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2022-03-18 05:22:43 +0000

    bhyvectl: drop vm_get_name()
    
    Grab the vm name from bhyvectl's --vm flag instead.
    
    Reviewed by:    jhb
    Differential Revision:  https://reviews.freebsd.org/D34399
---
 usr.sbin/bhyvectl/bhyvectl.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 0480e1623621..e4de6da1803c 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -1684,11 +1684,10 @@ show_memseg(struct vmctx *ctx)
 
 #ifdef BHYVE_SNAPSHOT
 static int
-send_message(struct vmctx *ctx, nvlist_t *nvl)
+send_message(const char *vmname, nvlist_t *nvl)
 {
 	struct sockaddr_un addr;
 	int err, socket_fd;
-	char vmname_buf[MAX_VMNAME];
 
 	socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0);
 	if (socket_fd < 0) {
@@ -1700,13 +1699,7 @@ send_message(struct vmctx *ctx, nvlist_t *nvl)
 	memset(&addr, 0, sizeof(struct sockaddr_un));
 	addr.sun_family = AF_UNIX;
 
-	err = vm_get_name(ctx, vmname_buf, MAX_VMNAME - 1);
-	if (err != 0) {
-		perror("Failed to get VM name");
-		goto done;
-	}
-
-	snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", BHYVE_RUN_DIR, vmname_buf);
+	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) {
 		perror("connect() failed");
@@ -1725,7 +1718,7 @@ done:
 }
 
 static int
-snapshot_request(struct vmctx *ctx, const char *file, bool suspend)
+snapshot_request(const char *vmname, const char *file, bool suspend)
 {
 	nvlist_t *nvl;
 
@@ -1734,7 +1727,7 @@ snapshot_request(struct vmctx *ctx, const char *file, bool suspend)
 	nvlist_add_string(nvl, "filename", file);
 	nvlist_add_bool(nvl, "suspend", suspend);
 
-	return (send_message(ctx, nvl));
+	return (send_message(vmname, nvl));
 }
 #endif
 
@@ -2398,10 +2391,10 @@ main(int argc, char *argv[])
 
 #ifdef BHYVE_SNAPSHOT
 	if (!error && vm_checkpoint_opt)
-		error = snapshot_request(ctx, checkpoint_file, false);
+		error = snapshot_request(vmname, checkpoint_file, false);
 
 	if (!error && vm_suspend_opt)
-		error = snapshot_request(ctx, suspend_file, true);
+		error = snapshot_request(vmname, suspend_file, true);
 #endif
 
 	free (opts);