From 6e785bee32f9225e9e4dd5fffd7192f8b3f83f08 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Thu, 10 Dec 2009 17:15:58 -0200 Subject: monitor: do_info_version(): Use QDict All 'info' commands should use QDict, this commit also kills monitor_print_qobject() as do_info_version() doesn't use it anymore (and no handler will). Signed-off-by: Luiz Capitulino Signed-off-by: Anthony Liguori (cherry picked from commit 45e914cfe03f9fcf946bdc124f752d8f288eff05) --- monitor.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 31a2afaa1..33ed3c53b 100644 --- a/monitor.c +++ b/monitor.c @@ -257,24 +257,6 @@ static inline int monitor_has_error(const Monitor *mon) return mon->error != NULL; } -static void monitor_print_qobject(Monitor *mon, const QObject *data) -{ - switch (qobject_type(data)) { - case QTYPE_QSTRING: - monitor_printf(mon, "%s",qstring_get_str(qobject_to_qstring(data))); - break; - case QTYPE_QINT: - monitor_printf(mon, "%" PRId64,qint_get_int(qobject_to_qint(data))); - break; - default: - monitor_printf(mon, "ERROR: unsupported type: %d", - qobject_type(data)); - break; - } - - monitor_puts(mon, "\n"); -} - static void monitor_json_emitter(Monitor *mon, const QObject *data) { QString *json; @@ -504,12 +486,32 @@ help: help_cmd(mon, "info"); } +static void do_info_version_print(Monitor *mon, const QObject *data) +{ + QDict *qdict; + + qdict = qobject_to_qdict(data); + + monitor_printf(mon, "%s%s\n", qdict_get_str(qdict, "qemu"), + qdict_get_str(qdict, "package")); +} + /** * do_info_version(): Show QEMU version + * + * Return a QDict with the following information: + * + * - "qemu": QEMU's version + * - "package": package's version + * + * Example: + * + * { "qemu": "0.11.50", "package": "" } */ static void do_info_version(Monitor *mon, QObject **ret_data) { - *ret_data = QOBJECT(qstring_from_str(QEMU_VERSION QEMU_PKGVERSION)); + *ret_data = qobject_from_jsonf("{ 'qemu': %s, 'package': %s }", + QEMU_VERSION, QEMU_PKGVERSION); } static void do_info_name(Monitor *mon) @@ -2223,7 +2225,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the version of QEMU", - .user_print = monitor_print_qobject, + .user_print = do_info_version_print, .mhandler.info_new = do_info_version, }, { -- cgit v1.2.3-65-gdbad From e637fd2386aba3e57345130d2fc3262f789e56c9 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Thu, 10 Dec 2009 17:15:59 -0200 Subject: monitor: Convert do_info_status() to QObject Signed-off-by: Luiz Capitulino Signed-off-by: Anthony Liguori (cherry picked from commit c0e8520ed5efef2891e2e930a1bb21c1b040410f) --- monitor.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 33ed3c53b..3d37548d6 100644 --- a/monitor.c +++ b/monitor.c @@ -1933,16 +1933,41 @@ static void do_inject_nmi(Monitor *mon, const QDict *qdict) } #endif -static void do_info_status(Monitor *mon) +static void do_info_status_print(Monitor *mon, const QObject *data) { - if (vm_running) { - if (singlestep) { - monitor_printf(mon, "VM status: running (single step mode)\n"); - } else { - monitor_printf(mon, "VM status: running\n"); + QDict *qdict; + + qdict = qobject_to_qdict(data); + + monitor_printf(mon, "VM status: "); + if (qdict_get_bool(qdict, "running")) { + monitor_printf(mon, "running"); + if (qdict_get_bool(qdict, "singlestep")) { + monitor_printf(mon, " (single step mode)"); } - } else - monitor_printf(mon, "VM status: paused\n"); + } else { + monitor_printf(mon, "paused"); + } + + monitor_printf(mon, "\n"); +} + +/** + * do_info_status(): VM status + * + * Return a QDict with the following information: + * + * - "running": true if the VM is running, or false if it is paused + * - "singlestep": true if the VM is in single step mode, false otherwise + * + * Example: + * + * { "running": true, "singlestep": false } + */ +static void do_info_status(Monitor *mon, QObject **ret_data) +{ + *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }", + vm_running, singlestep); } /** @@ -2393,7 +2418,8 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the current VM status (running|paused)", - .mhandler.info = do_info_status, + .user_print = do_info_status_print, + .mhandler.info_new = do_info_status, }, { .name = "pcmcia", -- cgit v1.2.3-65-gdbad From 94f539bdac57daea5f5d853cfee86bd683cf81cf Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Thu, 10 Dec 2009 17:16:00 -0200 Subject: monitor: Convert do_info_kvm() to QObject Signed-off-by: Luiz Capitulino Signed-off-by: Anthony Liguori (cherry picked from commit 2af5ba712b3e03cf644320f7386bf1dfd2c2b6a8) --- monitor.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 3d37548d6..18c461215 100644 --- a/monitor.c +++ b/monitor.c @@ -1806,16 +1806,40 @@ static void tlb_info(Monitor *mon) #endif -static void do_info_kvm(Monitor *mon) +static void do_info_kvm_print(Monitor *mon, const QObject *data) { -#ifdef CONFIG_KVM + QDict *qdict; + + qdict = qobject_to_qdict(data); + monitor_printf(mon, "kvm support: "); - if (kvm_enabled()) - monitor_printf(mon, "enabled\n"); - else - monitor_printf(mon, "disabled\n"); + if (qdict_get_bool(qdict, "present")) { + monitor_printf(mon, "%s\n", qdict_get_bool(qdict, "enabled") ? + "enabled" : "disabled"); + } else { + monitor_printf(mon, "not compiled\n"); + } +} + +/** + * do_info_kvm(): Show KVM information + * + * Return a QDict with the following information: + * + * - "enabled": true if KVM support is enabled, false otherwise + * - "present": true if QEMU has KVM support, false otherwise + * + * Example: + * + * { "enabled": true, "present": true } + */ +static void do_info_kvm(Monitor *mon, QObject **ret_data) +{ +#ifdef CONFIG_KVM + *ret_data = qobject_from_jsonf("{ 'enabled': %i, 'present': true }", + kvm_enabled()); #else - monitor_printf(mon, "kvm support: not compiled\n"); + *ret_data = qobject_from_jsonf("{ 'enabled': false, 'present': false }"); #endif } @@ -2369,7 +2393,8 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show KVM information", - .mhandler.info = do_info_kvm, + .user_print = do_info_kvm_print, + .mhandler.info_new = do_info_kvm, }, { .name = "numa", -- cgit v1.2.3-65-gdbad