The new handler directly calls qmp_query_name() to gather data and then prints it. This change allows us to drop the user_print callback.
Signed-off-by: Luiz Capitulino <[email protected]> --- monitor.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 89325d8..2d1f183 100644 --- a/monitor.c +++ b/monitor.c @@ -754,16 +754,21 @@ static void qmp_query_name(Monitor *mon, QObject **ret_data) qobject_from_jsonf("{}"); } -static void do_info_name_print(Monitor *mon, const QObject *data) +static void do_info_name(Monitor *mon) { QDict *qdict; + QObject *data; + qmp_query_name(NULL, &data); qdict = qobject_to_qdict(data); if (qdict_size(qdict) == 0) { - return; + goto out; } monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name")); + +out: + qobject_decref(data); } static QObject *get_cmd_dict(const char *name) @@ -2574,8 +2579,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the current VM name", - .user_print = do_info_name_print, - .mhandler.info_new = qmp_query_name, + .mhandler.info = do_info_name, }, { .name = "uuid", -- 1.7.3.3.398.g0b0cd
