Patchwork display: stop using DT_NOGRAPHIC, use DT_NONE

login
register
mail settings
Submitter Michael Tokarev
Date June 19, 2013, 12:34 p.m.
Message ID <1371645291-3178-1-git-send-email-mjt@msgid.tls.msk.ru>
Download mbox | patch
Permalink /patch/252572/
State New
Headers show

Comments

Michael Tokarev - June 19, 2013, 12:34 p.m.
It looks like initially there was -nographic option to turn
off display, now there's another option of the same sort,
-display none.  But code in other places of qemu checks for
DT_NOGRAPHIC and does not work well with -display none.
Make DT_NOGRAPHIC an internal version which selects DT_NONE,
and check for that in all other places where previously we
checked for DT_NOGRAPHIC.

While at it, rename two private variants of display (DT_DEFAULT
and DT_NOGRAPHIC) to use two underscores and make them negative,
and set DT_NONE to 0.

This should fix the issue of non-working sun serial console
with the suggested replacement of -nographic which is
-display none.

I'm not still sure we really want to check for display type
in qemu-char.c where we allow/disallow signals delivery from
terminal, -- for other display types (CURSES) this makes no
good sense.

If the fix is correct, it is a stable material.

Cc: Todd T. Fries <todd@fries.net>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 hw/lm32/milkymist-hw.h  |    2 +-
 hw/nvram/fw_cfg.c       |    2 +-
 hw/sparc/sun4m.c        |    2 +-
 include/sysemu/sysemu.h |    6 +++---
 qemu-char.c             |    4 ++--
 vl.c                    |   15 +++++++--------
 6 files changed, 15 insertions(+), 16 deletions(-)
Michael Tokarev - June 28, 2013, 10:38 a.m.
Ping?

19.06.2013 16:34, Michael Tokarev wrote:
> It looks like initially there was -nographic option to turn
> off display, now there's another option of the same sort,
> -display none.  But code in other places of qemu checks for
> DT_NOGRAPHIC and does not work well with -display none.
> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
> and check for that in all other places where previously we
> checked for DT_NOGRAPHIC.
> 
> While at it, rename two private variants of display (DT_DEFAULT
> and DT_NOGRAPHIC) to use two underscores and make them negative,
> and set DT_NONE to 0.
> 
> This should fix the issue of non-working sun serial console
> with the suggested replacement of -nographic which is
> -display none.
> 
> I'm not still sure we really want to check for display type
> in qemu-char.c where we allow/disallow signals delivery from
> terminal, -- for other display types (CURSES) this makes no
> good sense.
> 
> If the fix is correct, it is a stable material.
> 
> Cc: Todd T. Fries <todd@fries.net>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  hw/lm32/milkymist-hw.h  |    2 +-
>  hw/nvram/fw_cfg.c       |    2 +-
>  hw/sparc/sun4m.c        |    2 +-
>  include/sysemu/sysemu.h |    6 +++---
>  qemu-char.c             |    4 ++--
>  vl.c                    |   15 +++++++--------
>  6 files changed, 15 insertions(+), 16 deletions(-)
[]
Peter Maydell - June 28, 2013, 11:24 a.m.
On 19 June 2013 13:34, Michael Tokarev <mjt@tls.msk.ru> wrote:
> It looks like initially there was -nographic option to turn
> off display, now there's another option of the same sort,
> -display none.  But code in other places of qemu checks for
> DT_NOGRAPHIC and does not work well with -display none.
> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
> and check for that in all other places where previously we
> checked for DT_NOGRAPHIC.
>
> While at it, rename two private variants of display (DT_DEFAULT
> and DT_NOGRAPHIC) to use two underscores and make them negative,
> and set DT_NONE to 0.
>
> This should fix the issue of non-working sun serial console
> with the suggested replacement of -nographic which is
> -display none.

Note that "-display none" and "-nographic" aren't exactly
equivalent -- the latter is an option which turns on a bunch
of behaviour including but not limited to "-display none".

> I'm not still sure we really want to check for display type
> in qemu-char.c where we allow/disallow signals delivery from
> terminal, -- for other display types (CURSES) this makes no
> good sense.

...in particular I don't think "-display none" should
mean "don't allow ctrl-c" (though -nographic should
continue to have that effect), and this patch currently
introduces that behaviour change.

> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -87,12 +87,12 @@ void do_info_slirp(Monitor *mon);
>
>  typedef enum DisplayType
>  {
> -    DT_DEFAULT,
> +    DT__DEFAULT = -1,   /* private */
> +    DT__NOGRAPHIC = -2, /* private */
> +    DT_NONE = 0,

I think these could use a slightly longer comment than just "private",
eg "private, used internally by vl.c only".

>      DT_CURSES,
>      DT_SDL,
>      DT_GTK,
> -    DT_NOGRAPHIC,
> -    DT_NONE,
>  } DisplayType;

thanks
-- PMM
Michael Tokarev - June 28, 2013, 11:29 a.m.
28.06.2013 15:24, Peter Maydell wrote:
> On 19 June 2013 13:34, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> It looks like initially there was -nographic option to turn
>> off display, now there's another option of the same sort,
>> -display none.  But code in other places of qemu checks for
>> DT_NOGRAPHIC and does not work well with -display none.
>> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
>> and check for that in all other places where previously we
>> checked for DT_NOGRAPHIC.
>>
>> While at it, rename two private variants of display (DT_DEFAULT
>> and DT_NOGRAPHIC) to use two underscores and make them negative,
>> and set DT_NONE to 0.
>>
>> This should fix the issue of non-working sun serial console
>> with the suggested replacement of -nographic which is
>> -display none.
> 
> Note that "-display none" and "-nographic" aren't exactly
> equivalent -- the latter is an option which turns on a bunch
> of behaviour including but not limited to "-display none".

Exactly.  See ab51b1d568e02c80b1abf9016bda3a86dc1db389
for a bit more context of this.

