render / rpms / qemu

Forked from rpms/qemu 5 months ago
Clone

Blame 0223-curses-don-t-initialize-curses-when-qemu-is-daemoniz.patch

5544c1
From 949f263f90b97dadae23ad205c4c5a3671ecb3aa Mon Sep 17 00:00:00 2001
5544c1
From: Hitoshi Mitake <h.mitake@gmail.com>
5544c1
Date: Sat, 15 Sep 2012 01:15:41 +0900
5544c1
Subject: [PATCH] curses: don't initialize curses when qemu is daemonized
5544c1
5544c1
Current qemu initializes curses even if -daemonize option is
5544c1
passed. This cause problem because shell prompt appears without
5544c1
calling endwin().
5544c1
5544c1
This patch adds new function, is_daemonized(), to OS dependent
5544c1
code. With this function, curses_display_init() can check that qemu is
5544c1
daemonized or not. If daemonized, curses_display_init() isn't called
5544c1
and the problem is avoided.
5544c1
5544c1
Of course, -daemonize && -curses doesn't make sense. Users shouldn't
5544c1
pass the arguments at the same time. But the problem is very painful
5544c1
because Ctrl-C cannot be delivered to the terminal.
5544c1
5544c1
Cc: Andrzej Zaborowski  <balrog@zabor.org>
5544c1
Cc: Stefan Hajnoczi <stefanha@gmail.com>
5544c1
Cc: Anthony Liguori <aliguori@us.ibm.com>
5544c1
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
Signed-off-by: Hitoshi Mitake <h.mitake@gmail.com>
5544c1
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
5544c1
(cherry picked from commit 995ee2bf469de6bbe5ce133ec853392b2a4ce34c)
5544c1
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 os-posix.c      | 5 +++++
5544c1
 qemu-os-posix.h | 2 ++
5544c1
 qemu-os-win32.h | 5 +++++
5544c1
 vl.c            | 4 +++-
5544c1
 4 files changed, 15 insertions(+), 1 deletion(-)
5544c1
5544c1
diff --git a/os-posix.c b/os-posix.c
5544c1
index 79fa228..eabccb8 100644
5544c1
--- a/os-posix.c
5544c1
+++ b/os-posix.c
5544c1
@@ -360,3 +360,8 @@ int qemu_create_pidfile(const char *filename)
5544c1
     /* keep pidfile open & locked forever */
5544c1
     return 0;
5544c1
 }
5544c1
+
5544c1
+bool is_daemonized(void)
5544c1
+{
5544c1
+    return daemonize;
5544c1
+}
5544c1
diff --git a/qemu-os-posix.h b/qemu-os-posix.h
5544c1
index 8e1149d..7f198e4 100644
5544c1
--- a/qemu-os-posix.h
5544c1
+++ b/qemu-os-posix.h
5544c1
@@ -46,4 +46,6 @@ typedef struct timeval qemu_timeval;
5544c1
 typedef struct timespec qemu_timespec;
5544c1
 int qemu_utimens(const char *path, const qemu_timespec *times);
5544c1
 
5544c1
+bool is_daemonized(void);
5544c1
+
5544c1
 #endif
5544c1
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
5544c1
index 753679b..b3e451b 100644
5544c1
--- a/qemu-os-win32.h
5544c1
+++ b/qemu-os-win32.h
5544c1
@@ -86,4 +86,9 @@ typedef struct {
5544c1
 } qemu_timeval;
5544c1
 int qemu_gettimeofday(qemu_timeval *tp);
5544c1
 
5544c1
+static inline bool is_daemonized(void)
5544c1
+{
5544c1
+    return false;
5544c1
+}
5544c1
+
5544c1
 #endif
5544c1
diff --git a/vl.c b/vl.c
5544c1
index c681c33..49d7a52 100644
5544c1
--- a/vl.c
5544c1
+++ b/vl.c
5544c1
@@ -3692,7 +3692,9 @@ int main(int argc, char **argv, char **envp)
5544c1
         break;
5544c1
 #if defined(CONFIG_CURSES)
5544c1
     case DT_CURSES:
5544c1
-        curses_display_init(ds, full_screen);
5544c1
+        if (!is_daemonized()) {
5544c1
+            curses_display_init(ds, full_screen);
5544c1
+        }
5544c1
         break;
5544c1
 #endif
5544c1
 #if defined(CONFIG_SDL)
5544c1
-- 
5544c1
1.7.12.1
5544c1