Date: Sun, 7 Mar 2021 06:29:21 GMT From: Robert Wing <rew@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 6bb140e3ca89 - main - bhyvectl: print a better error message when vm_open() fails Message-ID: <202103070629.1276TLVZ064697@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=6bb140e3ca895a148f32c93d50f93619bf735f73 commit 6bb140e3ca895a148f32c93d50f93619bf735f73 Author: Robert Wing <rew@FreeBSD.org> AuthorDate: 2021-03-07 06:19:30 +0000 Commit: Robert Wing <rew@FreeBSD.org> CommitDate: 2021-03-07 06:19:30 +0000 bhyvectl: print a better error message when vm_open() fails Use errno to print a more descriptive error message when vm_open() fails libvmm: preserve errno when vm_device_open() fails vm_destroy() squashes errno by making a dive into sysctlbyname() - we can safely skip vm_destroy() here since it's not doing any critical clean up at this point. Replace vm_destroy() with a free() call. PR: 250671 MFC after: 3 days Submitted by: marko@apache.org Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D29109 --- lib/libvmmapi/vmmapi.c | 2 +- usr.sbin/bhyvectl/bhyvectl.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index b36ad1c84423..7d46a85b1cd5 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -133,7 +133,7 @@ vm_open(const char *name) return (vm); err: - vm_destroy(vm); + free(vm); return (NULL); } diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index 68cc958e66ec..0f7b9533fe4b 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -1950,7 +1950,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); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103070629.1276TLVZ064697>