>> I'm not still sure we really want to check for display type
>> in qemu-char.c where we allow/disallow signals delivery from
>> terminal, -- for other display types (CURSES) this makes no
>> good sense.
> 
> ...in particular I don't think "-display none" should
> mean "don't allow ctrl-c" (though -nographic should
> continue to have that effect), and this patch currently
> introduces that behaviour change.

As Anthony said before, -nographic is legacy.  So there should
be some more modern way to control this.  That's exactly the
change which I don't like myself.  But "don't allow ctrl-c"
which is currently bound to -nographic is equally wrong.

>> +    DT__DEFAULT = -1,   /* private */
> I think these could use a slightly longer comment than just "private",
> eg "private, used internally by vl.c only".

Okay.
Peter Maydell - June 28, 2013, 11:34 a.m.
On 28 June 2013 12:29, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 28.06.2013 15:24, Peter Maydell wrote:
>> ...in particular I don't think "-display none" should
>> mean "don't allow ctrl-c" (though -nographic should
>> continue to have that effect), and this patch currently
>> introduces that behaviour change.
>
> As Anthony said before, -nographic is legacy.  So there should
> be some more modern way to control this.  That's exactly the
> change which I don't like myself.  But "don't allow ctrl-c"
> which is currently bound to -nographic is equally wrong.

All I'm saying is that I use -display none and I like that
it defaults to "ctrl-c works and kills qemu" and I don't
want you to break that :-)

thanks
-- PMM
Michael Tokarev - June 28, 2013, 11:43 a.m.
28.06.2013 15:34, Peter Maydell wrote:
> On 28 June 2013 12:29, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> 28.06.2013 15:24, Peter Maydell wrote:
>>> ...in particular I don't think "-display none" should
>>> mean "don't allow ctrl-c" (though -nographic should
>>> continue to have that effect), and this patch currently
>>> introduces that behaviour change.
>>
>> As Anthony said before, -nographic is legacy.  So there should
>> be some more modern way to control this.  That's exactly the
>> change which I don't like myself.  But "don't allow ctrl-c"
>> which is currently bound to -nographic is equally wrong.
> 
> All I'm saying is that I use -display none and I like that
> it defaults to "ctrl-c works and kills qemu" and I don't
> want you to break that :-)

I'm not.  Code in qemu-char.c:

static bool stdio_allow_signal;

static void qemu_chr_set_echo_stdio(CharDriverState *chr, bool echo)
{
    ...
    /* if graphical mode, we allow Ctrl-C handling */
    if (!stdio_allow_signal)
        tty.c_lflag &= ~ISIG;
    ...
}

static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
{
    ...
    stdio_allow_signal = display_type != DT_NOGRAPHIC;
    if (opts->has_signal) {
        stdio_allow_signal = opts->signal;
    }
    ...
}


Note it is used only for stdio char device, like -serial stdio,
so if you _just_ use -display none, without -serial stdio, you
wont notice a change.

And note that original intention isn't exactly clear, either.
How it is related with, say, curses display which needs raw
keypresses?

Adding Paolo who wrote that code in bb002513.

Thanks,

/mjt
Andreas Färber - June 28, 2013, 11:45 a.m.
Am 28.06.2013 13:29, schrieb Michael Tokarev:
> 28.06.2013 15:24, Peter Maydell wrote:
>> On 19 June 2013 13:34, Michael Tokarev <mjt@tls.msk.ru> wrote:
>>> It looks like initially there was -nographic option to turn
>>> off display, now there's another option of the same sort,
>>> -display none.  But code in other places of qemu checks for
>>> DT_NOGRAPHIC and does not work well with -display none.
>>> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
>>> and check for that in all other places where previously we
>>> checked for DT_NOGRAPHIC.
>>>
>>> While at it, rename two private variants of display (DT_DEFAULT
>>> and DT_NOGRAPHIC) to use two underscores and make them negative,
>>> and set DT_NONE to 0.
>>>
>>> This should fix the issue of non-working sun serial console
>>> with the suggested replacement of -nographic which is
>>> -display none.
>>
>> Note that "-display none" and "-nographic" aren't exactly
>> equivalent -- the latter is an option which turns on a bunch
>> of behaviour including but not limited to "-display none".
> 
> Exactly.  See ab51b1d568e02c80b1abf9016bda3a86dc1db389
> for a bit more context of this.
> 
>>> I'm not still sure we really want to check for display type
>>> in qemu-char.c where we allow/disallow signals delivery from
>>> terminal, -- for other display types (CURSES) this makes no
>>> good sense.
>>
>> ...in particular I don't think "-display none" should
>> mean "don't allow ctrl-c" (though -nographic should
>> continue to have that effect), and this patch currently
>> introduces that behaviour change.
> 
> As Anthony said before, -nographic is legacy.  So there should
> be some more modern way to control this.  That's exactly the
> change which I don't like myself.  

> But "don't allow ctrl-c"
> which is currently bound to -nographic is equally wrong.

What's wrong about that? Isn't Ctrl+C passed through to the guest in
-nographic mode? I don't see how any other mode inclusing daemonize
would need that.

Andreas

> 
>>> +    DT__DEFAULT = -1,   /* private */
>> I think these could use a slightly longer comment than just "private",
>> eg "private, used internally by vl.c only".
> 
> Okay.
> 
>
Peter Maydell - June 28, 2013, 11:50 a.m.
On 28 June 2013 12:43, Michael Tokarev <mjt@tls.msk.ru> wrote:
> Note it is used only for stdio char device, like -serial stdio,
> so if you _just_ use -display none, without -serial stdio, you
> wont notice a change.

Yes, I use "-display none -serial stdio".

-- PMM
Michael Tokarev - June 28, 2013, 11:50 a.m.
28.06.2013 15:45, Andreas Färber пишет:
> Am 28.06.2013 13:29, schrieb Michael Tokarev:
>> 28.06.2013 15:24, Peter Maydell wrote:
[]
>>> ...in particular I don't think "-display none" should
>>> mean "don't allow ctrl-c" (though -nographic should
>>> continue to have that effect), and this patch currently
>>> introduces that behaviour change.
>>
>> As Anthony said before, -nographic is legacy.  So there should
>> be some more modern way to control this.  That's exactly the
>> change which I don't like myself.  
> 
>> But "don't allow ctrl-c"
>> which is currently bound to -nographic is equally wrong.
> 
> What's wrong about that? Isn't Ctrl+C passed through to the guest in
> -nographic mode? I don't see how any other mode inclusing daemonize
> would need that.

