Skip to content

Commit

Permalink
bhyvectl: print a better error message when vm_open() fails
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rob-wing committed Mar 7, 2021
1 parent 2fc640d commit 6bb140e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/libvmmapi/vmmapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ vm_open(const char *name)

return (vm);
err:
vm_destroy(vm);
free(vm);
return (NULL);
}

Expand Down
4 changes: 3 additions & 1 deletion usr.sbin/bhyvectl/bhyvectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 6bb140e

Please sign in to comment.