From owner-dev-commits-src-branches@freebsd.org Fri Jul 2 05:24:23 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 27D6365F17D; Fri, 2 Jul 2021 05:24:23 +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 4GGNml0cSJz4gGx; Fri, 2 Jul 2021 05:24:23 +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 F18F263CB; Fri, 2 Jul 2021 05:24:22 +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 1625OM3m078129; Fri, 2 Jul 2021 05:24:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1625OMcR078128; Fri, 2 Jul 2021 05:24:22 GMT (envelope-from git) Date: Fri, 2 Jul 2021 05:24:22 GMT Message-Id: <202107020524.1625OMcR078128@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: e63372af7107 - stable/12 - bhyvectl: print a better error message when vm_open() fails 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/stable/12 X-Git-Reftype: branch X-Git-Commit: e63372af710790e6d583a0f1f7d0a3a6e55b5369 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jul 2021 05:24:23 -0000 The branch stable/12 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=e63372af710790e6d583a0f1f7d0a3a6e55b5369 commit e63372af710790e6d583a0f1f7d0a3a6e55b5369 Author: Marko AuthorDate: 2021-03-07 06:19:30 +0000 Commit: Robert Wing CommitDate: 2021-07-02 03:18:54 +0000 bhyvectl: print a better error message when vm_open() fails libvmm: explicitly save and restore errno in vm_open() Use errno to print a more descriptive error message when vm_open() fails PR: 250671 Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D29109 (cherry picked from commit 6bb140e3ca895a148f32c93d50f93619bf735f73) (cherry picked from commit a7f81b488df2d4a5dcd785b4112e04ffb6ca0442) --- lib/libvmmapi/vmmapi.c | 5 ++++- usr.sbin/bhyvectl/bhyvectl.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 2bf034ee7f4d..a8ce5377b26d 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -111,6 +111,7 @@ struct vmctx * vm_open(const char *name) { struct vmctx *vm; + int saved_errno; vm = malloc(sizeof(struct vmctx) + strlen(name) + 1); assert(vm != NULL); @@ -126,7 +127,9 @@ vm_open(const char *name) return (vm); err: - vm_destroy(vm); + saved_errno = errno; + free(vm); + errno = saved_errno; return (NULL); } diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index 2f5e2c5c8c94..1da6dab3e14e 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -1849,7 +1849,9 @@ main(int argc, char *argv[]) if (!error) { ctx = vm_open(vmname); if (ctx == NULL) { - printf("VM:%s is not created.\n", vmname); + fprintf(stderr, + "vm_open: %s could not be opened: %s\n", + vmname, strerror(errno)); exit (1); } }