Skip to contentSkip to conversation

curses: don't initialize curses when qemu is daemonized

PATCH Applied Hitoshi Mitake 2 participants 3 messages Sep 14, 2012 – Sep 22, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 curses: don't initialize curses when qemu is daemonized

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 <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Anthony Liguori <[email protected]>
Cc Michael Roth <[email protected]>

---

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(-)
os-posix.c +5 -0
index 79fa228..99c5343 100644
@@ -360,3 +360,8 @@ int qemu_create_pidfile(const char *filename)
     /* keep pidfile open & locked forever */
     return 0;
 }
+
+int is_daemonized(void)
+{
+    return daemonize;
+}
qemu-os-posix.h +2 -0
index 8e1149d..0b2b60a 100644
@@ -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
qemu-os-win32.h +5 -0
index 753679b..08a6fa8 100644
@@ -86,4 +86,9 @@ typedef struct {
 } qemu_timeval;
 int qemu_gettimeofday(qemu_timeval *tp);
 
+static inline int is_daemonized(void)
+{
+    return 0;
+}
+
 #endif
vl.c +2 -1
index 7c577fa..463f39e 100644
@@ -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)
Signature · 1 line
1.7.5.1
#1 lore raw
Quoted 20 lines · Hitoshi 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 <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Anthony Liguori <[email protected]>
Cc Michael Roth <[email protected]>

---

Quoted 8 lines

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

#2 lore raw
Quoted 30 lines · Stefan Hajnoczi
Quoted 20 lines · Hitoshi 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 <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Anthony Liguori <[email protected]>
Cc Michael Roth <[email protected]>

---

Quoted 8 lines

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(-)
Quoted 3 lines

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