Page MenuHomeFreeBSD

bhyvectl: print a better error message when vm_open fails
ClosedPublic

Authored by rew on Mar 7 2021, 2:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 19, 3:10 PM
Unknown Object (File)
Sat, Oct 19, 6:14 AM
Unknown Object (File)
Sat, Oct 19, 6:14 AM
Unknown Object (File)
Sat, Oct 19, 6:14 AM
Unknown Object (File)
Sat, Oct 19, 5:52 AM
Unknown Object (File)
Oct 4 2024, 5:01 AM
Unknown Object (File)
Oct 1 2024, 4:37 PM
Unknown Object (File)
Sep 28 2024, 3:45 AM

Details

Summary

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
Submitted by: marko@apache.org

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rew requested review of this revision.Mar 7 2021, 2:15 AM
This revision is now accepted and ready to land.Mar 7 2021, 2:17 AM
jhb added inline comments.
lib/libvmmapi/vmmapi.c
136

free() can also trash errno in theory since it could potentially invoke madvise(), etc. It's probably safest to just explicitly save and restore errno around it.

usr.sbin/bhyvectl/bhyvectl.c
1953

Maybe use err() here?

lib/libvmmapi/vmmapi.c
136

got it

should I bring back vm_destroy() since the errno will be restored anyway?

usr.sbin/bhyvectl/bhyvectl.c
1953

I went with fprintf(stderr) because it was used elsewhere in this file and I didn't see any usage of err().

would have to #include <err.h>
something like err(1, "could not open %s", vmname);?

I've got no strong feelings here, let me know what you prefer.