Um. With either -nographic or -display none, there's no "display"
per se, and it is the "display" who relays keypresses and such into
guest.  Without display, the guest becomes headless completely, not
only it does not have a monitor of a video card, but also does not
have keyboard or mouse or other similar stuff.  Or it may have these,
but you can't "touch" neither keyboard nor mouse because you don't
"see" them without a display.  Fun thing but here we go.

This ctrl+c handling is only about when you explicitly redirected
some other char device to guest, such as serial port.  Which don't
have much to do with display I think, hence I don't understand the
logic here.

Thanks,

/mjt
Peter Maydell - June 28, 2013, 11:55 a.m.
On 28 June 2013 12:50, Michael Tokarev <mjt@tls.msk.ru> wrote:
> Um. With either -nographic or -display none, there's no "display"
> per se, and it is the "display" who relays keypresses and such into
> guest.  Without display, the guest becomes headless completely, not
> only it does not have a monitor of a video card, but also does not
> have keyboard or mouse or other similar stuff.  Or it may have these,
> but you can't "touch" neither keyboard nor mouse because you don't
> "see" them without a display.  Fun thing but here we go.
>
> This ctrl+c handling is only about when you explicitly redirected
> some other char device to guest, such as serial port.  Which don't
> have much to do with display I think, hence I don't understand the
> logic here.

The point is that one of the things -nographic does, as well
as disabling the graphics display, is to redirect the serial
port (among other things) to stdio. That's why there's code
in the char backend that cares about "did you say -nographic":
because -nographic means "no graphic display, serial port on
terminal, send ctrl-c in terminal to guest rather than killing
qemu, [some other stuff]".

It would be nice to be able to say "-nographic is equivalent to
'-display none -serial stdio -disable-ctrl-c -other-things'"
but I'm not sure exactly what the -other-things are or even
if we can set them all on the command line specifically.

-- PMM
Andreas Färber - June 28, 2013, 11:56 a.m.
Am 28.06.2013 13:50, schrieb Michael Tokarev:
> 28.06.2013 15:45, Andreas Färber пишет:
>> Am 28.06.2013 13:29, schrieb Michael Tokarev:
>>> 28.06.2013 15:24, Peter Maydell wrote:
> []
>>>> ...in particular I don't think "-display none" should
>>>> mean "don't allow ctrl-c" (though -nographic should
>>>> continue to have that effect), and this patch currently
>>>> introduces that behaviour change.
>>>
>>> As Anthony said before, -nographic is legacy.  So there should
>>> be some more modern way to control this.  That's exactly the
>>> change which I don't like myself.  
>>
>>> But "don't allow ctrl-c"
>>> which is currently bound to -nographic is equally wrong.
>>
>> What's wrong about that? Isn't Ctrl+C passed through to the guest in
>> -nographic mode? I don't see how any other mode inclusing daemonize
>> would need that.
> 
> Um. With either -nographic or -display none, there's no "display"
> per se, and it is the "display" who relays keypresses and such into
> guest.  Without display, the guest becomes headless completely, not
> only it does not have a monitor of a video card, but also does not
> have keyboard or mouse or other similar stuff.  Or it may have these,
> but you can't "touch" neither keyboard nor mouse because you don't
> "see" them without a display.  Fun thing but here we go.
> 
> This ctrl+c handling is only about when you explicitly redirected
> some other char device to guest, such as serial port.  Which don't
> have much to do with display I think, hence I don't understand the
> logic here.

The logic is that a) -nographic does have serial I/O on stdio and b)
emulated serial ports may get repurposed (change order/usage) for this
to work. CC'ing Alex and Blue who might remember more details.

So in the end it boils down to whether we consider stdio a "display" and
whether we may want to split this out into its own global variable to
cleanly separate it from graphical DT_* options.

Andreas

> 
> Thanks,
> 
> /mjt
>
Andreas Färber - June 28, 2013, 12:05 p.m.
Am 28.06.2013 13:50, schrieb Michael Tokarev:
> 28.06.2013 15:45, Andreas Färber пишет:
>> Am 28.06.2013 13:29, schrieb Michael Tokarev:
>>> 28.06.2013 15:24, Peter Maydell wrote:
> []
>>>> ...in particular I don't think "-display none" should
>>>> mean "don't allow ctrl-c" (though -nographic should
>>>> continue to have that effect), and this patch currently
>>>> introduces that behaviour change.
>>>
>>> As Anthony said before, -nographic is legacy.  So there should
>>> be some more modern way to control this.  That's exactly the
>>> change which I don't like myself.  
>>
>>> But "don't allow ctrl-c"
>>> which is currently bound to -nographic is equally wrong.
>>
>> What's wrong about that? Isn't Ctrl+C passed through to the guest in
>> -nographic mode? I don't see how any other mode inclusing daemonize
>> would need that.
> 
> Um. With either -nographic or -display none, there's no "display"
> per se, and it is the "display" who relays keypresses and such into
> guest.  Without display, the guest becomes headless completely, not
> only it does not have a monitor of a video card, but also does not
> have keyboard or mouse or other similar stuff.  Or it may have these,
> but you can't "touch" neither keyboard nor mouse because you don't
> "see" them without a display.  Fun thing but here we go.

BTW just try it out using the following to see for yourself:

$ qemu-system-ppc -nographic

should get you to an interactive OpenBIOS prompt. Same for sparc.
This involves communicating to firmware that we are in -nographic mode,
which then redirects its output to serial rather then VGA (think of
sgabios in x86 terms).

Andreas

