[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 0f5319: cli: Don't run early event loop if no

From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 0f5319: cli: Don't run early event loop if no --preconfig ...
Date: Tue, 12 Jun 2018 03:29:50 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 0f5319ea25fb0a05827d512859b7c7d23371ac5d
  Author: Igor Mammedov <address@hidden>
  Date:   2018-06-11 (Mon, 11 Jun 2018)

  Changed paths:
    M vl.c

  Log Message:
  cli: Don't run early event loop if no --preconfig was specified

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:

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 <address@hidden>
  Subject: [PATCH] cli: Don't run early event loop if no --preconfig was 
  Message-Id: <address@hidden>
Fixes: 047f7038f586d215
Signed-off-by: Igor Mammedov <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>

  Commit: 6e3bd769916e643d371882da1bda5fbd453d3c3b
  Author: Peter Maydell <address@hidden>
  Date:   2018-06-12 (Tue, 12 Jun 2018)

  Changed paths:
    M vl.c

  Log Message:
  Merge remote-tracking branch 
'remotes/ehabkost/tags/machine-next-pull-request' into staging

Machine queue, 2018-06-11

* Fix -daemonize hang caused by --preconfig code

# gpg: Signature made Mon 11 Jun 2018 18:32:52 BST
# gpg:                using RSA key 2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <address@hidden>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/machine-next-pull-request:
  cli: Don't run early event loop if no --preconfig was specified

Signed-off-by: Peter Maydell <address@hidden>

Compare: https://github.com/qemu/qemu/compare/a48f7644f812...6e3bd769916e
      **NOTE:** This service been marked for deprecation: 

      Functionality will be removed from GitHub.com on January 31st, 2019.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]