From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
libvir-list@redhat.com, Stefan Weil <sw@weilnetz.de>,
Hanna Reitz <hreitz@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize code
Date: Fri, 4 Mar 2022 14:54:54 +0000 [thread overview]
Message-ID: <YiIoPrLctNqySk4n@redhat.com> (raw)
In-Reply-To: <20220304115657.3177925-5-berrange@redhat.com>
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 :|
next prev parent reply other threads:[~2022-03-04 15:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 11:56 [PATCH 0/4] softmmu: move and refactor -runas, -chroot and -daemonize Daniel P. Berrangé
2022-03-04 11:56 ` [PATCH 1/4] softmmu: remove deprecated --enable-fips option Daniel P. Berrangé
2022-03-04 13:55 ` Philippe Mathieu-Daudé
2022-03-04 17:14 ` Eric Blake
2022-03-04 11:56 ` [PATCH 2/4] os-posix: refactor code handling the -runas argument Daniel P. Berrangé
2022-03-04 17:19 ` Eric Blake
2022-03-04 11:56 ` [PATCH 3/4] os-posix: refactor code handling the -chroot argument Daniel P. Berrangé
2022-03-04 13:54 ` Philippe Mathieu-Daudé
2022-03-04 11:56 ` [PATCH 4/4] softmmu: move parsing of -runas, -chroot and -daemonize code Daniel P. Berrangé
2022-03-04 14:54 ` Daniel P. Berrangé [this message]
2022-03-04 17:21 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YiIoPrLctNqySk4n@redhat.com \
--to=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=libvir-list@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).