diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-05 23:01:23 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-03-05 23:01:23 +0000 |
commit | 376253ece484b7dc86f215641dca47c3c88f38d1 (patch) | |
tree | cbbcd578628422d88cc6326012f59e7081d3c77e /vl.c | |
parent | bb5fc20f7c1c65e95030da3629dd0d7a0cce38cd (diff) |
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
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 47 |
1 files changed, 25 insertions, 22 deletions
@@ -31,6 +31,7 @@ #include "hw/baum.h" #include "hw/bt.h" #include "net.h" +#include "monitor.h" #include "console.h" #include "sysemu.h" #include "gdbstub.h" @@ -653,34 +654,34 @@ int kbd_mouse_is_absolute(void) return qemu_put_mouse_event_current->qemu_put_mouse_event_absolute; } -void do_info_mice(void) +void do_info_mice(Monitor *mon) { QEMUPutMouseEntry *cursor; int index = 0; if (!qemu_put_mouse_event_head) { - term_printf("No mouse devices connected\n"); + monitor_printf(mon, "No mouse devices connected\n"); return; } - term_printf("Mouse devices available:\n"); + monitor_printf(mon, "Mouse devices available:\n"); cursor = qemu_put_mouse_event_head; while (cursor != NULL) { - term_printf("%c Mouse #%d: %s\n", - (cursor == qemu_put_mouse_event_current ? '*' : ' '), - index, cursor->qemu_put_mouse_event_name); + monitor_printf(mon, "%c Mouse #%d: %s\n", + (cursor == qemu_put_mouse_event_current ? '*' : ' '), + index, cursor->qemu_put_mouse_event_name); index++; cursor = cursor->next; } } -void do_mouse_set(int index) +void do_mouse_set(Monitor *mon, int index) { QEMUPutMouseEntry *cursor; int i = 0; if (!qemu_put_mouse_event_head) { - term_printf("No mouse devices connected\n"); + monitor_printf(mon, "No mouse devices connected\n"); return; } @@ -693,7 +694,7 @@ void do_mouse_set(int index) if (cursor != NULL) qemu_put_mouse_event_current = cursor; else - term_printf("Mouse at given index not found\n"); + monitor_printf(mon, "Mouse at given index not found\n"); } /* compute with 96 bit intermediate result: (a*b)/c */ @@ -2697,7 +2698,8 @@ static int usb_device_add(const char *devname, int is_hotplug) if (bdrv_key_required(bs)) { autostart = 0; if (is_hotplug) { - monitor_read_bdrv_key_start(bs, usb_msd_password_cb, dev); + monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, + dev); return 0; } } @@ -2779,24 +2781,24 @@ static int usb_device_del(const char *devname) return usb_device_del_addr(bus_num, addr); } -void do_usb_add(const char *devname) +void do_usb_add(Monitor *mon, const char *devname) { usb_device_add(devname, 1); } -void do_usb_del(const char *devname) +void do_usb_del(Monitor *mon, const char *devname) { usb_device_del(devname); } -void usb_info(void) +void usb_info(Monitor *mon) { USBDevice *dev; USBPort *port; const char *speed_str; if (!usb_enabled) { - term_printf("USB support not enabled\n"); + monitor_printf(mon, "USB support not enabled\n"); return; } @@ -2818,8 +2820,8 @@ void usb_info(void) speed_str = "?"; break; } - term_printf(" Device %d.%d, Speed %s Mb/s, Product %s\n", - 0, dev->addr, speed_str, dev->devname); + monitor_printf(mon, " Device %d.%d, Speed %s Mb/s, Product %s\n", + 0, dev->addr, speed_str, dev->devname); } } @@ -2853,16 +2855,17 @@ void pcmcia_socket_unregister(struct pcmcia_socket_s *socket) } } -void pcmcia_info(void) +void pcmcia_info(Monitor *mon) { struct pcmcia_socket_entry_s *iter; + if (!pcmcia_sockets) - term_printf("No PCMCIA sockets\n"); + monitor_printf(mon, "No PCMCIA sockets\n"); for (iter = pcmcia_sockets; iter; iter = iter->next) - term_printf("%s: %s\n", iter->socket->slot_string, - iter->socket->attached ? iter->socket->card_string : - "Empty"); + monitor_printf(mon, "%s: %s\n", iter->socket->slot_string, + iter->socket->attached ? iter->socket->card_string : + "Empty"); } /***********************************************************/ @@ -5726,7 +5729,7 @@ int main(int argc, char **argv, char **envp) #endif if (loadvm) - do_loadvm(loadvm); + do_loadvm(cur_mon, loadvm); if (incoming) { autostart = 0; /* fixme how to deal with -daemonize */ |