commit 376253ece484b7dc86f215641dca47c3c88f38d1
Author: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Date:   Thu Mar 5 23:01:23 2009 +0000

    monitor: Rework API (Jan Kiszka)
    
    Refactor the monitor API and prepare it for decoupled terminals:
    term_print functions are renamed to monitor_* and all monitor services
    gain a new parameter (mon) that will once refer to the monitor instance
    the output is supposed to appear on. However, the argument remains
    unused for now. All monitor command callbacks are also extended by a mon
    parameter so that command handlers are able to pass an appropriate
    reference to monitor output services.
    
    For the case that monitor outputs so far happen without clearly
    identifiable context, the global variable cur_mon is introduced that
    shall once provide a pointer either to the current active monitor (while
    processing commands) or to the default one. On the mid or long term,
    those use case will be obsoleted so that this variable can be removed
    again.
    
    Due to the broad usage of the monitor interface, this patch mostly deals
    with converting users of the monitor API. A few of them are already
    extended to pass 'mon' from the command handler further down to internal
    functions that invoke monitor_printf.
    
    At this chance, monitor-related prototypes are moved from console.h to
    a new monitor.h. The same is done for the readline API.
    
    Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
    Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
    
    
    git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6711 c046a42c-6fe2-441c-8c8c-71466251a162

diff --git a/migration.c b/migration.c
index 0ef777a..cf69bbe 100644
--- a/migration.c
+++ b/migration.c
@@ -13,7 +13,7 @@
 
 #include "qemu-common.h"
 #include "migration.h"
-#include "console.h"
+#include "monitor.h"
 #include "buffered_file.h"
 #include "sysemu.h"
 #include "block.h"
@@ -48,7 +48,7 @@ void qemu_start_incoming_migration(const char *uri)
         fprintf(stderr, "unknown migration protocol: %s\n", uri);
 }
 
-void do_migrate(int detach, const char *uri)
+void do_migrate(Monitor *mon, int detach, const char *uri)
 {
     MigrationState *s = NULL;
     const char *p;
@@ -60,10 +60,10 @@ void do_migrate(int detach, const char *uri)
         s = exec_start_outgoing_migration(p, max_throttle, detach);
 #endif
     else
-        term_printf("unknown migration protocol: %s\n", uri);
+        monitor_printf(mon, "unknown migration protocol: %s\n", uri);
 
     if (s == NULL)
-        term_printf("migration failed\n");
+        monitor_printf(mon, "migration failed\n");
     else {
         if (current_migration)
             current_migration->release(current_migration);
@@ -72,7 +72,7 @@ void do_migrate(int detach, const char *uri)
     }
 }
 
-void do_migrate_cancel(void)
+void do_migrate_cancel(Monitor *mon)
 {
     MigrationState *s = current_migration;
 
@@ -80,7 +80,7 @@ void do_migrate_cancel(void)
         s->cancel(s);
 }
 
-void do_migrate_set_speed(const char *value)
+void do_migrate_set_speed(Monitor *mon, const char *value)
 {
     double d;
     char *ptr;
@@ -100,24 +100,24 @@ void do_migrate_set_speed(const char *value)
     max_throttle = (uint32_t)d;
 }
 
-void do_info_migrate(void)
+void do_info_migrate(Monitor *mon)
 {
     MigrationState *s = current_migration;
-    
+
     if (s) {
-        term_printf("Migration status: ");
+        monitor_printf(mon, "Migration status: ");
         switch (s->get_status(s)) {
         case MIG_STATE_ACTIVE:
-            term_printf("active\n");
+            monitor_printf(mon, "active\n");
             break;
         case MIG_STATE_COMPLETED:
-            term_printf("completed\n");
+            monitor_printf(mon, "completed\n");
             break;
         case MIG_STATE_ERROR:
-            term_printf("failed\n");
+            monitor_printf(mon, "failed\n");
             break;
         case MIG_STATE_CANCELLED:
-            term_printf("cancelled\n");
+            monitor_printf(mon, "cancelled\n");
             break;
         }
     }
@@ -146,7 +146,7 @@ void migrate_fd_cleanup(FdMigrationState *s)
 
     /* Don't resume monitor until we've flushed all of the buffers */
     if (s->detach == 2) {
-        monitor_resume();
+        monitor_resume(cur_mon);
         s->detach = 0;
     }
 