> 
> This ctrl+c handling is only about when you explicitly redirected
> some other char device to guest, such as serial port.  Which don't
> have much to do with display I think, hence I don't understand the
> logic here.
> 
> Thanks,
> 
> /mjt
>
Michael Tokarev - June 28, 2013, 12:05 p.m.
28.06.2013 15:55, Peter Maydell wrote:
> On 28 June 2013 12:50, Michael Tokarev <mjt@tls.msk.ru> wrote:

>> This ctrl+c handling is only about when you explicitly redirected
>> some other char device to guest, such as serial port.  Which don't
>> have much to do with display I think, hence I don't understand the
>> logic here.
> 
> The point is that one of the things -nographic does, as well
> as disabling the graphics display, is to redirect the serial
> port (among other things) to stdio. That's why there's code
> in the char backend that cares about "did you say -nographic":
> because -nographic means "no graphic display, serial port on
> terminal, send ctrl-c in terminal to guest rather than killing
> qemu, [some other stuff]".

That's exactly why I don't think looking at -nographic here in
serial code is wrong.  It should do the same regardless of
-nographic - if, say, serial is redirected to stdio, it should
always pass Ctrl+C to guest instead of killing it.  So I'm
not really sure we should test for -display none here, either.

> It would be nice to be able to say "-nographic is equivalent to
> '-display none -serial stdio -disable-ctrl-c -other-things'"
> but I'm not sure exactly what the -other-things are or even
> if we can set them all on the command line specifically.

We have some code in sun4 which also enabled serial ports
differently with and without -nographic, maybe because of
the same thing (which is what this all is about!).

And there's also another place, passing this NOGRAPHIC thing
to bios.

So far that's all.  With chardev you can explicitly control
Ctrl+C behavour using signal={on|off} attribute.


28.06.2013 15:56, Andreas Färber wrote:
[]
> The logic is that a) -nographic does have serial I/O on stdio and b)
> emulated serial ports may get repurposed (change order/usage) for this
> to work. CC'ing Alex and Blue who might remember more details.
>
> So in the end it boils down to whether we consider stdio a "display" and
> whether we may want to split this out into its own global variable to
> cleanly separate it from graphical DT_* options.

This is still wrong because it works differently if we explicitly
redirected serial port to stdio and used -display none, or it was
due to -nographic.



Thanks,

/mjt
Paolo Bonzini - June 28, 2013, 12:06 p.m.
Il 28/06/2013 14:05, Michael Tokarev ha scritto:
> That's exactly why I don't think looking at -nographic here in
> serial code is wrong.  It should do the same regardless of
> -nographic - if, say, serial is redirected to stdio, it should
> always pass Ctrl+C to guest instead of killing it.  So I'm
> not really sure we should test for -display none here, either.

See the patch I just sent.

>> > It would be nice to be able to say "-nographic is equivalent to
>> > '-display none -serial stdio -disable-ctrl-c -other-things'"
>> > but I'm not sure exactly what the -other-things are or even
>> > if we can set them all on the command line specifically.
> We have some code in sun4 which also enabled serial ports
> differently with and without -nographic, maybe because of
> the same thing (which is what this all is about!).
> 
> And there's also another place, passing this NOGRAPHIC thing
> to bios.
> 
> So far that's all.  With chardev you can explicitly control
> Ctrl+C behavour using signal={on|off} attribute.

Unfortunately, you cannot use -chardev for the vast majority of boards
(all those that have no ISA/PCI/virtio).

Paolo
Peter Maydell - June 28, 2013, 12:09 p.m.
On 28 June 2013 13:05, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 28.06.2013 15:55, Peter Maydell wrote:
>> The point is that one of the things -nographic does, as well
>> as disabling the graphics display, is to redirect the serial
>> port (among other things) to stdio. That's why there's code
>> in the char backend that cares about "did you say -nographic":
>> because -nographic means "no graphic display, serial port on
>> terminal, send ctrl-c in terminal to guest rather than killing
>> qemu, [some other stuff]".
>
> That's exactly why I don't think looking at -nographic here in
> serial code is wrong.  It should do the same regardless of
> -nographic - if, say, serial is redirected to stdio, it should
> always pass Ctrl+C to guest instead of killing it.  So I'm
> not really sure we should test for -display none here, either.

No, I do not want "-serial stdio" to mean "and also stop
ctrl-c killing QEMU". If you want that you should have to
specify it specifically (or if you say -nographic it should
happen by the code in vl.c opening the serial backend with
the right options).

-- PMM
Paolo Bonzini - June 28, 2013, 12:11 p.m.
Il 28/06/2013 14:05, Andreas Färber ha scritto:
> BTW just try it out using the following to see for yourself:
> 
> $ qemu-system-ppc -nographic
> 
> should get you to an interactive OpenBIOS prompt. Same for sparc.
> This involves communicating to firmware that we are in -nographic mode,
> which then redirects its output to serial rather then VGA (think of
> sgabios in x86 terms).

Is this FW_CFG_NOGRAPHIC?  This is really a good usecase for making the
machine a Device, so you can control it with -global.  It can be useful
even if you do have a VGA attached.

Paolo
Anthony Liguori - July 9, 2013, 6:37 p.m.
Michael Tokarev <mjt@tls.msk.ru> writes:

> It looks like initially there was -nographic option to turn
> off display, now there's another option of the same sort,
> -display none.  But code in other places of qemu checks for
> DT_NOGRAPHIC and does not work well with -display none.
> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
> and check for that in all other places where previously we
> checked for DT_NOGRAPHIC.
>
> While at it, rename two private variants of display (DT_DEFAULT
> and DT_NOGRAPHIC) to use two underscores and make them negative,
> and set DT_NONE to 0.
>
> This should fix the issue of non-working sun serial console
> with the suggested replacement of -nographic which is
> -display none.
>
> I'm not still sure we really want to check for display type
> in qemu-char.c where we allow/disallow signals delivery from
> terminal, -- for other display types (CURSES) this makes no
> good sense.
>
> If the fix is correct, it is a stable material.

Breaks make check:

