From patchwork Wed Dec 9 16:27:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [09/19] monitor: Convert do_info_kvm() to QObject Date: Wed, 09 Dec 2009 06:27:48 -0000 From: Luiz Capitulino X-Patchwork-Id: 40744 Message-Id: <1260376078-8694-10-git-send-email-lcapitulino@redhat.com> To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com Signed-off-by: Luiz Capitulino --- monitor.c | 41 +++++++++++++++++++++++++++++++++-------- 1 files changed, 33 insertions(+), 8 deletions(-) diff --git a/monitor.c b/monitor.c index e7a6294..47f794d 100644 --- a/monitor.c +++ b/monitor.c @@ -1783,16 +1783,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 } @@ -2346,7 +2370,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",