[22/25] Monitor: qmp_query_migrate(): Return {} for empty MigrationState

Submitted by Luiz Capitulino on Dec. 6, 2010, 6:24 p.m.

Details

Message ID 1291659852-23028-23-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Dec. 6, 2010, 6:24 p.m.
When no migration has been performed (ie. empty MigrationState),
qmp_query_migrate() returns nothing.

Let's do what other query handlers do: return an empty json-object.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 migration.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/migration.c b/migration.c
index 923d20e..ed253af 100644
--- a/migration.c
+++ b/migration.c
@@ -192,6 +192,9 @@  void do_info_migrate_print(Monitor *mon, const QObject *data)
     QDict *qdict;
 
     qdict = qobject_to_qdict(data);
+    if (qdict_size(qdict) == 0) {
+        return;
+    }
 
     monitor_printf(mon, "Migration status: %s\n",
                    qdict_get_str(qdict, "status"));
@@ -248,6 +251,8 @@  void qmp_query_migrate(Monitor *mon, QObject **ret_data)
             *ret_data = qobject_from_jsonf("{ 'status': 'cancelled' }");
             break;
         }
+    } else {
+        *ret_data = qobject_from_jsonf("{}");
     }
 }