main-loop: WARNING: I/O thread spun for 1000 iterations
**
ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b

Regards,

Anthony Liguori

>
> Cc: Todd T. Fries <todd@fries.net>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  hw/lm32/milkymist-hw.h  |    2 +-
>  hw/nvram/fw_cfg.c       |    2 +-
>  hw/sparc/sun4m.c        |    2 +-
>  include/sysemu/sysemu.h |    6 +++---
>  qemu-char.c             |    4 ++--
>  vl.c                    |   15 +++++++--------
>  6 files changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h
> index 5317ce6..59af720 100644
> --- a/hw/lm32/milkymist-hw.h
> +++ b/hw/lm32/milkymist-hw.h
> @@ -107,7 +107,7 @@ static inline DeviceState *milkymist_tmu2_create(hwaddr base,
>      int nelements;
>      int ver_major, ver_minor;
>  
> -    if (display_type == DT_NOGRAPHIC) {
> +    if (display_type == DT_NONE) {
>          return NULL;
>      }
>  
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 3c255ce..b3d163a 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -510,7 +510,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
>      }
>      fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4);
>      fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16);
> -    fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));
> +    fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NONE));
>      fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
>      fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
>      fw_cfg_bootsplash(s);
> diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
> index 0e86ca7..c1d42ec 100644
> --- a/hw/sparc/sun4m.c
> +++ b/hw/sparc/sun4m.c
> @@ -919,7 +919,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
>      slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
>  
>      slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
> -                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
> +                              display_type == DT_NONE, ESCC_CLOCK, 1);
>      /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
>         Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
>      escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 2fb71af..fba7a7a 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -87,12 +87,12 @@ void do_info_slirp(Monitor *mon);
>  
>  typedef enum DisplayType
>  {
> -    DT_DEFAULT,
> +    DT__DEFAULT = -1,   /* private */
> +    DT__NOGRAPHIC = -2, /* private */
> +    DT_NONE = 0,
>      DT_CURSES,
>      DT_SDL,
>      DT_GTK,
> -    DT_NOGRAPHIC,
> -    DT_NONE,
>  } DisplayType;
>  
>  extern int autostart;
> diff --git a/qemu-char.c b/qemu-char.c
> index 2c3cfe6..3434971 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -955,7 +955,7 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
>      chr = qemu_chr_open_fd(0, 1);
>      chr->chr_close = qemu_chr_close_stdio;
>      chr->chr_set_echo = qemu_chr_set_echo_stdio;
> -    stdio_allow_signal = display_type != DT_NOGRAPHIC;
> +    stdio_allow_signal = display_type != DT_NONE;
>      if (opts->has_signal) {
>          stdio_allow_signal = opts->signal;
>      }
> @@ -3066,7 +3066,7 @@ static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend,
>      backend->stdio = g_new0(ChardevStdio, 1);
>      backend->stdio->has_signal = true;
>      backend->stdio->signal =
> -        qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC);
> +        qemu_opt_get_bool(opts, "signal", display_type != DT_NONE);
>  }
>  
>  static void qemu_chr_parse_serial(QemuOpts *opts, ChardevBackend *backend,
> diff --git a/vl.c b/vl.c
> index f94ec9c..0269965 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -183,7 +183,7 @@ static const char *data_dir[16];
>  static int data_dir_idx;
>  const char *bios_name = NULL;
>  enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
> -DisplayType display_type = DT_DEFAULT;
> +DisplayType display_type = DT__DEFAULT;
>  static int display_remote;
>  const char* keyboard_layout = NULL;
>  ram_addr_t ram_size;
> @@ -2152,7 +2152,7 @@ static void select_vgahw (const char *p)
>  static DisplayType select_display(const char *p)
>  {
>      const char *opts;
> -    DisplayType display = DT_DEFAULT;
> +    DisplayType display = DT__DEFAULT;
>  
>      if (strstart(p, "sdl", &opts)) {
>  #ifdef CONFIG_SDL
> @@ -3093,7 +3093,7 @@ int main(int argc, char **argv, char **envp)
>                  display_type = select_display(optarg);
>                  break;
>              case QEMU_OPTION_nographic:
> -                display_type = DT_NOGRAPHIC;
> +                display_type = DT__NOGRAPHIC;
>                  break;
>              case QEMU_OPTION_curses:
>  #ifdef CONFIG_CURSES
> @@ -4018,7 +4018,7 @@ int main(int argc, char **argv, char **envp)
>           * -nographic _and_ redirects all ports explicitly - this is valid
>           * usage, -nographic is just a no-op in this case.
>           */
> -        if (display_type == DT_NOGRAPHIC
> +        if (display_type == DT__NOGRAPHIC
>              && (default_parallel || default_serial
>                  || default_monitor || default_virtcon)) {
>              fprintf(stderr, "-nographic can not be used with -daemonize\n");
> @@ -4032,7 +4032,8 @@ int main(int argc, char **argv, char **envp)
>  #endif
>      }
>  
> -    if (display_type == DT_NOGRAPHIC) {
> +    if (display_type == DT__NOGRAPHIC) {
> +        display_type = DT_NONE;
>          if (default_parallel)
>              add_device_config(DEV_PARALLEL, "null");
>          if (default_serial && default_monitor) {
> @@ -4066,7 +4067,7 @@ int main(int argc, char **argv, char **envp)
>          }
>      }
>  
> -    if (display_type == DT_DEFAULT && !display_remote) {
> +    if (display_type == DT__DEFAULT && !display_remote) {
>  #if defined(CONFIG_GTK)
>          display_type = DT_GTK;
>  #elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
> @@ -4333,8 +4334,6 @@ int main(int argc, char **argv, char **envp)
>  
>      /* init local displays */
>      switch (display_type) {
> -    case DT_NOGRAPHIC:
> -        break;
>  #if defined(CONFIG_CURSES)
>      case DT_CURSES:
>          curses_display_init(ds, full_screen);
> -- 
> 1.7.10.4
Michael Tokarev - July 9, 2013, 7 p.m.
09.07.2013 22:37, Anthony Liguori wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
> 
>> It looks like initially there was -nographic option to turn
>> off display, now there's another option of the same sort,
>> -display none.  But code in other places of qemu checks for
>> DT_NOGRAPHIC and does not work well with -display none.
>> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
>> and check for that in all other places where previously we
>> checked for DT_NOGRAPHIC.
[]
> Breaks make check:
> 
> main-loop: WARNING: I/O thread spun for 1000 iterations
> **
> ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
> GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b

Sure, because the test is bogus.  Should I remove this bogus test?

Thanks,

/mjt
Anthony Liguori - July 9, 2013, 8:45 p.m.
Michael Tokarev <mjt@tls.msk.ru> writes:

> 09.07.2013 22:37, Anthony Liguori wrote:
>> Michael Tokarev <mjt@tls.msk.ru> writes:
>> 
>>> It looks like initially there was -nographic option to turn
>>> off display, now there's another option of the same sort,
>>> -display none.  But code in other places of qemu checks for
>>> DT_NOGRAPHIC and does not work well with -display none.
>>> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
>>> and check for that in all other places where previously we
>>> checked for DT_NOGRAPHIC.
> []
>> Breaks make check:
>> 
>> main-loop: WARNING: I/O thread spun for 1000 iterations
>> **
>> ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
>> GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b
>
> Sure, because the test is bogus.

No, it's a guest ABI.  You cannot change the guest ABI.

-display none != -nographic.

nographic gives you -display none plus a stdio serial port (with muxing
magic).

-display none should not imply stdio serial port.  The vc goes to a
dummy display.  That's a major semantic difference.

Regards,

Anthony Liguori

> Should I remove this bogus test?
>
> Thanks,
>
> /mjt
Peter Maydell - July 9, 2013, 9:18 p.m.
On 9 July 2013 21:45, Anthony Liguori <aliguori@us.ibm.com> wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
>> 09.07.2013 22:37, Anthony Liguori wrote:
>>> ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
>>> GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b
>>
>> Sure, because the test is bogus.
>
> No, it's a guest ABI.  You cannot change the guest ABI.

Why the heck are we telling the guest that the user
specified -nographic anyhow? It's a dumb guest ABI...

> -display none != -nographic.
>
> nographic gives you -display none plus a stdio serial port (with muxing
> magic).
>
> -display none should not imply stdio serial port.  The vc goes to a
> dummy display.  That's a major semantic difference.

None of these semantics have changed AFAICT.

-- PMM
Anthony Liguori - July 9, 2013, 9:24 p.m.
Peter Maydell <peter.maydell@linaro.org> writes:

> On 9 July 2013 21:45, Anthony Liguori <aliguori@us.ibm.com> wrote:
>> Michael Tokarev <mjt@tls.msk.ru> writes:
>>> 09.07.2013 22:37, Anthony Liguori wrote:
>>>> ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
>>>> GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b
>>>
>>> Sure, because the test is bogus.
>>
>> No, it's a guest ABI.  You cannot change the guest ABI.
>
> Why the heck are we telling the guest that the user
> specified -nographic anyhow? It's a dumb guest ABI...

I believe OpenBIOS uses this to determine if it should display messages
on serial or on the graphic display.

It's actually a useful ABI in that regard.

Regards,

Anthony Liguori

>> -display none != -nographic.
>>
>> nographic gives you -display none plus a stdio serial port (with muxing
>> magic).
>>
>> -display none should not imply stdio serial port.  The vc goes to a
>> dummy display.  That's a major semantic difference.
>
> None of these semantics have changed AFAICT.
>
> -- PMM
Peter Maydell - July 9, 2013, 9:36 p.m.
On 9 July 2013 22:24, Anthony Liguori <aliguori@us.ibm.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>> Why the heck are we telling the guest that the user
>> specified -nographic anyhow? It's a dumb guest ABI...
>
> I believe OpenBIOS uses this to determine if it should display messages
> on serial or on the graphic display.
>
> It's actually a useful ABI in that regard.

OK, I might go for "useful but misnamed"; we should
presumably have a command line option to set it
cleanly (ie independently of display type), and add
that to the list of random things -nographic does...

-- PMM
Anthony Liguori - July 9, 2013, 10:03 p.m.
Peter Maydell <peter.maydell@linaro.org> writes:

> On 9 July 2013 22:24, Anthony Liguori <aliguori@us.ibm.com> wrote:
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>> Why the heck are we telling the guest that the user
>>> specified -nographic anyhow? It's a dumb guest ABI...
>>
>> I believe OpenBIOS uses this to determine if it should display messages
>> on serial or on the graphic display.
>>
>> It's actually a useful ABI in that regard.
>
> OK, I might go for "useful but misnamed"; we should
> presumably have a command line option to set it
> cleanly (ie independently of display type), and add
> that to the list of random things -nographic does...

I wouldn't be opposed to that but whatever we do, it should be
documented and should not break 'make check'.

Regards,

Anthony Liguori

>
> -- PMM
Michael Tokarev - July 10, 2013, 4:18 a.m.
10.07.2013 00:45, Anthony Liguori wrote:
> Michael Tokarev <mjt@tls.msk.ru> writes:
> 
>> 09.07.2013 22:37, Anthony Liguori wrote:
>>> Michael Tokarev <mjt@tls.msk.ru> writes:
>>>
>>>> It looks like initially there was -nographic option to turn
>>>> off display, now there's another option of the same sort,
>>>> -display none.  But code in other places of qemu checks for
>>>> DT_NOGRAPHIC and does not work well with -display none.
>>>> Make DT_NOGRAPHIC an internal version which selects DT_NONE,
>>>> and check for that in all other places where previously we
>>>> checked for DT_NOGRAPHIC.
>> []
>>> Breaks make check:
>>>
>>> main-loop: WARNING: I/O thread spun for 1000 iterations
>>> **
>>> ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
>>> GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b
>>
>> Sure, because the test is bogus.
> 
> No, it's a guest ABI.  You cannot change the guest ABI.
> 
> -display none != -nographic.
> 
> nographic gives you -display none plus a stdio serial port (with muxing
> magic).
> 
> -display none should not imply stdio serial port.  The vc goes to a
> dummy display.  That's a major semantic difference.

So we're back to the original bugreport by Todd Fries -- apparently
all my attempts to describe the proposed ways to change it failed.

Note that -nographics does NOT imply a serial port either, because it
can be redirected elsewhere.

/mjt
Michael Tokarev - July 10, 2013, 4:45 a.m.
10.07.2013 01:24, Anthony Liguori wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
> 
>> On 9 July 2013 21:45, Anthony Liguori <aliguori@us.ibm.com> wrote:
>>> Michael Tokarev <mjt@tls.msk.ru> writes:
>>>> 09.07.2013 22:37, Anthony Liguori wrote:
>>>>> ERROR:/home/aliguori/git/qemu/tests/fw_cfg-test.c:63:test_fw_cfg_nographic: assertion failed (qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC) == 0): (1 == 0)
>>>>> GTester: last random seed: R02S25031265f05e4d41efcf758c9ef6043b
>>>>
>>>> Sure, because the test is bogus.
>>>
>>> No, it's a guest ABI.  You cannot change the guest ABI.
>>
>> Why the heck are we telling the guest that the user
>> specified -nographic anyhow? It's a dumb guest ABI...
> 
> I believe OpenBIOS uses this to determine if it should display messages
> on serial or on the graphic display.

This is actually exactly the thing this very patch changes: it stops
relying on -nographics and passes -display none to the bios/firmware
instead.  And the documentation has been updated accordingly, also in
this very patch:

hw/nvram/fw_cfg.c
-    fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));
+    fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NONE));

hw/sparc/sun4m.c
     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
-                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
+                              display_type == DT_NONE, ESCC_CLOCK, 1);

qemu-options.hx

 @item none
 Do not display video output. The guest will still see an emulated
 graphics card, but its output will not be displayed to the QEMU
-user. This option differs from the -nographic option in that it
+user.  The fact that we have no display is passed to firmware and
+affects a few other places depending on the target architecture,
+like switching console output to serial console or disabling keyboard
+input.
+
+This option differs from the -nographic option in that it
 only affects what is done with video output; -nographic also changes
 the destination of the serial and parallel port data.


Besides, -- I just noticed -- we're discussing a V1 of this patch,
while I already sent a v3, -- it has a much more appropriate logic
for the Ctrl+C handling.  The only issue I see with it is the make
check breakage which is easy to fix by s/==0/==1/.

Thanks,

/mjt
Michael Tokarev - July 10, 2013, 5:08 a.m.
10.07.2013 08:45, Michael Tokarev wrote:
[]
> Besides, -- I just noticed -- we're discussing a V1 of this patch,
> while I already sent a v3, -- it has a much more appropriate logic
> for the Ctrl+C handling.  The only issue I see with it is the make
> check breakage which is easy to fix by s/==0/==1/.

I updated the git branch on my site --

 http://git.corpit.ru/?p=qemu.git;a=shortlog;h=refs/heads/mjt-dt-nographic

(two patches on the top).  This now includes the `make check' fix by
flipping the check (FW_CFG_NOGRAPHIC==1 vs ==0), more documentation
rewording (suggested by Peter) and Reviewed-by tags.

And yes, I dislike this mess too -- neither -nographic nor -display none
should be tied with guest serial port.  Better approach for the Ctrl+C
handling has been proposed by pbonzini. Better suggestions for FW_CFG_NOGRAPHIC
welcome.  Maybe something like -serial-console (linux has console=ttyS0,tty1)
which will be turned on by -nographic and which will be passed to firmware
as FW_CFG_NOGRAPHIC, and which can be used in -serial none case to check for
sanity.  But actually, -display none isn't that bad of a choice here (and
maybe we may also enforce non-none serial in case of -display none).

Thanks,

/mjt
Michael Tokarev - July 16, 2013, 11:10 a.m.
10.07.2013 02:03, Anthony Liguori wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
> 
>> On 9 July 2013 22:24, Anthony Liguori <aliguori@us.ibm.com> wrote:
>>> Peter Maydell <peter.maydell@linaro.org> writes:
>>>> Why the heck are we telling the guest that the user
>>>> specified -nographic anyhow? It's a dumb guest ABI...
>>>
>>> I believe OpenBIOS uses this to determine if it should display messages
>>> on serial or on the graphic display.
>>>
>>> It's actually a useful ABI in that regard.
>>
>> OK, I might go for "useful but misnamed"; we should
>> presumably have a command line option to set it
>> cleanly (ie independently of display type), and add
>> that to the list of random things -nographic does...
> 
> I wouldn't be opposed to that but whatever we do, it should be
> documented and should not break 'make check'.

So, what do we do now? Ping:

http://git.corpit.ru/?p=qemu.git;a=shortlog;h=refs/heads/mjt-dt-nographic

/mjt
Peter Maydell - July 16, 2013, 11:35 a.m.
On 10 July 2013 06:08, Michael Tokarev <mjt@tls.msk.ru> wrote:
> I updated the git branch on my site --
>
>  http://git.corpit.ru/?p=qemu.git;a=shortlog;h=refs/heads/mjt-dt-nographic
>
> (two patches on the top).  This now includes the `make check' fix by
> flipping the check (FW_CFG_NOGRAPHIC==1 vs ==0), more documentation
> rewording (suggested by Peter) and Reviewed-by tags.
>
> And yes, I dislike this mess too -- neither -nographic nor -display none
> should be tied with guest serial port.  Better approach for the Ctrl+C
> handling has been proposed by pbonzini. Better suggestions for FW_CFG_NOGRAPHIC
> welcome.  Maybe something like -serial-console (linux has console=ttyS0,tty1)
> which will be turned on by -nographic and which will be passed to firmware
> as FW_CFG_NOGRAPHIC, and which can be used in -serial none case to check for
> sanity.  But actually, -display none isn't that bad of a choice here (and
> maybe we may also enforce non-none serial in case of -display none).

I think "-display none" should just mean "I didn't plug the monitor in":
it should have no effect at all on the guest (or on the way we emulate
or configure any other of our devices) -- it's just that graphics output
doesn't go anywhere. So the test case is correct (the test was started
with '-display none' and this shouldn't result in the FW_CFG_NOGRAPHIC
bit being set) and we need to make QEMU behave correctly (ie by tying
that FW_CFG_ setting to something other than display=none).

