On Thu, May 13, 2021 at 04:19:22PM -0400, Steven Sistare wrote: > On 5/7/2021 10:31 AM, Eric Blake wrote: > > On 5/7/21 7:25 AM, Steve Sistare wrote: > >> Add a qemu_exec_requested() hook that causes the main loop to exit and > >> re-exec qemu using the same initial arguments. If /usr/bin/qemu-exec > >> exists, exec that instead. This is an optional site-specific trampoline > >> that may alter the environment before exec'ing the qemu binary. > >> > >> Signed-off-by: Steve Sistare <steven.sist...@oracle.com> > >> --- > > > >> +static void qemu_exec(void) > >> +{ > >> + const char *helper = "/usr/bin/qemu-exec"; > >> + const char *bin = !access(helper, X_OK) ? helper : argv_main[0]; > > > > Reads awkwardly; I would have used '...= access(helper, X_OK) == 0 ?...' > > Will fix. > > >> + > >> + execvp(bin, argv_main); > >> + error_report("execvp failed, errno %d.", errno); > > > > error_report should not be used with a trailing dot. > > Will fix. I was not sure because I see examples both ways, though no dot > prevails. > Perhaps it should be added to the style guide and checkpatch. > > > Also, %d for errno is awkward, better is: > > > > error_report("execvp failed: %s", strerror(errno)); > > I shy away from strerror because it is not thread safe, but I see qemu uses it > extensively. Will fix.
GLib provides 'g_strerror' which is threadsafe, but without the horrible API of strerror_r. It works by caching the errno strings in a static table on demand. We don't use it much in QEMU, but I think we ought to. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|