Commit 28c3e6ee authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging



QOM infrastructure fixes and device conversions

* Fix for properties on objects > 4 GiB
* Performance improvements for QOM property handling
* Assertion cleanups
* MAINTAINERS additions

# gpg: Signature made Thu 19 Nov 2015 14:32:16 GMT using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/qom-devices-for-peter:
  MAINTAINERS: Add check-qom-{interface,proplist} to QOM
  qom: Clean up assertions to display values on failure
  qom: Replace object property list with GHashTable
  qom: Add a test case for complex property finalization
  net: Convert net filter code to use object property iterators
  ppc: Convert spapr code to use object property iterators
  vl: Convert machine help code to use object property iterators
  qmp: Convert QMP code to use object property iterators
  qom: Introduce ObjectPropertyIterator struct for iteration
  qdev: Change Property::offset field to ptrdiff_t type

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 348c3270 9f4aa7ce
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1164,6 +1164,8 @@ F: include/qom/
X: include/qom/cpu.h
F: qom/
X: qom/cpu.c
F: tests/check-qom-interface.c
F: tests/check-qom-proplist.c
F: tests/qom-test.c

QMP
+4 −1
Original line number Diff line number Diff line
@@ -657,6 +657,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
{
    Object *root_container;
    ObjectProperty *prop;
    ObjectPropertyIterator *iter;
    uint32_t drc_count = 0;
    GArray *drc_indexes, *drc_power_domains;
    GString *drc_names, *drc_types;
@@ -680,7 +681,8 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
     */
    root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);

    QTAILQ_FOREACH(prop, &root_container->properties, node) {
    iter = object_property_iter_init(root_container);
    while ((prop = object_property_iter_next(iter))) {
        Object *obj;
        sPAPRDRConnector *drc;
        sPAPRDRConnectorClass *drck;
@@ -721,6 +723,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
                                    spapr_drc_get_type_str(drc->type));
        drc_types = g_string_insert_len(drc_types, -1, "\0", 1);
    }
    object_property_iter_free(iter);

    /* now write the drc count into the space we reserved at the
     * beginning of the arrays previously
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ struct BusState {
struct Property {
    const char   *name;
    PropertyInfo *info;
    int          offset;
    ptrdiff_t    offset;
    uint8_t      bitnr;
    qtype_code   qtype;
    int64_t      defval;
+56 −3
Original line number Diff line number Diff line
@@ -344,8 +344,6 @@ typedef struct ObjectProperty
    ObjectPropertyResolve *resolve;
    ObjectPropertyRelease *release;
    void *opaque;

    QTAILQ_ENTRY(ObjectProperty) node;
} ObjectProperty;

/**
@@ -405,7 +403,7 @@ struct Object
    /*< private >*/
    ObjectClass *class;
    ObjectFree *free;
    QTAILQ_HEAD(, ObjectProperty) properties;
    GHashTable *properties;
    uint32_t ref;
    Object *parent;
};
@@ -960,6 +958,55 @@ void object_property_del(Object *obj, const char *name, Error **errp);
ObjectProperty *object_property_find(Object *obj, const char *name,
                                     Error **errp);

typedef struct ObjectPropertyIterator ObjectPropertyIterator;

/**
 * object_property_iter_init:
 * @obj: the object
 *
 * Initializes an iterator for traversing all properties
 * registered against an object instance.
 *
 * It is forbidden to modify the property list while iterating,
 * whether removing or adding properties.
 *
 * Typical usage pattern would be
 *
 * <example>
 *   <title>Using object property iterators</title>
 *   <programlisting>
 *   ObjectProperty *prop;
 *   ObjectPropertyIterator *iter;
 *
 *   iter = object_property_iter_init(obj);
 *   while ((prop = object_property_iter_next(iter))) {
 *     ... do something with prop ...
 *   }
 *   object_property_iter_free(iter);
 *   </programlisting>
 * </example>
 *
 * Returns: the new iterator
 */
ObjectPropertyIterator *object_property_iter_init(Object *obj);

/**
 * object_property_iter_free:
 * @iter: the iterator instance
 *
 * Releases any resources associated with the iterator.
 */
void object_property_iter_free(ObjectPropertyIterator *iter);

/**
 * object_property_iter_next:
 * @iter: the iterator instance
 *
 * Returns: the next property, or %NULL when all properties
 * have been traversed.
 */
ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter);

void object_unparent(Object *obj);

/**
@@ -1488,6 +1535,9 @@ void object_property_set_description(Object *obj, const char *name,
 * Call @fn passing each child of @obj and @opaque to it, until @fn returns
 * non-zero.
 *
 * It is forbidden to add or remove children from @obj from the @fn
 * callback.
 *
 * Returns: The last value returned by @fn, or 0 if there is no child.
 */
int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
@@ -1503,6 +1553,9 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
 * non-zero. Calls recursively, all child nodes of @obj will also be passed
 * all the way down to the leaf nodes of the tree. Depth first ordering.
 *
 * It is forbidden to add or remove children from @obj (or its
 * child nodes) from the @fn callback.
 *
 * Returns: The last value returned by @fn, or 0 if there is no child.
 */
int object_child_foreach_recursive(Object *obj,
+4 −1
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ static void netfilter_complete(UserCreatable *uc, Error **errp)
    Error *local_err = NULL;
    char *str, *info;
    ObjectProperty *prop;
    ObjectPropertyIterator *iter;
    StringOutputVisitor *ov;

    if (!nf->netdev_id) {
@@ -173,7 +174,8 @@ static void netfilter_complete(UserCreatable *uc, Error **errp)
    QTAILQ_INSERT_TAIL(&nf->netdev->filters, nf, next);

    /* generate info str */
    QTAILQ_FOREACH(prop, &OBJECT(nf)->properties, node) {
    iter = object_property_iter_init(OBJECT(nf));
    while ((prop = object_property_iter_next(iter))) {
        if (!strcmp(prop->name, "type")) {
            continue;
        }
@@ -187,6 +189,7 @@ static void netfilter_complete(UserCreatable *uc, Error **errp)
        g_free(str);
        g_free(info);
    }
    object_property_iter_free(iter);
}

static void netfilter_finalize(Object *obj)
Loading