diff options
author | Markus Armbruster <armbru@redhat.com> | 2016-05-04 18:49:18 +0200 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2016-05-23 14:16:12 +0530 |
commit | b72fe9e690db5082fdd0476074230cf2c65508bf (patch) | |
tree | 2b332dd8bc8eb429cbbc31684e3239588522492f | |
parent | 17b74b98676aee5bc470b173b1e528d2fce2cf18 (diff) | |
download | qemu-b72fe9e690db5082fdd0476074230cf2c65508bf.zip |
migration/qjson: Drop gratuitous use of QOM
All the use of QOM buys us here is the ability to destroy the thing
with object_unref(OBJECT(vmdesc)). Not worth the notational overhead.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <1462380558-2030-3-git-send-email-armbru@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r-- | include/migration/qjson.h | 2 | ||||
-rw-r--r-- | migration/qjson.c | 39 | ||||
-rw-r--r-- | migration/savevm.c | 2 |
3 files changed, 8 insertions, 35 deletions
diff --git a/include/migration/qjson.h b/include/migration/qjson.h index 7c54fdf0ac..2978b5f371 100644 --- a/include/migration/qjson.h +++ b/include/migration/qjson.h @@ -13,10 +13,10 @@ #ifndef QEMU_QJSON_H #define QEMU_QJSON_H -#define TYPE_QJSON "QJSON" typedef struct QJSON QJSON; QJSON *qjson_new(void); +void qjson_destroy(QJSON *json); void json_prop_str(QJSON *json, const char *name, const char *str); void json_prop_int(QJSON *json, const char *name, int64_t val); void json_end_array(QJSON *json); diff --git a/migration/qjson.c b/migration/qjson.c index cb479fe0eb..5cae55af07 100644 --- a/migration/qjson.c +++ b/migration/qjson.c @@ -26,17 +26,12 @@ #include "qemu/osdep.h" #include "qapi/qmp/qstring.h" #include "migration/qjson.h" -#include "qemu/module.h" -#include "qom/object.h" struct QJSON { - Object obj; QString *str; bool omit_comma; }; -#define QJSON(obj) OBJECT_CHECK(QJSON, (obj), TYPE_QJSON) - static void json_emit_element(QJSON *json, const char *name) { /* Check whether we need to print a , before an element */ @@ -100,41 +95,19 @@ const char *qjson_get_str(QJSON *json) QJSON *qjson_new(void) { - QJSON *json = QJSON(object_new(TYPE_QJSON)); - return json; -} - -void qjson_finish(QJSON *json) -{ - json_end_object(json); -} - -static void qjson_initfn(Object *obj) -{ - QJSON *json = QJSON(obj); + QJSON *json = g_new0(QJSON, 1); json->str = qstring_from_str("{ "); json->omit_comma = true; + return json; } -static void qjson_finalizefn(Object *obj) +void qjson_finish(QJSON *json) { - QJSON *json = QJSON(obj); - - qobject_decref(QOBJECT(json->str)); + json_end_object(json); } -static const TypeInfo qjson_type_info = { - .name = TYPE_QJSON, - .parent = TYPE_OBJECT, - .instance_size = sizeof(QJSON), - .instance_init = qjson_initfn, - .instance_finalize = qjson_finalizefn, -}; - -static void qjson_register_types(void) +void qjson_destroy(QJSON *json) { - type_register_static(&qjson_type_info); + g_free(json); } - -type_init(qjson_register_types) diff --git a/migration/savevm.c b/migration/savevm.c index bfb3d9178f..8546fdfae1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1115,7 +1115,7 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only) qemu_put_be32(f, vmdesc_len); qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len); } - object_unref(OBJECT(vmdesc)); + qjson_destroy(vmdesc); qemu_fflush(f); } |