| Submitter | Luiz Capitulino |
|---|---|
| Date | Dec. 4, 2009, 5:11 p.m. |
| Message ID | <1259946695-15784-8-git-send-email-lcapitulino@redhat.com> |
| Download | mbox | patch |
| Permalink | /patch/40346/ |
| State | New |
| Headers | show |
Comments
Luiz Capitulino wrote: > Return a QString with kvm status information. > > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> > --- > monitor.c | 31 +++++++++++++++++++++++++------ > 1 files changed, 25 insertions(+), 6 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 03f5d7a..d3ab2ab 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -1738,17 +1738,35 @@ 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) > { > + monitor_printf(mon, "kvm support: %s\n", > + qstring_get_str(qobject_to_qstring(data))); > +} > + > +/** > + * do_info_kvm(): Show KVM information > + * > + * Return a QString with KVM information, which can be: > + * > + * - "enabled" > + * - "disabled" > + * - "not compiled" > + */ > +static void do_info_kvm(Monitor *mon, QObject **ret_data) > +{ > + QString *qs; > + > #ifdef CONFIG_KVM > - monitor_printf(mon, "kvm support: "); > if (kvm_enabled()) > - monitor_printf(mon, "enabled\n"); > + qs = qstring_from_str("enabled"); > else > - monitor_printf(mon, "disabled\n"); > + qs = qstring_from_str("disabled"); > #else > - monitor_printf(mon, "kvm support: not compiled\n"); > + qs = qstring_from_str("not compiled"); > #endif > + > + *ret_data = QOBJECT(qs); > } > > "{'enabled': true, 'present': false}" Using a dictionary here is important as then we can extend it with more information (like the supported KVM features). Regards, Anthony Liguori
Patch
diff --git a/monitor.c b/monitor.c index 03f5d7a..d3ab2ab 100644 --- a/monitor.c +++ b/monitor.c @@ -1738,17 +1738,35 @@ 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) { + monitor_printf(mon, "kvm support: %s\n", + qstring_get_str(qobject_to_qstring(data))); +} + +/** + * do_info_kvm(): Show KVM information + * + * Return a QString with KVM information, which can be: + * + * - "enabled" + * - "disabled" + * - "not compiled" + */ +static void do_info_kvm(Monitor *mon, QObject **ret_data) +{ + QString *qs; + #ifdef CONFIG_KVM - monitor_printf(mon, "kvm support: "); if (kvm_enabled()) - monitor_printf(mon, "enabled\n"); + qs = qstring_from_str("enabled"); else - monitor_printf(mon, "disabled\n"); + qs = qstring_from_str("disabled"); #else - monitor_printf(mon, "kvm support: not compiled\n"); + qs = qstring_from_str("not compiled"); #endif + + *ret_data = QOBJECT(qs); } static void do_info_numa(Monitor *mon) @@ -2288,7 +2306,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",
Return a QString with kvm status information. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> --- monitor.c | 31 +++++++++++++++++++++++++------ 1 files changed, 25 insertions(+), 6 deletions(-)