The new handler directly calls qmp_query_migrate() to gather data and then prints it. This change allows us to drop the user_print callback.
Signed-off-by: Luiz Capitulino <lcapitul...@redhat.com> --- migration.c | 8 ++++++-- migration.h | 2 +- monitor.c | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/migration.c b/migration.c index ed253af..df10354 100644 --- a/migration.c +++ b/migration.c @@ -187,13 +187,15 @@ static void migrate_print_status(Monitor *mon, const char *name, qdict_get_int(qdict, "total") >> 10); } -void do_info_migrate_print(Monitor *mon, const QObject *data) +void do_info_migrate(Monitor *mon) { QDict *qdict; + QObject *data; + qmp_query_migrate(NULL, &data); qdict = qobject_to_qdict(data); if (qdict_size(qdict) == 0) { - return; + goto out; } monitor_printf(mon, "Migration status: %s\n", @@ -206,6 +208,8 @@ void do_info_migrate_print(Monitor *mon, const QObject *data) if (qdict_haskey(qdict, "disk")) { migrate_print_status(mon, "disk", qdict); } +out: + qobject_decref(data); } static void migrate_put_status(QDict *qdict, const char *name, diff --git a/migration.h b/migration.h index 30ee679..96d4eb3 100644 --- a/migration.h +++ b/migration.h @@ -65,7 +65,7 @@ uint64_t migrate_max_downtime(void); int do_migrate_set_downtime(Monitor *mon, const QDict *qdict, QObject **ret_data); -void do_info_migrate_print(Monitor *mon, const QObject *data); +void do_info_migrate(Monitor *mon); void qmp_query_migrate(Monitor *mon, QObject **ret_data); diff --git a/monitor.c b/monitor.c index 3b6137e..97bab21 100644 --- a/monitor.c +++ b/monitor.c @@ -2615,8 +2615,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show migration status", - .user_print = do_info_migrate_print, - .mhandler.info_new = qmp_query_migrate, + .mhandler.info = do_info_migrate, }, { .name = "balloon", -- 1.7.3.3.398.g0b0cd