mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
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 commit6bb140e3ca
) (cherry picked from commita7f81b488d
)
This commit is contained in:
parent
6aee785518
commit
3f65cb8fda
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user