qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <afaerber@suse.de>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: [Qemu-devel] [PULL v2 03/10] qmp: Convert QMP code to use object property iterators
Date: Thu, 19 Nov 2015 15:36:01 +0100	[thread overview]
Message-ID: <1447943768-31393-4-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1447943768-31393-1-git-send-email-afaerber@suse.de>

From: "Daniel P. Berrange" <berrange@redhat.com>

Stop directly accessing the Object::properties field data
structure and instead use the formal object property iterator
APIs. This insulates the code from future data structure
changes in the Object struct.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Tested-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 qmp.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/qmp.c b/qmp.c
index ddc63ea..0a1fa19 100644
--- a/qmp.c
+++ b/qmp.c
@@ -210,6 +210,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
     bool ambiguous = false;
     ObjectPropertyInfoList *props = NULL;
     ObjectProperty *prop;
+    ObjectPropertyIterator *iter;
 
     obj = object_resolve_path(path, &ambiguous);
     if (obj == NULL) {
@@ -222,7 +223,8 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
         return NULL;
     }
 
-    QTAILQ_FOREACH(prop, &obj->properties, node) {
+    iter = object_property_iter_init(obj);
+    while ((prop = object_property_iter_next(iter))) {
         ObjectPropertyInfoList *entry = g_malloc0(sizeof(*entry));
 
         entry->value = g_malloc0(sizeof(ObjectPropertyInfo));
@@ -232,6 +234,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
         entry->value->name = g_strdup(prop->name);
         entry->value->type = g_strdup(prop->type);
     }
+    object_property_iter_free(iter);
 
     return props;
 }
@@ -503,6 +506,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
     ObjectClass *klass;
     Object *obj;
     ObjectProperty *prop;
+    ObjectPropertyIterator *iter;
     DevicePropertyInfoList *prop_list = NULL;
 
     klass = object_class_by_name(typename);
@@ -531,7 +535,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
 
     obj = object_new(typename);
 
-    QTAILQ_FOREACH(prop, &obj->properties, node) {
+    iter = object_property_iter_init(obj);
+    while ((prop = object_property_iter_next(iter))) {
         DevicePropertyInfo *info;
         DevicePropertyInfoList *entry;
 
@@ -562,6 +567,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
         entry->next = prop_list;
         prop_list = entry;
     }
+    object_property_iter_free(iter);
 
     object_unref(obj);
 
-- 
2.6.2

  parent reply	other threads:[~2015-11-19 14:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-19 14:35 [Qemu-devel] [PULL for-2.5 v2 00/10] QOM devices patch queue 2015-11-19 Andreas Färber
2015-11-19 14:35 ` [Qemu-devel] [PULL v2 01/10] qdev: Change Property::offset field to ptrdiff_t type Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 02/10] qom: Introduce ObjectPropertyIterator struct for iteration Andreas Färber
2015-11-19 14:36 ` Andreas Färber [this message]
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 04/10] vl: Convert machine help code to use object property iterators Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 05/10] ppc: Convert spapr " Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 06/10] net: Convert net filter " Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 07/10] qom: Add a test case for complex property finalization Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 08/10] qom: Replace object property list with GHashTable Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 09/10] qom: Clean up assertions to display values on failure Andreas Färber
2015-11-19 14:36 ` [Qemu-devel] [PULL v2 10/10] MAINTAINERS: Add check-qom-{interface, proplist} to QOM Andreas Färber
2015-11-19 18:34 ` [Qemu-devel] [PULL for-2.5 v2 00/10] QOM devices patch queue 2015-11-19 Peter Maydell
2015-11-20 11:14 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447943768-31393-4-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).