On a similar line of thought:
* milkymist_tmu2_create() should definitely not be doing the X probing
  if DT_NONE, but it should ideally still create the milkymist-tmu2 device.
  This is hard though because the device itself basically assumes it can
  use all the OpenGL APIs. So I think the change in your patch is as
  good as we're going to get.
* I'm not convinced we should need to disable the sparc keyboard
  if DT_NONE -- shouldn't this just work as if you had a physical
  keyboard plugged in but never typed anything on it? (Or does
  real hardware use "keyboard plugged in" to decide something?)

thanks
-- PMM

Patch

diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h
index 5317ce6..59af720 100644
--- a/hw/lm32/milkymist-hw.h
+++ b/hw/lm32/milkymist-hw.h
@@ -107,7 +107,7 @@  static inline DeviceState *milkymist_tmu2_create(hwaddr base,
     int nelements;
     int ver_major, ver_minor;
 
-    if (display_type == DT_NOGRAPHIC) {
+    if (display_type == DT_NONE) {
         return NULL;
     }
 
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 3c255ce..b3d163a 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -510,7 +510,7 @@  FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
     }
     fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4);
     fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16);
-    fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));
+    fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NONE));
     fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
     fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
     fw_cfg_bootsplash(s);
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 0e86ca7..c1d42ec 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -919,7 +919,7 @@  static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
     slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
 
     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
