From patchwork Wed May 4 16:49:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 9016741 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3F7B5BF29F for ; Wed, 4 May 2016 16:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99541203B7 for ; Wed, 4 May 2016 16:50:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D8658203B5 for ; Wed, 4 May 2016 16:50:04 +0000 (UTC) Received: from localhost ([::1]:49039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axzzs-00080a-Mh for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 May 2016 12:50:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axzza-0007lq-Pd for qemu-devel@nongnu.org; Wed, 04 May 2016 12:49:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axzzP-0000mI-0q for qemu-devel@nongnu.org; Wed, 04 May 2016 12:49:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axzzO-0000jX-Qj for qemu-devel@nongnu.org; Wed, 04 May 2016 12:49:30 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81AAE3455AD for ; Wed, 4 May 2016 16:49:20 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u44GnIAY001935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 4 May 2016 12:49:20 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3D38A1132D8C; Wed, 4 May 2016 18:49:18 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 4 May 2016 18:49:18 +0200 Message-Id: <1462380558-2030-3-git-send-email-armbru@redhat.com> In-Reply-To: <1462380558-2030-1-git-send-email-armbru@redhat.com> References: <1462380558-2030-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] migration/qjson: Drop gratuitous use of QOM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amit.shah@redhat.com, dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- include/migration/qjson.h | 2 +- migration/qjson.c | 39 ++++++--------------------------------- migration/savevm.c | 2 +- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/include/migration/qjson.h b/include/migration/qjson.h index 7c54fdf..2978b5f 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 cb479fe..5cae55a 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,7 +95,10 @@ const char *qjson_get_str(QJSON *json) QJSON *qjson_new(void) { - QJSON *json = QJSON(object_new(TYPE_QJSON)); + QJSON *json = g_new0(QJSON, 1); + + json->str = qstring_from_str("{ "); + json->omit_comma = true; return json; } @@ -109,32 +107,7 @@ void qjson_finish(QJSON *json) json_end_object(json); } -static void qjson_initfn(Object *obj) +void qjson_destroy(QJSON *json) { - QJSON *json = QJSON(obj); - - json->str = qstring_from_str("{ "); - json->omit_comma = true; + g_free(json); } - -static void qjson_finalizefn(Object *obj) -{ - QJSON *json = QJSON(obj); - - qobject_decref(QOBJECT(json->str)); -} - -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) -{ - type_register_static(&qjson_type_info); -} - -type_init(qjson_register_types) diff --git a/migration/savevm.c b/migration/savevm.c index 16ba443..c5937c8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1114,7 +1114,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); }