[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize code |
Date: |
Fri, 4 Mar 2022 14:54:54 +0000 |
User-agent: |
Mutt/2.1.5 (2021-12-30) |
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
> its name and will always daemonize, instead of using global state
> to decide to be a no-op sometimes.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> include/sysemu/os-posix.h | 4 +-
> include/sysemu/os-win32.h | 1 -
> os-posix.c | 148 +++++++++++---------------------------
> os-win32.c | 9 ---
> softmmu/vl.c | 76 ++++++++++++++++++--
> 5 files changed, 113 insertions(+), 125 deletions(-)
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 1fe028800f..cdf27b6027 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -2602,11 +2602,13 @@ static void qemu_process_help_options(void)
> }
> }
>
> -static void qemu_maybe_daemonize(const char *pid_file)
> +static void qemu_maybe_daemonize(bool daemonize, const char *pid_file)
> {
> Error *err = NULL;
>
> - os_daemonize();
> + if (daemonize) {
> + os_daemonize();
> + }
> rcu_disable_atfork();
>
> if (pid_file && !qemu_write_pidfile(pid_file, &err)) {
> @@ -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()
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.
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 :|
- [PATCH 0/4] softmmu: move and refactor -runas, -chroot and -daemonize, Daniel P . Berrangé, 2022/03/04
- [PATCH 1/4] softmmu: remove deprecated --enable-fips option, Daniel P . Berrangé, 2022/03/04
- [PATCH 2/4] os-posix: refactor code handling the -runas argument, Daniel P . Berrangé, 2022/03/04
- [PATCH 3/4] os-posix: refactor code handling the -chroot argument, Daniel P . Berrangé, 2022/03/04
- [PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize code, Daniel P . Berrangé, 2022/03/04
- Re: [PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize code,
Daniel P . Berrangé <=