qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-stable] [Qemu-devel] [PATCH v4 1/3] qmp: fix object-add assert


From: Xiao Long Jiang
Subject: Re: [Qemu-stable] [Qemu-devel] [PATCH v4 1/3] qmp: fix object-add assert() without props
Date: Fri, 23 Sep 2016 14:52:15 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

Hi,

I have tested this patch on arch s390 system. It works fine. :-)

On 2016/9/23 上午4:39, Marc-André Lureau wrote:
Since commit ad739706bbadee49, user_creatable_add_type() expects to be
given a qdict. However, if object-add is called without props, you reach
the assert: "qemu/qom/object_interfaces.c:115: user_creatable_add_type:
Assertion `qdict' failed.", because the qdict isn't created in this
case (it's optional).

Furthermore, qmp_input_visitor_new() is not meant to be called without a
dict, and a further commit will assert in this situation.

If none given, create an empty qdict in qmp to avoid the
user_creatable_add_type() assert(qdict).

Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
  qmp.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qmp.c b/qmp.c
index 6733463..b6de482 100644
--- a/qmp.c
+++ b/qmp.c
@@ -665,7 +665,7 @@ void qmp_add_client(const char *protocol, const char 
*fdname,
  void qmp_object_add(const char *type, const char *id,
                      bool has_props, QObject *props, Error **errp)
  {
-    const QDict *pdict = NULL;
+    QDict *pdict;
      Visitor *v;
      Object *obj;
@@ -675,14 +675,18 @@ void qmp_object_add(const char *type, const char *id,
              error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
              return;
          }
+        QINCREF(pdict);
+    } else {
+        pdict = qdict_new();
      }
- v = qmp_input_visitor_new(props, true);
+    v = qmp_input_visitor_new(QOBJECT(pdict), true);
      obj = user_creatable_add_type(type, id, pdict, v, errp);
      visit_free(v);
      if (obj) {
          object_unref(obj);
      }
+    QDECREF(pdict);
  }
void qmp_object_del(const char *id, Error **errp)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]