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

login
register
mail settings
Submitter Luiz Capitulino
Date Dec. 6, 2010, 6:24 p.m.
Message ID <1291659852-23028-23-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/74453/
State New
Headers show

Comments

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

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("{}");
     }
 }