qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@gmail.com>, Michael Tokarev <mjt@tls.msk.ru>
Subject: [Qemu-devel] [PATCH] stop using stdio for monitor/serial/etc with -daemonize
Date: Tue, 25 Sep 2012 14:43:37 +0400	[thread overview]
Message-ID: <1348569817-11178-1-git-send-email-mjt@msgid.tls.msk.ru> (raw)

Current code binds monitor and serial port to the guest console
unless -nographic is specified, which is okay.  But when there's
no guest console (-nographic), the code tries to use stdio for
the same default devices.  But it does not check for -daemonize
at the same time -- because when -daemonize is given, there's no
point at using stdin since it will be closed down the line.
However, when serial port is attached to stdin, tty control
modes are changed (switching tty to raw mode), and qemu will
switch to background, leaving the tty in bad state.

Take -daemonize into account too, when assigning default devices,
and for -nographic -daemonize case, assign them to "null" instead.

This is https://bugs.launchpad.net/qemu/+bug/1024275
or http://bugs.debian.org/549195 .

This patch depends on another patch, 995ee2bf469de6,
"curses: don't initialize curses when qemu is daemonized",
by Hitoshi Mitake, which creates is_daemonized() routine.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 vl.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/vl.c b/vl.c
index 48049ef..ae1794f 100644
--- a/vl.c
+++ b/vl.c
@@ -3395,17 +3395,26 @@ int main(int argc, char **argv, char **envp)
     if (display_type == DT_NOGRAPHIC) {
         if (default_parallel)
             add_device_config(DEV_PARALLEL, "null");
-        if (default_serial && default_monitor) {
-            add_device_config(DEV_SERIAL, "mon:stdio");
-        } else if (default_virtcon && default_monitor) {
-            add_device_config(DEV_VIRTCON, "mon:stdio");
+        if (!is_daemonized()) {
+            if (default_serial && default_monitor) {
+                add_device_config(DEV_SERIAL, "mon:stdio");
+            } else if (default_virtcon && default_monitor) {
+                add_device_config(DEV_VIRTCON, "mon:stdio");
+            } else {
+                if (default_serial)
+                    add_device_config(DEV_SERIAL, "stdio");
+                if (default_virtcon)
+                    add_device_config(DEV_VIRTCON, "stdio");
+                if (default_monitor)
+                    monitor_parse("stdio", "readline");
+            }
         } else {
             if (default_serial)
-                add_device_config(DEV_SERIAL, "stdio");
+                add_device_config(DEV_SERIAL, "null");
             if (default_virtcon)
-                add_device_config(DEV_VIRTCON, "stdio");
+                add_device_config(DEV_VIRTCON, "null");
             if (default_monitor)
-                monitor_parse("stdio", "readline");
+                monitor_parse("stdio", "null");
         }
     } else {
         if (default_serial)
-- 
1.7.10.4

             reply	other threads:[~2012-09-25 10:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25 10:43 Michael Tokarev [this message]
2012-09-25 11:23 ` [Qemu-devel] [PATCH] stop using stdio for monitor/serial/etc with -daemonize Peter Maydell
2012-09-25 11:53   ` Michael Tokarev
2012-09-25 13:49     ` Michael Tokarev

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=1348569817-11178-1-git-send-email-mjt@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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).