From: Anthony Liguori <anthony@codemonkey.ws>
To: Michael Tokarev <mjt@tls.msk.ru>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Hajnoczi <stefanha@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v2] stop using stdio for monitor/serial/etc with -daemonize
Date: Tue, 25 Sep 2012 16:19:59 -0500 [thread overview]
Message-ID: <876271ol4w.fsf@codemonkey.ws> (raw)
In-Reply-To: <1348584532-21914-1-git-send-email-mjt@msgid.tls.msk.ru>
Michael Tokarev <mjt@tls.msk.ru> writes:
> 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.
Combining -nographic and -daemonize don't make sense. I'd rather error
out with this combination.
I think what the user is after is -daemonize -vga none OR -daemonize
-display none.
Regards,
Anthony Liguori
>
> This is https://bugs.launchpad.net/qemu/+bug/1024275
> or http://bugs.debian.org/549195 .
>
> While at it, reformat this code a bit to be less of a maze of
> ifs and use a variable to hold common target of devices.
>
> 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 | 45 +++++++++++++++++++++++++++------------------
> 1 file changed, 27 insertions(+), 18 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 48049ef..a210ff9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3392,30 +3392,39 @@ int main(int argc, char **argv, char **envp)
> default_sdcard = 0;
> }
>
> - if (display_type == DT_NOGRAPHIC) {
> - if (default_parallel)
> - add_device_config(DEV_PARALLEL, "null");
> + /* Create default monitor, serial, parallel and virtcon devices. */
> + /* reuse optarg variable */
> + optarg = NULL;
> + if (display_type != DT_NOGRAPHIC) {
> + /* regular case, all devices directed to the guest console */
> + optarg = "vc:80Cx24C";
> + } else if (is_daemonized()) {
> + /* nographic and daemonize, everything => null */
> + optarg = "null";
> + } else {
> + /* nographic and no daemonize */
> + /* can't have both serial and virtcon on stdio */
> 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");
> + optarg = "stdio";
> }
> - } else {
> - if (default_serial)
> - add_device_config(DEV_SERIAL, "vc:80Cx24C");
> - if (default_parallel)
> - add_device_config(DEV_PARALLEL, "vc:80Cx24C");
> - if (default_monitor)
> - monitor_parse("vc:80Cx24C", "readline");
> - if (default_virtcon)
> - add_device_config(DEV_VIRTCON, "vc:80Cx24C");
> + }
> + if (optarg && default_serial) {
> + add_device_config(DEV_SERIAL, optarg);
> + }
> + if (default_parallel) {
> + /* parallel port is connected console or to null */
> + add_device_config(DEV_PARALLEL,
> + display_type == DT_NOGRAPHIC ? "null" : optarg);
> + }
> + if (optarg && default_monitor) {
> + monitor_parse(optarg, "readline");
> + }
> + if (optarg && default_virtcon) {
> + add_device_config(DEV_VIRTCON, optarg);
> }
>
> socket_init();
> --
> 1.7.10.4
next prev parent reply other threads:[~2012-09-25 21:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-25 14:48 [Qemu-devel] [PATCH v2] stop using stdio for monitor/serial/etc with -daemonize Michael Tokarev
2012-09-25 21:19 ` Anthony Liguori [this message]
2012-09-26 7:09 ` Michael Tokarev
2012-09-26 8:00 ` Peter Maydell
2012-09-26 8:17 ` Michael Tokarev
2012-09-26 8:43 ` Peter Maydell
2012-09-26 13:46 ` Anthony Liguori
2012-09-26 14:56 ` Michael Tokarev
2012-10-27 11:23 ` Michael Tokarev
2012-10-27 11:33 ` Peter Maydell
2012-10-27 12:15 ` Michael Tokarev
2012-10-27 12:48 ` Blue Swirl
2012-10-27 12:55 ` Michael Tokarev
2012-10-27 13:11 ` 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=876271ol4w.fsf@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=mjt@tls.msk.ru \
--cc=peter.maydell@linaro.org \
--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).