[PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize code

Eric Blake eblake at redhat.com
Fri Mar 4 17:21:38 UTC 2022


On Fri, Mar 04, 2022 at 02:54:54PM +0000, Daniel P. Berrangé wrote:
> On Fri, Mar 04, 2022 at 11:56:57AM +0000, Daniel P. Berrangé wrote:
> > With the future intent to try to move to a fully QAPI driven
> > configuration system, we want to have any current command
> > parsing well isolated from logic that applies the resulting
> > configuration.
> > 
> > We also don't want os-posix.c to contain code that is specific
> > to the system emulators, as this file is linked to other binaries
> > too.
> > 
> > To satisfy these goals, we move parsing of the -runas, -chroot and
> > -daemonize code out of the os-posix.c helper code, and pass the
> > parsed data into APIs in os-posix.c.
> > 
> > As a side benefit the 'os_daemonize()' function now lives upto to

up to

> > its name and will always daemonize, instead of using global state
> > to decide to be a no-op sometimes.

Yay.

> > @@ -3683,7 +3743,7 @@ void qemu_init(int argc, char **argv, char **envp)
> >      qemu_process_early_options();
> >  
> >      qemu_process_help_options();
> > -    qemu_maybe_daemonize(pid_file);
> > +    qemu_maybe_daemonize(daemonize, pid_file);
> 
> This commit is a bit flawed, because we're until we call the
> os_daemonize() method, the is_daemonized() method won't return
> true. Unfortunately some callers rely is_daemonized() returning
> true merely for the request, even though we've not yet put it
> into action. ie the method would have been better called
> is_daemonize_requested()

Eww, indeed.

> 
> The upshot is that we fail to properly close stderr.
> 
> I'll send a v2 that handles this by fully removing the
> is_daemonize() method.

Looking forward to it.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the libvir-list mailing list