From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kd9Et-0001PY-2c for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:51:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kd9Em-0001J7-FQ for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:58 -0400 Received: from [199.232.76.173] (port=35802 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kd9El-0001IS-CX for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:55 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:35238) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kd9El-0001tu-CM for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:55 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m89JoqpU014351 for ; Tue, 9 Sep 2008 15:50:52 -0400 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m89Jop9W215360 for ; Tue, 9 Sep 2008 13:50:51 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m89JooSr007609 for ; Tue, 9 Sep 2008 13:50:50 -0600 From: Anthony Liguori Date: Tue, 9 Sep 2008 14:49:54 -0500 Message-Id: <1220989802-13706-3-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1220989802-13706-1-git-send-email-aliguori@us.ibm.com> References: <1220989802-13706-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 2/10] Allow the monitor to be suspended during non-blocking op Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Chris Wright , Uri Lublin , Anthony Liguori , kvm@vger.kernel.org Live migration happens in the background, but it is useful to make the monitor command appear as if it's blocking. This allows a management tool to immediately know when the live migration has completed without having to poll the migration status. This patch allows the monitor to be suspended from a monitor callback which will prevent new monitor commands from being executed. Signed-off-by: Anthony Liguori diff --git a/console.h b/console.h index 561ef51..c94386c 100644 --- a/console.h +++ b/console.h @@ -168,6 +168,8 @@ void term_flush(void); void term_print_help(void); void monitor_readline(const char *prompt, int is_password, char *buf, int buf_size); +void monitor_suspend(void); +void monitor_resume(void); /* readline.c */ typedef void ReadLineFunc(void *opaque, const char *str); diff --git a/monitor.c b/monitor.c index 47c5514..14bdbeb 100644 --- a/monitor.c +++ b/monitor.c @@ -2687,10 +2687,27 @@ static void term_read(void *opaque, const uint8_t *buf, int size) static void monitor_start_input(void); +static int monitor_suspended; + static void monitor_handle_command1(void *opaque, const char *cmdline) { monitor_handle_command(cmdline); - monitor_start_input(); + if (!monitor_suspended) + monitor_start_input(); + else + monitor_suspended = 2; +} + +void monitor_suspend(void) +{ + monitor_suspended = 1; +} + +void monitor_resume(void) +{ + if (monitor_suspended == 2) + monitor_start_input(); + monitor_suspended = 0; } static void monitor_start_input(void)