qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH v2] curses: don't initialize curses when qemu is daemonized
@ 2012-09-14 16:15 Hitoshi Mitake
  2012-09-22 16:06 ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Hitoshi Mitake @ 2012-09-14 16:15 UTC (permalink / raw)
  To: qemu-trivial; +Cc: Anthony Liguori, Andrzej Zaborowski, h.mitake

Current qemu initializes curses even if -daemonize option is
passed. This cause problem because shell prompt appears without
calling endwin().

This patch adds new function, is_daemonized(), to OS dependent
code. With this function, curses_display_init() can check that qemu is
daemonized or not. If daemonized, curses_display_init() isn't called
and the problem is avoided.

Of course, -daemonize && -curses doesn't make sense. Users shouldn't
pass the arguments at the same time. But the problem is very painful
because Ctrl-C cannot be delivered to the terminal.

Cc: Andrzej Zaborowski  <balrog@zabor.org>
Cc: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Hitoshi Mitake <h.mitake@gmail.com>
---

v2: is_daemonized() is now called in main(), not in curses_display_init()

8<---
 os-posix.c      |    5 +++++
 qemu-os-posix.h |    2 ++
 qemu-os-win32.h |    5 +++++
 vl.c            |    3 ++-
 4 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index 79fa228..99c5343 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -360,3 +360,8 @@ int qemu_create_pidfile(const char *filename)
     /* keep pidfile open & locked forever */
     return 0;
 }
+
+int is_daemonized(void)
+{
+    return daemonize;
+}
diff --git a/qemu-os-posix.h b/qemu-os-posix.h
index 8e1149d..0b2b60a 100644
--- a/qemu-os-posix.h
+++ b/qemu-os-posix.h
@@ -46,4 +46,6 @@ typedef struct timeval qemu_timeval;
 typedef struct timespec qemu_timespec;
 int qemu_utimens(const char *path, const qemu_timespec *times);
 
+int is_daemonized(void);
+
 #endif
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
index 753679b..08a6fa8 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -86,4 +86,9 @@ typedef struct {
 } qemu_timeval;
 int qemu_gettimeofday(qemu_timeval *tp);
 
+static inline int is_daemonized(void)
+{
+    return 0;
+}
+
 #endif
diff --git a/vl.c b/vl.c
index 7c577fa..463f39e 100644
--- a/vl.c
+++ b/vl.c
@@ -3657,7 +3657,8 @@ int main(int argc, char **argv, char **envp)
         break;
 #if defined(CONFIG_CURSES)
     case DT_CURSES:
-        curses_display_init(ds, full_screen);
+        if (!is_daemonized())
+	    curses_display_init(ds, full_screen);
         break;
 #endif
 #if defined(CONFIG_SDL)
-- 
1.7.5.1



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

* Re: [Qemu-trivial] [PATCH v2] curses: don't initialize curses when qemu is daemonized
  2012-09-14 16:15 [Qemu-trivial] [PATCH v2] curses: don't initialize curses when qemu is daemonized Hitoshi Mitake
@ 2012-09-22 16:06 ` Stefan Hajnoczi
  2012-09-22 16:19   ` Hitoshi Mitake
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-09-22 16:06 UTC (permalink / raw)
  To: Hitoshi Mitake; +Cc: qemu-trivial, Anthony Liguori, Andrzej Zaborowski

On Sat, Sep 15, 2012 at 01:15:41AM +0900, Hitoshi Mitake wrote:
> Current qemu initializes curses even if -daemonize option is
> passed. This cause problem because shell prompt appears without
> calling endwin().
> 
> This patch adds new function, is_daemonized(), to OS dependent
> code. With this function, curses_display_init() can check that qemu is
> daemonized or not. If daemonized, curses_display_init() isn't called
> and the problem is avoided.
> 
> Of course, -daemonize && -curses doesn't make sense. Users shouldn't
> pass the arguments at the same time. But the problem is very painful
> because Ctrl-C cannot be delivered to the terminal.
> 
> Cc: Andrzej Zaborowski  <balrog@zabor.org>
> Cc: Stefan Hajnoczi <stefanha@gmail.com>
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> Signed-off-by: Hitoshi Mitake <h.mitake@gmail.com>
> ---
> 
> v2: is_daemonized() is now called in main(), not in curses_display_init()
> 
> 8<---
>  os-posix.c      |    5 +++++
>  qemu-os-posix.h |    2 ++
>  qemu-os-win32.h |    5 +++++
>  vl.c            |    3 ++-
>  4 files changed, 14 insertions(+), 1 deletions(-)

There has been no further discussion so this patch is ready to go.  I
have fixed up the coding style issues - please use scripts/checkpatch.pl
next time (and see ./CODING_STYLE and ./HACKING).

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan


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

* Re: [Qemu-trivial] [PATCH v2] curses: don't initialize curses when qemu is daemonized
  2012-09-22 16:06 ` Stefan Hajnoczi
@ 2012-09-22 16:19   ` Hitoshi Mitake
  0 siblings, 0 replies; 3+ messages in thread
From: Hitoshi Mitake @ 2012-09-22 16:19 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-trivial, Anthony Liguori, Andrzej Zaborowski

On Sun, Sep 23, 2012 at 1:06 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Sat, Sep 15, 2012 at 01:15:41AM +0900, Hitoshi Mitake wrote:
>> Current qemu initializes curses even if -daemonize option is
>> passed. This cause problem because shell prompt appears without
>> calling endwin().
>>
>> This patch adds new function, is_daemonized(), to OS dependent
>> code. With this function, curses_display_init() can check that qemu is
>> daemonized or not. If daemonized, curses_display_init() isn't called
>> and the problem is avoided.
>>
>> Of course, -daemonize && -curses doesn't make sense. Users shouldn't
>> pass the arguments at the same time. But the problem is very painful
>> because Ctrl-C cannot be delivered to the terminal.
>>
>> Cc: Andrzej Zaborowski  <balrog@zabor.org>
>> Cc: Stefan Hajnoczi <stefanha@gmail.com>
>> Cc: Anthony Liguori <aliguori@us.ibm.com>
>> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
>> Signed-off-by: Hitoshi Mitake <h.mitake@gmail.com>
>> ---
>>
>> v2: is_daemonized() is now called in main(), not in curses_display_init()
>>
>> 8<---
>>  os-posix.c      |    5 +++++
>>  qemu-os-posix.h |    2 ++
>>  qemu-os-win32.h |    5 +++++
>>  vl.c            |    3 ++-
>>  4 files changed, 14 insertions(+), 1 deletions(-)
>
> There has been no further discussion so this patch is ready to go.  I
> have fixed up the coding style issues - please use scripts/checkpatch.pl
> next time (and see ./CODING_STYLE and ./HACKING).

Sorry for my coding style problems and thanks for your fix!

Thanks,
Hitoshi


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

end of thread, other threads:[~2012-09-22 16:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 16:15 [Qemu-trivial] [PATCH v2] curses: don't initialize curses when qemu is daemonized Hitoshi Mitake
2012-09-22 16:06 ` Stefan Hajnoczi
2012-09-22 16:19   ` Hitoshi Mitake

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