Patchwork [v3,10/34] qmp: allow object-add completion handler to get canonical path

login
register
mail settings
Submitter Hu Tao
Date March 26, 2014, 10:36 a.m.
Message ID <2c29c40a976ad2f7c715c39115a3829344a45e33.1395825870.git.hutao@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/333924/
State New
Headers show

Comments

Hu Tao - March 26, 2014, 10:36 a.m.
From: Igor Mammedov <imammedo@redhat.com>

Add object to /objects before calling user_creatable_complete()
handler, so that object might be able to call
object_get_canonical_path() in its completion handler.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qmp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/qmp.c b/qmp.c
index 87a28f7..54b95ba 100644
--- a/qmp.c
+++ b/qmp.c
@@ -564,13 +564,15 @@  void object_add(const char *type, const char *id, const QDict *qdict,
         goto out;
     }
 
+    object_property_add_child(container_get(object_get_root(), "/objects"),
+                              id, obj, &local_err);
+
     user_creatable_complete(obj, &local_err);
     if (local_err) {
+        object_property_del(container_get(object_get_root(), "/objects"),
+                            id, &error_abort);
         goto out;
     }
-
-    object_property_add_child(container_get(object_get_root(), "/objects"),
-                              id, obj, &local_err);
 out:
     if (local_err) {
         error_propagate(errp, local_err);