From: Igor Mammedov <imammedo@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Michal Privoznik <mprivozn@redhat.com>,
qemu-devel@nongnu.org, Eric Blake <eblake@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] vl: fix use of --daemonize with --preconfig
Date: Mon, 4 Jun 2018 17:55:01 +0200 [thread overview]
Message-ID: <20180604175501.275b08c8@redhat.com> (raw)
In-Reply-To: <20180604151523.GK19749@redhat.com>
On Mon, 4 Jun 2018 16:15:23 +0100
Daniel P. Berrangé <berrange@redhat.com> wrote:
> On Mon, Jun 04, 2018 at 05:01:11PM +0200, Igor Mammedov wrote:
> > On Mon, 4 Jun 2018 16:21:48 +0200
> > Michal Privoznik <mprivozn@redhat.com> wrote:
> >
> > > On 06/04/2018 02:03 PM, Daniel P. Berrangé wrote:
> > > > When using --daemonize, the initial lead process will fork a child and
> > > > then wait to be notified that setup is complete via a pipe, before it
> > > > exits. When using --preconfig there is an extra call to main_loop()
> > > > before the notification is done from os_setup_post(). Thus the parent
> > > > process won't exit until the mgmt application connects to the monitor
> > > > and tells QEMU to leave the RUN_STATE_PRECONFIG. The mgmt application
> > > > won't connect to the monitor until daemonizing has completed though.
> > > >
> > > > This is a chicken and egg problem, leading to deadlock at startup.
> > not calling 1st main_loop(), solves the issue if no --preconfig
> > is specified like Michal has suggested. So moving os_setup_post()
> > earlier isn't the only option.
> >
> > With Michal's patch it should work fine with old libvirt versions,
> > however it would mean more changes to libvirt when adding
> > --preconfig option handling as it would need to connect to qmp
> > socket earlier if the option is used.
>
> This patch doesn't cause problems with old libvirt either - the opposite
> in fact, it fixes the problems that broke with old libvirt.
>
> >
> > > > The only viable way to fix this is to call os_setup_post() before
> > > > the early main_loop() call when in RUN_STATE_PRECONFIG. This has the
> > > > downside that any errors from this point onwards won't be handled
> > > > well by the mgmt application, because it will think QEMU has started
> > > > successfully, so not be expecting an abrupt exit. The only way to
> > > > deal with that is to move as much user input validation as possible
> > > > to before the main_loop() call. This is left as an exercise for
> > > > future interested developers.
> > Moving post board input validation might be problematic as
> > it might require existing board to create a device so it could verify
> > user provided parameters.
> >
> > Does mgmt application starts QEMU with log file where QEMU would
> > write errors if any after os_setup_post() and would mgmt app look
> > into it/report from it to user if QEMU disappears?
>
> Sure any app can redirect stdout/err to a file if it wishes.
>
> --daemonize was actually also a synchronization point - once the parent
> returns, the mgmt app knows it can successfully connect to the QEMU
> monitor as the listener socket is guaranteed to be created by then.
> So moving the os_setup_post earlier as I did still gives that sync
> point, which is good. It just means when the mgmt app has to be aware
> that more errors might appear on stderr in the window until it exits
> preconfig phase.
>
> Ideally there would be a way to feed them back via the monitor, but
> that's non-trivial, so doubt it'll happen any time in the forseeable
> future.
Question is if libvirt would notify user (in its logs) about error
after sync point?
> > > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > > > ---
> > > > vl.c | 7 ++++++-
> > > > 1 file changed, 6 insertions(+), 1 deletion(-)
> > >
> > > Yup, this fixes the problem I've raised in my patch. Thanks!
> > I'd prefer your patch, as it doesn't break error handling,
>
> Michal's patch didn't actually fix the real problem. It simply avoided
> triggering the bug when --preconfig was not present - QEMU still hangs
> with --preconfig --daemonize are used together.
it's not exactly a bug, it's new behavior so mgmt could adapt to it,
i.e. lack of sync point (which certainly complicates mgmt part).
So this patch is also fine if libvirt would be able to provide
meaning-full error to users in case of problem post os_setup_post() stage.
In both cases it would require some work on mgmt part when adding support
for --precongig.
next prev parent reply other threads:[~2018-06-04 15:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 12:03 [Qemu-devel] [PATCH v2 0/2] Avoid using RUN_STATE_PRECONFIG unless explicitly requested with --preconfig Daniel P. Berrangé
2018-06-04 12:03 ` [Qemu-devel] [PATCH v2 1/2] vl: don't use RUN_STATE_PRECONFIG as initial state Daniel P. Berrangé
2018-06-04 14:21 ` Michal Privoznik
2018-06-05 0:56 ` Eduardo Habkost
2018-06-05 8:37 ` Igor Mammedov
2018-06-05 12:01 ` Eduardo Habkost
2018-06-05 14:25 ` Igor Mammedov
2018-06-05 14:59 ` Eduardo Habkost
2018-06-05 11:59 ` Daniel P. Berrangé
2018-06-04 15:40 ` Igor Mammedov
2018-06-04 16:11 ` Daniel P. Berrangé
2018-06-04 17:37 ` Igor Mammedov
2018-06-05 0:35 ` Eduardo Habkost
2018-06-05 8:31 ` Igor Mammedov
2018-06-05 12:03 ` Daniel P. Berrangé
2018-06-04 12:03 ` [Qemu-devel] [PATCH v2 2/2] vl: fix use of --daemonize with --preconfig Daniel P. Berrangé
2018-06-04 14:21 ` Michal Privoznik
2018-06-04 15:01 ` Igor Mammedov
2018-06-04 15:15 ` Daniel P. Berrangé
2018-06-04 15:55 ` Igor Mammedov [this message]
2018-06-05 1:06 ` Eduardo Habkost
2018-06-05 7:10 ` Igor Mammedov
2018-06-04 21:53 ` Igor Mammedov
2018-06-05 12:00 ` Daniel P. Berrangé
2018-06-05 14:49 ` Igor Mammedov
2018-06-11 7:58 ` [Qemu-devel] [PATCH v2 0/2] Avoid using RUN_STATE_PRECONFIG unless explicitly requested " Michal Prívozník
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=20180604175501.275b08c8@redhat.com \
--to=imammedo@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=mprivozn@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).