Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jul 2021 05:24:22 GMT
From:      Robert Wing <rew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e63372af7107 - stable/12 - bhyvectl: print a better error message when vm_open() fails
Message-ID:  <202107020524.1625OMcR078128@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=e63372af710790e6d583a0f1f7d0a3a6e55b5369

commit e63372af710790e6d583a0f1f7d0a3a6e55b5369
Author:     Marko <marko@apache.org>
AuthorDate: 2021-03-07 06:19:30 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
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);
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107020524.1625OMcR078128>