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)
Mar 12 2024, 6:10 AM
Unknown Object (File)
Mar 12 2024, 6:10 AM
Unknown Object (File)
Mar 8 2024, 5:13 AM
Unknown Object (File)
Mar 8 2024, 5:01 AM
Unknown Object (File)
Feb 12 2024, 4:19 AM
Unknown Object (File)
Feb 9 2024, 2:08 AM
Unknown Object (File)
Dec 31 2023, 11:47 AM
Unknown Object (File)
Dec 20 2023, 8:14 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.