Commit d8f4460989d6d6749ff649f1c5439de38c2dfeab

Authored by aliguori
1 parent 1ed1a787

Allow the monitor to be suspended during non-blocking op

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 <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5431 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 20 additions and 1 deletions
console.h
... ... @@ -175,6 +175,8 @@ void term_flush(void);
175 175 void term_print_help(void);
176 176 void monitor_readline(const char *prompt, int is_password,
177 177 char *buf, int buf_size);
  178 +void monitor_suspend(void);
  179 +void monitor_resume(void);
178 180  
179 181 /* readline.c */
180 182 typedef void ReadLineFunc(void *opaque, const char *str);
... ...
monitor.c
... ... @@ -2694,10 +2694,27 @@ static void term_read(void *opaque, const uint8_t *buf, int size)
2694 2694 readline_handle_byte(buf[i]);
2695 2695 }
2696 2696  
  2697 +static int monitor_suspended;
  2698 +
2697 2699 static void monitor_handle_command1(void *opaque, const char *cmdline)
2698 2700 {
2699 2701 monitor_handle_command(cmdline);
2700   - monitor_start_input();
  2702 + if (!monitor_suspended)
  2703 + monitor_start_input();
  2704 + else
  2705 + monitor_suspended = 2;
  2706 +}
  2707 +
  2708 +void monitor_suspend(void)
  2709 +{
  2710 + monitor_suspended = 1;
  2711 +}
  2712 +
  2713 +void monitor_resume(void)
  2714 +{
  2715 + if (monitor_suspended == 2)
  2716 + monitor_start_input();
  2717 + monitor_suspended = 0;
2701 2718 }
2702 2719  
2703 2720 static void monitor_start_input(void)
... ...