monitor: Port handler_1 to use QDict

This commit ports command handlers that receive one argument to use
the new monitor's dictionary.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Luiz Capitulino 2009-08-28 15:27:13 -03:00 committed by Anthony Liguori
parent f96fc8a0f1
commit d54908a55b
8 changed files with 67 additions and 47 deletions

View File

@ -2,6 +2,7 @@
#define CONSOLE_H
#include "qemu-char.h"
#include "qdict.h"
/* keyboard/mouse support */
@ -44,7 +45,7 @@ struct MouseTransformInfo {
};
void do_info_mice(Monitor *mon);
void do_mouse_set(Monitor *mon, int index);
void do_mouse_set(Monitor *mon, const QDict *qdict);
/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
constants) */

View File

@ -203,9 +203,9 @@ void pci_device_hot_remove(Monitor *mon, const char *pci_addr)
qemu_system_device_hot_add(bus, slot, 0);
}
void do_pci_device_hot_remove(Monitor *mon, const char *pci_addr)
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
{
pci_device_hot_remove(mon, pci_addr);
pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
}
static int pci_match_fn(void *dev_private, void *arg)

View File

@ -88,11 +88,12 @@ void do_migrate_cancel(Monitor *mon, const QDict *qdict)
s->cancel(s);
}
void do_migrate_set_speed(Monitor *mon, const char *value)
void do_migrate_set_speed(Monitor *mon, const QDict *qdict)
{
double d;
char *ptr;
FdMigrationState *s;
const char *value = qdict_get_str(qdict, "value");
d = strtod(value, &ptr);
switch (*ptr) {
@ -126,10 +127,11 @@ uint64_t migrate_max_downtime(void)
return max_downtime;
}
void do_migrate_set_downtime(Monitor *mon, const char *value)
void do_migrate_set_downtime(Monitor *mon, const QDict *qdict)
{
char *ptr;
double d;
const char *value = qdict_get_str(qdict, "value");
d = strtod(value, &ptr);
if (!strcmp(ptr,"ms")) {

View File

@ -54,11 +54,11 @@ void do_migrate(Monitor *mon, int detach, const char *uri);
void do_migrate_cancel(Monitor *mon, const QDict *qdict);
void do_migrate_set_speed(Monitor *mon, const char *value);
void do_migrate_set_speed(Monitor *mon, const QDict *qdict);
uint64_t migrate_max_downtime(void);
void do_migrate_set_downtime(Monitor *mon, const char *value);
void do_migrate_set_downtime(Monitor *mon, const QDict *qdict);
void do_info_migrate(Monitor *mon);

View File

@ -254,15 +254,16 @@ static void help_cmd(Monitor *mon, const char *name)
}
}
static void do_help_cmd(Monitor *mon, const char *name)
static void do_help_cmd(Monitor *mon, const QDict *qdict)
{
help_cmd(mon, name);
help_cmd(mon, qdict_get_try_str(qdict, "name"));
}
static void do_commit(Monitor *mon, const char *device)
static void do_commit(Monitor *mon, const QDict *qdict)
{
int all_devices;
DriveInfo *dinfo;
const char *device = qdict_get_str(qdict, "device");
all_devices = !strcmp(device, "all");
TAILQ_FOREACH(dinfo, &drives, next) {
@ -273,9 +274,10 @@ static void do_commit(Monitor *mon, const char *device)
}
}
static void do_info(Monitor *mon, const char *item)
static void do_info(Monitor *mon, const QDict *qdict)
{
const mon_cmd_t *cmd;
const char *item = qdict_get_try_str(qdict, "item");
void (*handler)(Monitor *);
if (!item)
@ -387,8 +389,9 @@ static void do_info_cpus(Monitor *mon)
}
}
static void do_cpu_set(Monitor *mon, int index)
static void do_cpu_set(Monitor *mon, const QDict *qdict)
{
int index = qdict_get_int(qdict, "index");
if (mon_set_cpu(index) < 0)
monitor_printf(mon, "Invalid CPU index\n");
}
@ -522,19 +525,20 @@ static void do_change(Monitor *mon, const char *device, const char *target,
}
}
static void do_screen_dump(Monitor *mon, const char *filename)
static void do_screen_dump(Monitor *mon, const QDict *qdict)
{
vga_hw_screen_dump(filename);
vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
}
static void do_logfile(Monitor *mon, const char *filename)
static void do_logfile(Monitor *mon, const QDict *qdict)
{
cpu_set_log_filename(filename);
cpu_set_log_filename(qdict_get_str(qdict, "filename"));
}
static void do_log(Monitor *mon, const char *items)
static void do_log(Monitor *mon, const QDict *qdict)
{
int mask;
const char *items = qdict_get_str(qdict, "items");
if (!strcmp(items, "none")) {
mask = 0;
@ -548,8 +552,9 @@ static void do_log(Monitor *mon, const char *items)
cpu_set_log(mask);
}
static void do_singlestep(Monitor *mon, const char *option)
static void do_singlestep(Monitor *mon, const QDict *qdict)
{
const char *option = qdict_get_try_str(qdict, "option");
if (!option || !strcmp(option, "on")) {
singlestep = 1;
} else if (!strcmp(option, "off")) {
@ -601,8 +606,9 @@ static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs)
}
}
static void do_gdbserver(Monitor *mon, const char *device)
static void do_gdbserver(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_try_str(qdict, "device");
if (!device)
device = "tcp::" DEFAULT_GDBSTUB_PORT;
if (gdbserver_start(device) < 0) {
@ -616,8 +622,9 @@ static void do_gdbserver(Monitor *mon, const char *device)
}
}
static void do_watchdog_action(Monitor *mon, const char *action)
static void do_watchdog_action(Monitor *mon, const QDict *qdict)
{
const char *action = qdict_get_str(qdict, "action");
if (select_watchdog_action(action) == -1) {
monitor_printf(mon, "Unknown watchdog action '%s'\n", action);
}
@ -1167,8 +1174,9 @@ static void do_mouse_move(Monitor *mon, const char *dx_str, const char *dy_str,
kbd_mouse_event(dx, dy, dz, mouse_button_state);
}
static void do_mouse_button(Monitor *mon, int button_state)
static void do_mouse_button(Monitor *mon, const QDict *qdict)
{
int button_state = qdict_get_int(qdict, "button_state");
mouse_button_state = button_state;
kbd_mouse_event(0, 0, 0, mouse_button_state);
}
@ -1223,9 +1231,10 @@ static void do_ioport_write(Monitor *mon, int count, int format, int size,
}
}
static void do_boot_set(Monitor *mon, const char *bootdevice)
static void do_boot_set(Monitor *mon, const QDict *qdict)
{
int res;
const char *bootdevice = qdict_get_str(qdict, "bootdevice");
res = qemu_boot_set(bootdevice);
if (res == 0) {
@ -1467,9 +1476,10 @@ static void do_info_capture(Monitor *mon)
}
#ifdef HAS_AUDIO
static void do_stop_capture(Monitor *mon, int n)
static void do_stop_capture(Monitor *mon, const QDict *qdict)
{
int i;
int n = qdict_get_int(qdict, "n");
CaptureState *s;
for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
@ -1504,9 +1514,10 @@ static void do_wav_capture(Monitor *mon, const char *path,
#endif
#if defined(TARGET_I386)
static void do_inject_nmi(Monitor *mon, int cpu_index)
static void do_inject_nmi(Monitor *mon, const QDict *qdict)
{
CPUState *env;
int cpu_index = qdict_get_int(qdict, "cpu_index");
for (env = first_cpu; env != NULL; env = env->next_cpu)
if (env->cpu_index == cpu_index) {
@ -1529,8 +1540,9 @@ static void do_info_status(Monitor *mon)
}
static void do_balloon(Monitor *mon, int value)
static void do_balloon(Monitor *mon, const QDict *qdict)
{
int value = qdict_get_int(qdict, "value");
ram_addr_t target = value;
qemu_balloon(target << 20);
}
@ -1559,8 +1571,9 @@ static qemu_acl *find_acl(Monitor *mon, const char *name)
return acl;
}
static void do_acl_show(Monitor *mon, const char *aclname)
static void do_acl_show(Monitor *mon, const QDict *qdict)
{
const char *aclname = qdict_get_str(qdict, "aclname");
qemu_acl *acl = find_acl(mon, aclname);
qemu_acl_entry *entry;
int i = 0;
@ -1576,8 +1589,9 @@ static void do_acl_show(Monitor *mon, const char *aclname)
}
}
static void do_acl_reset(Monitor *mon, const char *aclname)
static void do_acl_reset(Monitor *mon, const QDict *qdict)
{
const char *aclname = qdict_get_str(qdict, "aclname");
qemu_acl *acl = find_acl(mon, aclname);
if (acl) {
@ -1669,8 +1683,9 @@ static void do_inject_mce(Monitor *mon,
}
#endif
static void do_getfd(Monitor *mon, const char *fdname)
static void do_getfd(Monitor *mon, const QDict *qdict)
{
const char *fdname = qdict_get_str(qdict, "fdname");
mon_fd_t *monfd;
int fd;
@ -1709,8 +1724,9 @@ static void do_getfd(Monitor *mon, const char *fdname)
LIST_INSERT_HEAD(&mon->fds, monfd, next);
}
static void do_closefd(Monitor *mon, const char *fdname)
static void do_closefd(Monitor *mon, const QDict *qdict)
{
const char *fdname = qdict_get_str(qdict, "fdname");
mon_fd_t *monfd;
LIST_FOREACH(monfd, &mon->fds, next) {
@ -1729,9 +1745,10 @@ static void do_closefd(Monitor *mon, const char *fdname)
fdname);
}
static void do_loadvm(Monitor *mon, const char *name)
static void do_loadvm(Monitor *mon, const QDict *qdict)
{
int saved_vm_running = vm_running;
const char *name = qdict_get_str(qdict, "name");
vm_stop(0);
@ -2555,7 +2572,6 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
void *str_allocated[MAX_ARGS];
void *args[MAX_ARGS];
void (*handler_d)(Monitor *mon, const QDict *qdict);
void (*handler_1)(Monitor *mon, void *arg0);
void (*handler_2)(Monitor *mon, void *arg0, void *arg1);
void (*handler_3)(Monitor *mon, void *arg0, void *arg1, void *arg2);
void (*handler_4)(Monitor *mon, void *arg0, void *arg1, void *arg2,
@ -2848,13 +2864,10 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
qemu_errors_to_mon(mon);
switch(nb_args) {
case 0:
case 1:
handler_d = cmd->handler;
handler_d(mon, qdict);
break;
case 1:
handler_1 = cmd->handler;
handler_1(mon, args[0]);
break;
case 2:
handler_2 = cmd->handler;
handler_2(mon, args[0], args[1]);

View File

@ -1480,7 +1480,7 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
return ret;
}
void do_savevm(Monitor *mon, const char *name)
void do_savevm(Monitor *mon, const QDict *qdict)
{
DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
@ -1494,6 +1494,7 @@ void do_savevm(Monitor *mon, const char *name)
#else
struct timeval tv;
#endif
const char *name = qdict_get_try_str(qdict, "name");
bs = get_bs_snapshots();
if (!bs) {
@ -1644,11 +1645,12 @@ int load_vmstate(Monitor *mon, const char *name)
return 0;
}
void do_delvm(Monitor *mon, const char *name)
void do_delvm(Monitor *mon, const QDict *qdict)
{
DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
int ret;
const char *name = qdict_get_str(qdict, "name");
bs = get_bs_snapshots();
if (!bs) {

View File

@ -5,6 +5,7 @@
#include "qemu-common.h"
#include "qemu-option.h"
#include "sys-queue.h"
#include "qdict.h"
#ifdef _WIN32
#include <windows.h>
@ -50,9 +51,9 @@ int qemu_powerdown_requested(void);
extern qemu_irq qemu_system_powerdown;
void qemu_system_reset(void);
void do_savevm(Monitor *mon, const char *name);
void do_savevm(Monitor *mon, const QDict *qdict);
int load_vmstate(Monitor *mon, const char *name);
void do_delvm(Monitor *mon, const char *name);
void do_delvm(Monitor *mon, const QDict *qdict);
void do_info_snapshots(Monitor *mon);
void qemu_announce_self(void);
@ -212,8 +213,8 @@ void destroy_bdrvs(dev_match_fn *match_fn, void *arg);
void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type,
const char *opts);
void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts);
void do_pci_device_hot_remove(Monitor *mon, const char *pci_addr);
void pci_device_hot_remove(Monitor *mon, const char *pci_addr);
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
void pci_device_hot_remove_success(int pcibus, int slot);
/* serial ports */
@ -269,8 +270,8 @@ struct soundhw {
extern struct soundhw soundhw[];
#endif
void do_usb_add(Monitor *mon, const char *devname);
void do_usb_del(Monitor *mon, const char *devname);
void do_usb_add(Monitor *mon, const QDict *qdict);
void do_usb_del(Monitor *mon, const QDict *qdict);
void usb_info(Monitor *mon);
void register_devices(void);

11
vl.c
View File

@ -479,10 +479,11 @@ void do_info_mice(Monitor *mon)
}
}
void do_mouse_set(Monitor *mon, int index)
void do_mouse_set(Monitor *mon, const QDict *qdict)
{
QEMUPutMouseEntry *cursor;
int i = 0;
int index = qdict_get_int(qdict, "index");
if (!qemu_put_mouse_event_head) {
monitor_printf(mon, "No mouse devices connected\n");
@ -2597,14 +2598,14 @@ static int usb_parse(const char *cmdline)
return usb_device_add(cmdline, 0);
}
void do_usb_add(Monitor *mon, const char *devname)
void do_usb_add(Monitor *mon, const QDict *qdict)
{
usb_device_add(devname, 1);
usb_device_add(qdict_get_str(qdict, "devname"), 1);
}
void do_usb_del(Monitor *mon, const char *devname)
void do_usb_del(Monitor *mon, const QDict *qdict)
{
usb_device_del(devname);
usb_device_del(qdict_get_str(qdict, "devname"));
}
void usb_info(Monitor *mon)