-                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
+                              display_type == DT_NONE, ESCC_CLOCK, 1);
     /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
        Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
     escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 2fb71af..fba7a7a 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -87,12 +87,12 @@  void do_info_slirp(Monitor *mon);
 
 typedef enum DisplayType
 {
-    DT_DEFAULT,
+    DT__DEFAULT = -1,   /* private */
+    DT__NOGRAPHIC = -2, /* private */
+    DT_NONE = 0,
     DT_CURSES,
     DT_SDL,
     DT_GTK,
-    DT_NOGRAPHIC,
-    DT_NONE,
 } DisplayType;
 
 extern int autostart;
diff --git a/qemu-char.c b/qemu-char.c
index 2c3cfe6..3434971 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -955,7 +955,7 @@  static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
     chr = qemu_chr_open_fd(0, 1);
     chr->chr_close = qemu_chr_close_stdio;
     chr->chr_set_echo = qemu_chr_set_echo_stdio;
-    stdio_allow_signal = display_type != DT_NOGRAPHIC;
+    stdio_allow_signal = display_type != DT_NONE;
     if (opts->has_signal) {
         stdio_allow_signal = opts->signal;
     }
@@ -3066,7 +3066,7 @@  static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend,
     backend->stdio = g_new0(ChardevStdio, 1);
     backend->stdio->has_signal = true;
     backend->stdio->signal =
