qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11
@ 2018-06-11 17:34 Eduardo Habkost
  2018-06-11 17:34 ` [Qemu-devel] [PULL 1/1] cli: Don't run early event loop if no --preconfig was specified Eduardo Habkost
  2018-06-12 10:56 ` [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11 Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Habkost @ 2018-06-11 17:34 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Marcel Apfelbaum, Paolo Bonzini, Daniel P. Berrange

The following changes since commit 9f55925b8f50a962d1d08d815044db7767ae3838:

  Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-3.0-pull-request' into staging (2018-06-11 12:46:16 +0100)

are available in the Git repository at:

  git://github.com/ehabkost/qemu.git tags/machine-next-pull-request

for you to fetch changes up to 0f5319ea25fb0a05827d512859b7c7d23371ac5d:

  cli: Don't run early event loop if no --preconfig was specified (2018-06-11 14:25:49 -0300)

----------------------------------------------------------------
Machine queue, 2018-06-11

* Fix -daemonize hang caused by --preconfig code

----------------------------------------------------------------

Queue for Machine Core patches


Igor Mammedov (1):
  cli: Don't run early event loop if no --preconfig was specified

 vl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.18.0.rc1.1.g3f1ff2140

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PULL 1/1] cli: Don't run early event loop if no --preconfig was specified
  2018-06-11 17:34 [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11 Eduardo Habkost
@ 2018-06-11 17:34 ` Eduardo Habkost
  2018-06-12 10:56 ` [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11 Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Habkost @ 2018-06-11 17:34 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Marcel Apfelbaum, Paolo Bonzini, Daniel P. Berrange,
	Igor Mammedov

From: Igor Mammedov <imammedo@redhat.com>

After 047f7038f586d215 it is possible for event loop to run two
times. First time whilst parsing command line options (the idea
is to bring up monitor early so that management applications can
tweak config before machine is initialized). And the second time
is after everything is set up (this is the usual place). In both
cases the event loop is called as main_loop_wait(nonblocking =
false) which causes the event loop to block until at least one
event occurred.

Now, consider that somebody (i.e. libvirt) calls us with
-daemonize. This operation is split in two steps. The main()
calls os_daemonize() which fork()-s and then waits in read()
until child notifies it via write():

/qemu.git $ ./x86_64-softmmu/qemu-system-x86_64 -S -daemonize \
  -no-user-config -nodefaults -nographic

  main():                child:
    os_daemonize():
      read(pipe[0])

                           main_loop():
                             main_loop_wait(false)

                           os_setup_post():
                             write(pipe[1])

                           main_loop():
                             main_loop_wait(false)

Here it can be clearly seen that main() does not exit until an
event occurs, but at the same time nobody will touch the monitor
socket until their exec("qemu-system-*") finishes. So the whole
thing deadlocks.

The solution is to not call main_loop_wait() unless --preconfig was
specified (in which case caller knows they must connect to the
socket before exec() finishes).

Patch also fixes hang when -nodefaults option is used, which were
causing QEMU hang in the early main_loop_wait() indefinitely by
the same means (not calling main_loop_wait() unless --preconfig
is present on CLI)

Based on
  From: Michal Privoznik <mprivozn@redhat.com>
  Subject: [PATCH] cli: Don't run early event loop if no --preconfig was specified
  Message-Id: <ad910973c593c5ac2fed3a10ea958f7e9c12f82c.1527935663.git.mprivozn@redhat.com>
Fixes: 047f7038f586d215
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1528207243-268226-2-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 vl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index 06031715ac..6e34fb348d 100644
--- a/vl.c
+++ b/vl.c
@@ -1841,7 +1841,7 @@ static void main_loop(void)
 #ifdef CONFIG_PROFILER
     int64_t ti;
 #endif
-    do {
+    while (!main_loop_should_exit()) {
 #ifdef CONFIG_PROFILER
         ti = profile_getclock();
 #endif
@@ -1849,7 +1849,7 @@ static void main_loop(void)
 #ifdef CONFIG_PROFILER
         dev_time += profile_getclock() - ti;
 #endif
-    } while (!main_loop_should_exit());
+    }
 }
 
 static void version(void)
-- 
2.18.0.rc1.1.g3f1ff2140

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11
  2018-06-11 17:34 [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11 Eduardo Habkost
  2018-06-11 17:34 ` [Qemu-devel] [PULL 1/1] cli: Don't run early event loop if no --preconfig was specified Eduardo Habkost
@ 2018-06-12 10:56 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2018-06-12 10:56 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: QEMU Developers, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrange

On 11 June 2018 at 18:34, Eduardo Habkost <ehabkost@redhat.com> wrote:
> The following changes since commit 9f55925b8f50a962d1d08d815044db7767ae3838:
>
>   Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-3.0-pull-request' into staging (2018-06-11 12:46:16 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/ehabkost/qemu.git tags/machine-next-pull-request
>
> for you to fetch changes up to 0f5319ea25fb0a05827d512859b7c7d23371ac5d:
>
>   cli: Don't run early event loop if no --preconfig was specified (2018-06-11 14:25:49 -0300)
>
> ----------------------------------------------------------------
> Machine queue, 2018-06-11
>
> * Fix -daemonize hang caused by --preconfig code
>
> ----------------------------------------------------------------
>
> Queue for Machine Core patches
>
>
> Igor Mammedov (1):
>   cli: Don't run early event loop if no --preconfig was specified
>
>  vl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> --

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-12 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-11 17:34 [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11 Eduardo Habkost
2018-06-11 17:34 ` [Qemu-devel] [PULL 1/1] cli: Don't run early event loop if no --preconfig was specified Eduardo Habkost
2018-06-12 10:56 ` [Qemu-devel] [PULL 0/1] Machine queue, 2018-06-11 Peter Maydell

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).