The branch stable/13 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=3f65cb8fda02c4f643c476f04655de843e31e563
commit 3f65cb8fda02c4f643c476f04655de843e31e563 Author: Marko <[email protected]> AuthorDate: 2021-03-07 06:19:30 +0000 Commit: Robert Wing <[email protected]> CommitDate: 2021-07-02 03:17:12 +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 39732f448023..5810274c9a73 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -118,6 +118,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); @@ -133,7 +134,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 c54aa1f33dc1..1b882e1e0504 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -1960,7 +1960,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); } } _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "[email protected]"