-        qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC);
+        qemu_opt_get_bool(opts, "signal", display_type != DT_NONE);
 }
 
 static void qemu_chr_parse_serial(QemuOpts *opts, ChardevBackend *backend,
diff --git a/vl.c b/vl.c
index f94ec9c..0269965 100644
--- a/vl.c
+++ b/vl.c
@@ -183,7 +183,7 @@  static const char *data_dir[16];
 static int data_dir_idx;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
-DisplayType display_type = DT_DEFAULT;
+DisplayType display_type = DT__DEFAULT;
 static int display_remote;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
@@ -2152,7 +2152,7 @@  static void select_vgahw (const char *p)
 static DisplayType select_display(const char *p)
 {
     const char *opts;
-    DisplayType display = DT_DEFAULT;
+    DisplayType display = DT__DEFAULT;
 
     if (strstart(p, "sdl", &opts)) {
 #ifdef CONFIG_SDL
@@ -3093,7 +3093,7 @@  int main(int argc, char **argv, char **envp)
                 display_type = select_display(optarg);
                 break;
             case QEMU_OPTION_nographic:
-                display_type = DT_NOGRAPHIC;
+                display_type = DT__NOGRAPHIC;
                 break;
             case QEMU_OPTION_curses:
 #ifdef CONFIG_CURSES
@@ -4018,7 +4018,7 @@  int main(int argc, char **argv, char **envp)
          * -nographic _and_ redirects all ports explicitly - this is valid
          * usage, -nographic is just a no-op in this case.
          */
-        if (display_type == DT_NOGRAPHIC
+        if (display_type == DT__NOGRAPHIC
             && (default_parallel || default_serial
                 || default_monitor || default_virtcon)) {
             fprintf(stderr, "-nographic can not be used with -daemonize\n");
@@ -4032,7 +4032,8 @@  int main(int argc, char **argv, char **envp)
 #endif
     }
 
-    if (display_type == DT_NOGRAPHIC) {
+    if (display_type == DT__NOGRAPHIC) {
+        display_type = DT_NONE;
         if (default_parallel)
             add_device_config(DEV_PARALLEL, "null");
         if (default_serial && default_monitor) {
@@ -4066,7 +4067,7 @@  int main(int argc, char **argv, char **envp)
         }
     }
 
-    if (display_type == DT_DEFAULT && !display_remote) {
+    if (display_type == DT__DEFAULT && !display_remote) {
 #if defined(CONFIG_GTK)
         display_type = DT_GTK;
 #elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
@@ -4333,8 +4334,6 @@  int main(int argc, char **argv, char **envp)
 
     /* init local displays */
     switch (display_type) {
-    case DT_NOGRAPHIC:
-        break;
 #if defined(CONFIG_CURSES)
     case DT_CURSES:
         curses_display_init(ds, full_screen);