From patchwork Fri Oct 9 21:31:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06DA6C433E7 for ; Fri, 9 Oct 2020 21:33:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82F2521D6C for ; Fri, 9 Oct 2020 21:33:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jBb8qpLD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82F2521D6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kR00t-0005qa-DD for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 17:33:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQzzX-0005Nt-B1 for qemu-devel@nongnu.org; Fri, 09 Oct 2020 17:31:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQzzT-0000cV-VK for qemu-devel@nongnu.org; Fri, 09 Oct 2020 17:31:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602279110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ypkI9tRVj1LN2UT/ZgT9wIeE2U3jpshUd4zd5TXpgus=; b=jBb8qpLDVLmp3vCy7abIPF02bp6ElwjFmy12bXJ4NQOdo1+omuNXRrKOGochM1mDgt0VQ4 +5nzzFhM9dqA9BYCX7rx30ZwpewzXADN1YZKGGijdZpNtjb1wy9eJC/jcJo/zZynGWAJqs 3AUKILA1sApiPmpxHQzR2C33tK5k2vI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-559-pERrSbaIPW2-HC6rsJtBlg-1; Fri, 09 Oct 2020 17:31:48 -0400 X-MC-Unique: pERrSbaIPW2-HC6rsJtBlg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC6F2107AD64 for ; Fri, 9 Oct 2020 21:31:47 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76B071A3D6; Fri, 9 Oct 2020 21:31:44 +0000 (UTC) Date: Fri, 9 Oct 2020 17:31:43 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH] check-qom-proplist: Don't register instance props for user-creatable type Message-ID: <20201009213143.GI7303@habkost.net> References: <20201009160122.1662082-1-ehabkost@redhat.com> <20201009160122.1662082-13-ehabkost@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201009160122.1662082-13-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" user-creatable types will now be forbidden from registering instance properties, but check-qom-proplist reuse the same type for testing user_creatable_add_opts() and for testing class/instance property enumeration. To address those conflicting requirements, add two subclasses of TYPE_DUMMY: one that's user-creatable and another one that has instance properties. Most test that set the "bv" property will use the new TYPE_DUMMY_WITH_INSTANCE_PROPS type, but test_dummy_createcmdl() will now TYPE_DUMMY_USER_CREATABLE. Signed-off-by: Eduardo Habkost --- The patch [RFC] qom: Lock properties of all TYPE_USER_CREATABLE types will break check-qom-proplist, unless this patch is applied first. --- tests/check-qom-proplist.c | 59 +++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index fba30c20b2..e9d0eec0c2 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -124,14 +124,6 @@ static char *dummy_get_sv(Object *obj, } -static void dummy_init(Object *obj) -{ - object_property_add_bool(obj, "bv", - dummy_get_bv, - dummy_set_bv); -} - - static void dummy_class_init(ObjectClass *cls, void *data) { object_class_property_add_str(cls, "sv", @@ -155,15 +147,48 @@ static void dummy_finalize(Object *obj) g_free(dobj->sv); } - static const TypeInfo dummy_info = { .name = TYPE_DUMMY, .parent = TYPE_OBJECT, .instance_size = sizeof(DummyObject), - .instance_init = dummy_init, .instance_finalize = dummy_finalize, .class_size = sizeof(DummyObjectClass), .class_init = dummy_class_init, +}; + +static void dummy_with_instance_props_init(Object *obj) +{ + object_property_add_bool(obj, "bv", + dummy_get_bv, + dummy_set_bv); +} + +/* Subclass of TYPE_DUMMY, but with a instance-level "bv" property */ +#define TYPE_DUMMY_WITH_INSTANCE_PROPS "qemu-dummy-with-intance-props" + +static const TypeInfo dummy_with_instance_props_info = { + .name = TYPE_DUMMY_WITH_INSTANCE_PROPS, + .parent = TYPE_DUMMY, + .instance_init = dummy_with_instance_props_init, +}; + +static void dummy_user_creatable_class_init(ObjectClass *cls, void *data) +{ + object_class_property_add_bool(cls, "bv", + dummy_get_bv, + dummy_set_bv); +} + +/* + * Subclass of TYPE_DUMMY, but user-creatable and with a class-level + * "bv" property + */ +#define TYPE_DUMMY_USER_CREATABLE "qemu-dummy-user-creatable" + +static const TypeInfo dummy_user_creatable_info = { + .name = TYPE_DUMMY_USER_CREATABLE, + .parent = TYPE_DUMMY, + .class_init = dummy_user_creatable_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, { } @@ -341,7 +366,7 @@ static void test_dummy_createv(void) Error *err = NULL; Object *parent = object_get_objects_root(); DummyObject *dobj = DUMMY_OBJECT( - object_new_with_props(TYPE_DUMMY, + object_new_with_props(TYPE_DUMMY_WITH_INSTANCE_PROPS, parent, "dummy0", &err, @@ -370,7 +395,7 @@ static Object *new_helper(Error **errp, Object *obj; va_start(vargs, parent); - obj = object_new_with_propv(TYPE_DUMMY, + obj = object_new_with_propv(TYPE_DUMMY_WITH_INSTANCE_PROPS, parent, "dummy0", errp, @@ -409,7 +434,7 @@ static void test_dummy_createcmdl(void) QemuOpts *opts; DummyObject *dobj; Error *err = NULL; - const char *params = TYPE_DUMMY \ + const char *params = TYPE_DUMMY_USER_CREATABLE \ ",id=dev0," \ "bv=yes,sv=Hiss hiss hiss,av=platypus"; @@ -449,7 +474,7 @@ static void test_dummy_badenum(void) Error *err = NULL; Object *parent = object_get_objects_root(); Object *dobj = - object_new_with_props(TYPE_DUMMY, + object_new_with_props(TYPE_DUMMY_WITH_INSTANCE_PROPS, parent, "dummy0", &err, @@ -541,7 +566,7 @@ static void test_dummy_iterator(void) "bv"}; /* instance property */ Object *parent = object_get_objects_root(); DummyObject *dobj = DUMMY_OBJECT( - object_new_with_props(TYPE_DUMMY, + object_new_with_props(TYPE_DUMMY_WITH_INSTANCE_PROPS, parent, "dummy0", &error_abort, @@ -560,7 +585,7 @@ static void test_dummy_class_iterator(void) { const char *expected[] = { "type", "av", "sv", "u8v" }; ObjectPropertyIterator iter; - ObjectClass *klass = object_class_by_name(TYPE_DUMMY); + ObjectClass *klass = object_class_by_name(TYPE_DUMMY_WITH_INSTANCE_PROPS); object_class_property_iter_init(&iter, klass); test_dummy_prop_iterator(&iter, expected, ARRAY_SIZE(expected)); @@ -626,6 +651,8 @@ int main(int argc, char **argv) module_call_init(MODULE_INIT_QOM); type_register_static(&dummy_info); + type_register_static(&dummy_with_instance_props_info); + type_register_static(&dummy_user_creatable_info); type_register_static(&dummy_dev_info); type_register_static(&dummy_bus_info); type_register_static(&dummy_backend_info); From patchwork Fri Oct 9 16:01:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 303313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B51D4C433E7 for ; Fri, 9 Oct 2020 16:13:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D2C22225D for ; Fri, 9 Oct 2020 16:13:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dDlJTjKb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D2C22225D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv15-0008EF-Fg for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:13:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQupx-0003ig-39 for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQupu-00018S-R7 for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j8o0cMvoB1NfkCAmxv1Vhgzlg9+OlUbpZQtUOLLhGZY=; b=dDlJTjKbA0Nx7xFDDOHUhCk9qJedwioSoSoIwOkbdts0mn1Z5UCg1q+udx3b8k77wHehES 1c1BlFC9p9GEUFktvT8WwBIc1ef+H1Cs9g060RueZcIc07wvXRNEKfRbfHMJUVaku9J9xl Jw1tbg7XVeNeefFsDp/+lXGSXMUOZeM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-n1mRpz7cOqmYpS_feHFrNg-1; Fri, 09 Oct 2020 12:01:36 -0400 X-MC-Unique: n1mRpz7cOqmYpS_feHFrNg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40836803F6A for ; Fri, 9 Oct 2020 16:01:35 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8575D55771; Fri, 9 Oct 2020 16:01:31 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 02/12] qom: Introduce PointerProperty struct Date: Fri, 9 Oct 2020 12:01:12 -0400 Message-Id: <20201009160122.1662082-3-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" PointerProperty will hold additional info about pointer properties. It will allow us to implement more complex logic in pointer property getters and setters. Signed-off-by: Eduardo Habkost --- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- qom/object.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/qom/object.c b/qom/object.c index 313d2f9834..17692ed5c3 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2449,17 +2449,30 @@ static char *object_get_type(Object *obj, Error **errp) return g_strdup(object_get_typename(obj)); } +typedef struct { + /* Pointer to property value */ + void *ptr; +} PointerProperty; + +static void *pointer_property_get_ptr(Object *obj, PointerProperty *prop) +{ + return prop->ptr; +} + static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint8_t value = *(uint8_t *)opaque; + PointerProperty *prop = opaque; + uint8_t *field = pointer_property_get_ptr(obj, prop); + uint8_t value = *field; visit_type_uint8(v, name, &value, errp); } static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint8_t *field = opaque; + PointerProperty *prop = opaque; + uint8_t *field = pointer_property_get_ptr(obj, prop); uint8_t value; if (!visit_type_uint8(v, name, &value, errp)) { @@ -2472,14 +2485,17 @@ static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name, static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint16_t value = *(uint16_t *)opaque; + PointerProperty *prop = opaque; + uint16_t *field = pointer_property_get_ptr(obj, prop); + uint16_t value = *field; visit_type_uint16(v, name, &value, errp); } static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint16_t *field = opaque; + PointerProperty *prop = opaque; + uint16_t *field = pointer_property_get_ptr(obj, prop); uint16_t value; if (!visit_type_uint16(v, name, &value, errp)) { @@ -2492,14 +2508,17 @@ static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name, static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint32_t value = *(uint32_t *)opaque; + PointerProperty *prop = opaque; + uint32_t *field = pointer_property_get_ptr(obj, prop); + uint32_t value = *field; visit_type_uint32(v, name, &value, errp); } static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint32_t *field = opaque; + PointerProperty *prop = opaque; + uint32_t *field = pointer_property_get_ptr(obj, prop); uint32_t value; if (!visit_type_uint32(v, name, &value, errp)) { @@ -2512,14 +2531,17 @@ static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name, static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint64_t value = *(uint64_t *)opaque; + PointerProperty *prop = opaque; + uint64_t *field = pointer_property_get_ptr(obj, prop); + uint64_t value = *field; visit_type_uint64(v, name, &value, errp); } static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - uint64_t *field = opaque; + PointerProperty *prop = opaque; + uint64_t *field = pointer_property_get_ptr(obj, prop); uint64_t value; if (!visit_type_uint64(v, name, &value, errp)) { @@ -2537,10 +2559,12 @@ object_property_add_uint_ptr(Object *obj, const char *name, ObjectPropertyFlags flags, void *ptr) { + PointerProperty *prop = g_new0(PointerProperty, 1); + prop->ptr = ptr; return object_property_add(obj, name, type, (flags & OBJ_PROP_FLAG_READ) ? getter : NULL, (flags & OBJ_PROP_FLAG_WRITE) ? setter : NULL, - NULL, ptr); + NULL, (void *)prop); } static ObjectProperty * @@ -2551,10 +2575,12 @@ object_class_property_add_uint_ptr(ObjectClass *oc, const char *name, ObjectPropertyFlags flags, void *ptr) { + PointerProperty *prop = g_new0(PointerProperty, 1); + prop->ptr = ptr; return object_class_property_add(oc, name, type, (flags & OBJ_PROP_FLAG_READ) ? getter : NULL, (flags & OBJ_PROP_FLAG_WRITE) ? setter : NULL, - NULL, ptr); + NULL, (void *)prop); } ObjectProperty * From patchwork Fri Oct 9 16:01:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 303312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 512BAC433E7 for ; Fri, 9 Oct 2020 16:16:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE0F02227F for ; Fri, 9 Oct 2020 16:16:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YeHUtGBu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE0F02227F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv46-0003Ju-02 for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:16:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQupz-0003jz-0i for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQupw-00018W-5e for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+D4Qlu6faHWzWrvhTA7LnAXy7RbcEPbMekSs3yKkXRI=; b=YeHUtGBumwAtdIcgcvm+6vq4uSfAaHBETjF8R9QDhUXNBNxQH8UybzUobHmvb0fJkoungv TUHLSzKKyT1W5bn5OzCPghvIwXuV7MzD+4cLcGY0mjxl1kqMZ0CxwRJYLk4Odyw1V31Kej evDk8KlPMJLV5IbyfnpZX2575k2FR/Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-AwNJIaxkOXa0qXn5HTcZUg-1; Fri, 09 Oct 2020 12:01:37 -0400 X-MC-Unique: AwNJIaxkOXa0qXn5HTcZUg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89B00879519 for ; Fri, 9 Oct 2020 16:01:36 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43A3A6266E; Fri, 9 Oct 2020 16:01:36 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 03/12] qom: Make object_class_property_add_uint*_ptr() get offset Date: Fri, 9 Oct 2020 12:01:13 -0400 Message-Id: <20201009160122.1662082-4-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The existing object_class_property_add_uint*_ptr() functions are not very useful, because they need a pointer to the property value, which can't really be provided before the object is created. Replace the pointer parameter in those functions with a `ptrdiff_t offset` parameter. Include a uint8 class property in check-qom-proplist unit tests, to ensure the feature is working. Signed-off-by: Eduardo Habkost --- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- include/qom/object.h | 8 ++++---- qom/object.c | 36 +++++++++++++++++++++++------------- tests/check-qom-proplist.c | 10 ++++++++-- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index d378f13a11..1634294e4f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1747,7 +1747,7 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name, ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, - const uint8_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags); /** @@ -1768,7 +1768,7 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name, ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, - const uint16_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags); /** @@ -1789,7 +1789,7 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name, ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, - const uint32_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags); /** @@ -1810,7 +1810,7 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name, ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, - const uint64_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags); /** diff --git a/qom/object.c b/qom/object.c index 17692ed5c3..bb32f5d3ad 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2450,13 +2450,22 @@ static char *object_get_type(Object *obj, Error **errp) } typedef struct { - /* Pointer to property value */ - void *ptr; + bool is_offset; + union { + /* Pointer to property value. Valid if is_offset=false */ + void *ptr; + /* Offset in Object struct. Valid if is_offset=true */ + ptrdiff_t offset; + }; } PointerProperty; static void *pointer_property_get_ptr(Object *obj, PointerProperty *prop) { - return prop->ptr; + if (prop->is_offset) { + return (void *)obj + prop->offset; + } else { + return prop->ptr; + } } static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *name, @@ -2573,10 +2582,11 @@ object_class_property_add_uint_ptr(ObjectClass *oc, const char *name, ObjectPropertyAccessor getter, ObjectPropertyAccessor setter, ObjectPropertyFlags flags, - void *ptr) + ptrdiff_t offset) { PointerProperty *prop = g_new0(PointerProperty, 1); - prop->ptr = ptr; + prop->is_offset = true; + prop->offset = offset; return object_class_property_add(oc, name, type, (flags & OBJ_PROP_FLAG_READ) ? getter : NULL, (flags & OBJ_PROP_FLAG_WRITE) ? setter : NULL, @@ -2597,13 +2607,13 @@ object_property_add_uint8_ptr(Object *obj, const char *name, ObjectProperty * object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, - const uint8_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags) { return object_class_property_add_uint_ptr(klass, name, "uint8", property_get_uint8_ptr, property_set_uint8_ptr, - flags, (void *)v); + flags, offset); } ObjectProperty * @@ -2620,13 +2630,13 @@ object_property_add_uint16_ptr(Object *obj, const char *name, ObjectProperty * object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, - const uint16_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags) { return object_class_property_add_uint_ptr(klass, name, "uint16", property_get_uint16_ptr, property_set_uint16_ptr, - flags, (void *)v); + flags, offset); } ObjectProperty * @@ -2643,13 +2653,13 @@ object_property_add_uint32_ptr(Object *obj, const char *name, ObjectProperty * object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, - const uint32_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags) { return object_class_property_add_uint_ptr(klass, name, "uint32", property_get_uint32_ptr, property_set_uint32_ptr, - flags, (void *)v); + flags, offset); } ObjectProperty * @@ -2666,13 +2676,13 @@ object_property_add_uint64_ptr(Object *obj, const char *name, ObjectProperty * object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, - const uint64_t *v, + ptrdiff_t offset, ObjectPropertyFlags flags) { return object_class_property_add_uint_ptr(klass, name, "uint64", property_get_uint64_ptr, property_set_uint64_ptr, - flags, (void *)v); + flags, offset); } typedef struct { diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 1b76581980..fba30c20b2 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -61,6 +61,7 @@ struct DummyObject { bool bv; DummyAnimal av; char *sv; + uint8_t u8v; }; struct DummyObjectClass { @@ -141,6 +142,9 @@ static void dummy_class_init(ObjectClass *cls, void *data) &dummy_animal_map, dummy_get_av, dummy_set_av); + object_class_property_add_uint8_ptr(cls, "u8v", + offsetof(DummyObject, u8v), + OBJ_PROP_FLAG_READWRITE); } @@ -385,12 +389,14 @@ static void test_dummy_createlist(void) "bv", "yes", "sv", "Hiss hiss hiss", "av", "platypus", + "u8v", "42", NULL)); g_assert(err == NULL); g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss"); g_assert(dobj->bv == true); g_assert(dobj->av == DUMMY_PLATYPUS); + g_assert_cmpint(dobj->u8v, ==, 42); g_assert(object_resolve_path_component(parent, "dummy0") == OBJECT(dobj)); @@ -531,7 +537,7 @@ static void test_dummy_iterator(void) { const char *expected[] = { "type", /* inherited from TYPE_OBJECT */ - "sv", "av", /* class properties */ + "sv", "av", "u8v", /* class properties */ "bv"}; /* instance property */ Object *parent = object_get_objects_root(); DummyObject *dobj = DUMMY_OBJECT( @@ -552,7 +558,7 @@ static void test_dummy_iterator(void) static void test_dummy_class_iterator(void) { - const char *expected[] = { "type", "av", "sv" }; + const char *expected[] = { "type", "av", "sv", "u8v" }; ObjectPropertyIterator iter; ObjectClass *klass = object_class_by_name(TYPE_DUMMY); From patchwork Fri Oct 9 16:01:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FD9AC433DF for ; Fri, 9 Oct 2020 16:05:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0FEA22259 for ; Fri, 9 Oct 2020 16:05:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M/3981KX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0FEA22259 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQutY-0006zc-Tu for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:05:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuq0-0003ku-MT for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQupx-00018i-UW for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IZtbwbBnXHyx61GM0CmVgiZpiaLakMIl9udCynleo4I=; b=M/3981KXkWp1IqAORCoCmETmdq5aR03IMDjHWW+bB1iKUiaNteNaYbL0FAqSakI76SqQOI Cc9IMiMuNbh3uZczmJf1UbLeHafZ86pnpZKdUnVzi+CHf6wj8qyyrvv5nwkiBKkRyKnHjN 4NL60C71MF+CiCk1Rupbm5W8Nc1Y3K8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-358-iO6RfbCOOUOBVrQ9XvZ5mw-1; Fri, 09 Oct 2020 12:01:38 -0400 X-MC-Unique: iO6RfbCOOUOBVrQ9XvZ5mw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E5B41074643; Fri, 9 Oct 2020 16:01:37 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6069855776; Fri, 9 Oct 2020 16:01:37 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 04/12] sev: Use class properties Date: Fri, 9 Oct 2020 12:01:14 -0400 Message-Id: <20201009160122.1662082-5-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost --- Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- target/i386/sev.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 93c4d60b82..d1c9247c14 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -298,6 +298,19 @@ sev_guest_class_init(ObjectClass *oc, void *data) sev_guest_set_session_file); object_class_property_set_description(oc, "session-file", "guest owners session parameters (encoded with base64)"); + + object_class_property_add_uint32_ptr(oc, "policy", + offsetof(SevGuestState, policy), + OBJ_PROP_FLAG_READWRITE); + object_class_property_add_uint32_ptr(oc, "handle", + offsetof(SevGuestState, handle), + OBJ_PROP_FLAG_READWRITE); + object_class_property_add_uint32_ptr(oc, "cbitpos", + offsetof(SevGuestState, cbitpos), + OBJ_PROP_FLAG_READWRITE); + object_class_property_add_uint32_ptr(oc, "reduced-phys-bits", + offsetof(SevGuestState, reduced_phys_bits), + OBJ_PROP_FLAG_READWRITE); } static void @@ -307,15 +320,6 @@ sev_guest_instance_init(Object *obj) sev->sev_device = g_strdup(DEFAULT_SEV_DEVICE); sev->policy = DEFAULT_GUEST_POLICY; - object_property_add_uint32_ptr(obj, "policy", &sev->policy, - OBJ_PROP_FLAG_READWRITE); - object_property_add_uint32_ptr(obj, "handle", &sev->handle, - OBJ_PROP_FLAG_READWRITE); - object_property_add_uint32_ptr(obj, "cbitpos", &sev->cbitpos, - OBJ_PROP_FLAG_READWRITE); - object_property_add_uint32_ptr(obj, "reduced-phys-bits", - &sev->reduced_phys_bits, - OBJ_PROP_FLAG_READWRITE); } /* sev guest info */ From patchwork Fri Oct 9 16:01:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81748C433E7 for ; Fri, 9 Oct 2020 16:15:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 062562227E for ; Fri, 9 Oct 2020 16:15:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N9gjiUA1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 062562227E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv3B-0002Ym-4D for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:15:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuq4-0003m7-22 for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:48920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuq1-000190-5m for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=slIUVKk0+8beFrLh45o20cBpi9FInCOQBDpM1t0b5mc=; b=N9gjiUA1My0j0nQgRVaWJghslq5syCuk7MSaATK9z+nGXID45nS+bxkEt1MgpcglRAt2UV e/95/B5hLFFGi4lNXnufMCj4w7dd+jj2V0kLWeE6feL434n3iiFX47LYk2hYa7fa60la5/ Wv9IxRUc8olScgU+1R9WLto5Y1qckEA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-xqKz9e7tMqK1I_X1i2Qvug-1; Fri, 09 Oct 2020 12:01:42 -0400 X-MC-Unique: xqKz9e7tMqK1I_X1i2Qvug-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F8B31019631; Fri, 9 Oct 2020 16:01:41 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AA997664F; Fri, 9 Oct 2020 16:01:38 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 05/12] rng: Use class properties Date: Fri, 9 Oct 2020 12:01:15 -0400 Message-Id: <20201009160122.1662082-6-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Amit Shah , Markus Armbruster , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost --- Cc: Laurent Vivier Cc: Amit Shah Cc: qemu-devel@nongnu.org --- backends/rng-egd.c | 10 +++------- backends/rng-random.c | 8 ++++---- backends/rng.c | 6 +++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/backends/rng-egd.c b/backends/rng-egd.c index 20198ff26e..600eef3f75 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -135,12 +135,6 @@ static char *rng_egd_get_chardev(Object *obj, Error **errp) return NULL; } -static void rng_egd_init(Object *obj) -{ - object_property_add_str(obj, "chardev", - rng_egd_get_chardev, rng_egd_set_chardev); -} - static void rng_egd_finalize(Object *obj) { RngEgd *s = RNG_EGD(obj); @@ -153,6 +147,9 @@ static void rng_egd_class_init(ObjectClass *klass, void *data) { RngBackendClass *rbc = RNG_BACKEND_CLASS(klass); + object_class_property_add_str(klass, "chardev", + rng_egd_get_chardev, rng_egd_set_chardev); + rbc->request_entropy = rng_egd_request_entropy; rbc->opened = rng_egd_opened; } @@ -162,7 +159,6 @@ static const TypeInfo rng_egd_info = { .parent = TYPE_RNG_BACKEND, .instance_size = sizeof(RngEgd), .class_init = rng_egd_class_init, - .instance_init = rng_egd_init, .instance_finalize = rng_egd_finalize, }; diff --git a/backends/rng-random.c b/backends/rng-random.c index 245b12ab24..27152b8cdb 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -108,10 +108,6 @@ static void rng_random_init(Object *obj) { RngRandom *s = RNG_RANDOM(obj); - object_property_add_str(obj, "filename", - rng_random_get_filename, - rng_random_set_filename); - s->filename = g_strdup("/dev/urandom"); s->fd = -1; } @@ -132,6 +128,10 @@ static void rng_random_class_init(ObjectClass *klass, void *data) { RngBackendClass *rbc = RNG_BACKEND_CLASS(klass); + object_class_property_add_str(klass, "filename", + rng_random_get_filename, + rng_random_set_filename); + rbc->request_entropy = rng_random_request_entropy; rbc->opened = rng_random_opened; } diff --git a/backends/rng.c b/backends/rng.c index 484f04e891..f018c380da 100644 --- a/backends/rng.c +++ b/backends/rng.c @@ -106,9 +106,6 @@ static void rng_backend_init(Object *obj) QSIMPLEQ_INIT(&s->requests); - object_property_add_bool(obj, "opened", - rng_backend_prop_get_opened, - rng_backend_prop_set_opened); } static void rng_backend_finalize(Object *obj) @@ -122,6 +119,9 @@ static void rng_backend_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + object_class_property_add_bool(oc, "opened", + rng_backend_prop_get_opened, + rng_backend_prop_set_opened); ucc->complete = rng_backend_complete; } From patchwork Fri Oct 9 16:01:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B931C433E7 for ; Fri, 9 Oct 2020 16:19:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A835B2225D for ; Fri, 9 Oct 2020 16:19:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cq852Zw4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A835B2225D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv7J-00072I-RD for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:19:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuq8-0003n2-RP for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55194) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuq5-00019J-QE for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ll32Ld3oaLI3mIkeWOiZjUATzrWwfL5tTQJloVNDuu4=; b=cq852Zw42g8Z/2aDAt3s7bFHSxCtIxiP3IaAO8htvpJ+Zbz9cXmQD+Pt9Q8WwAKGN1m0lT BNlhNptA7m2AZQSxsQeQsid/F74ZfGBkSmaaFlsE7K+dX3+G+PSq23y22l0mvMrGy6TNtA 64iFfGUt/oB/CLAle7lKLkqQ8cUvFAg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-PN1-52c7PTq3oa1YV_cm-g-1; Fri, 09 Oct 2020 12:01:47 -0400 X-MC-Unique: PN1-52c7PTq3oa1YV_cm-g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF8AC107AFCC; Fri, 9 Oct 2020 16:01:45 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F63D5D9F3; Fri, 9 Oct 2020 16:01:42 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 06/12] can_host: Use class properties Date: Fri, 9 Oct 2020 12:01:16 -0400 Message-Id: <20201009160122.1662082-7-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vikram Garhwal , Jason Wang , Markus Armbruster , =?utf-8?q?Marc-Andr=C3=A9_Lure?= =?utf-8?q?au?= , John Snow , Pavel Pisa Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost Tested-by: Pavel Pisa --- Cc: Pavel Pisa Cc: Vikram Garhwal Cc: Jason Wang Cc: qemu-devel@nongnu.org --- net/can/can_host.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/net/can/can_host.c b/net/can/can_host.c index be4547d913..bec88b9620 100644 --- a/net/can/can_host.c +++ b/net/can/can_host.c @@ -72,21 +72,16 @@ static void can_host_complete(UserCreatable *uc, Error **errp) can_host_connect(CAN_HOST(uc), errp); } -static void can_host_instance_init(Object *obj) -{ - CanHostState *ch = CAN_HOST(obj); - - object_property_add_link(obj, "canbus", TYPE_CAN_BUS, - (Object **)&ch->bus, - object_property_allow_set_link, - OBJ_PROP_LINK_STRONG); -} - static void can_host_class_init(ObjectClass *klass, void *class_data G_GNUC_UNUSED) { UserCreatableClass *uc_klass = USER_CREATABLE_CLASS(klass); + object_class_property_add_link(klass, "canbus", TYPE_CAN_BUS, + offsetof(CanHostState, bus), + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG); + klass->unparent = can_host_unparent; uc_klass->complete = can_host_complete; } @@ -97,7 +92,6 @@ static const TypeInfo can_host_info = { .instance_size = sizeof(CanHostState), .class_size = sizeof(CanHostClass), .abstract = true, - .instance_init = can_host_instance_init, .class_init = can_host_class_init, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, From patchwork Fri Oct 9 16:01:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 303316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C8E6C433DF for ; Fri, 9 Oct 2020 16:08:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD0292225D for ; Fri, 9 Oct 2020 16:08:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X3SiXk97" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD0292225D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQuwX-0002Ry-Qp for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:08:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuqB-0003nZ-Ni for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuq9-00019Q-6l for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:01:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ieqbab86Rfeh1OrZIz62JdalD0ysqKb7dWKqPrptghw=; b=X3SiXk97buwWh2dAnDOZQoB6mDFsR3e+/MQLMTRSD7mt5cR8skA+XRQP1TTzzhdYpTKM+u KAmGTEguY1n62oOewqI1MZQusH8BPSqPA+mHSki7NLV7WirpMmsJDFrpWUZ8d9dgmOqJg2 C2gWVlvqfZSrfL+uGqQb/uM0skqWWhk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-0jqnRlTFM5C_4We3ZfvVkg-1; Fri, 09 Oct 2020 12:01:48 -0400 X-MC-Unique: 0jqnRlTFM5C_4We3ZfvVkg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D35A107464A; Fri, 9 Oct 2020 16:01:47 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 234BF5DC17; Fri, 9 Oct 2020 16:01:46 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 07/12] colo: Use class properties Date: Fri, 9 Oct 2020 12:01:17 -0400 Message-Id: <20201009160122.1662082-8-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Li Zhijian , Jason Wang , Markus Armbruster , Zhang Chen , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost --- Cc: Zhang Chen Cc: Li Zhijian Cc: Jason Wang Cc: qemu-devel@nongnu.org --- net/colo-compare.c | 57 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 3a45d64175..017e82dd8b 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1375,6 +1375,35 @@ static void colo_compare_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + object_class_property_add_str(oc, "primary_in", + compare_get_pri_indev, compare_set_pri_indev); + object_class_property_add_str(oc, "secondary_in", + compare_get_sec_indev, compare_set_sec_indev); + object_class_property_add_str(oc, "outdev", + compare_get_outdev, compare_set_outdev); + object_class_property_add_link(oc, "iothread", TYPE_IOTHREAD, + offsetof(CompareState, iothread), + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG); + /* This parameter just for Xen COLO */ + object_class_property_add_str(oc, "notify_dev", + compare_get_notify_dev, compare_set_notify_dev); + + object_class_property_add(oc, "compare_timeout", "uint32", + compare_get_timeout, + compare_set_timeout, NULL, NULL); + + object_class_property_add(oc, "expired_scan_cycle", "uint32", + compare_get_expired_scan_cycle, + compare_set_expired_scan_cycle, NULL, NULL); + + object_class_property_add(oc, "max_queue_size", "uint32", + get_max_queue_size, + set_max_queue_size, NULL, NULL); + + object_class_property_add_bool(oc, "vnet_hdr_support", compare_get_vnet_hdr, + compare_set_vnet_hdr); + ucc->complete = colo_compare_complete; } @@ -1382,35 +1411,7 @@ static void colo_compare_init(Object *obj) { CompareState *s = COLO_COMPARE(obj); - object_property_add_str(obj, "primary_in", - compare_get_pri_indev, compare_set_pri_indev); - object_property_add_str(obj, "secondary_in", - compare_get_sec_indev, compare_set_sec_indev); - object_property_add_str(obj, "outdev", - compare_get_outdev, compare_set_outdev); - object_property_add_link(obj, "iothread", TYPE_IOTHREAD, - (Object **)&s->iothread, - object_property_allow_set_link, - OBJ_PROP_LINK_STRONG); - /* This parameter just for Xen COLO */ - object_property_add_str(obj, "notify_dev", - compare_get_notify_dev, compare_set_notify_dev); - - object_property_add(obj, "compare_timeout", "uint32", - compare_get_timeout, - compare_set_timeout, NULL, NULL); - - object_property_add(obj, "expired_scan_cycle", "uint32", - compare_get_expired_scan_cycle, - compare_set_expired_scan_cycle, NULL, NULL); - - object_property_add(obj, "max_queue_size", "uint32", - get_max_queue_size, - set_max_queue_size, NULL, NULL); - s->vnet_hdr = false; - object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr, - compare_set_vnet_hdr); } static void colo_compare_finalize(Object *obj) From patchwork Fri Oct 9 16:01:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 303309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31EFDC433DF for ; Fri, 9 Oct 2020 16:22:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B13822225D for ; Fri, 9 Oct 2020 16:22:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R+EdWXqA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B13822225D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv9i-000250-NZ for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:22:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuqQ-0003y2-0p for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36285) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuqH-0001AP-SO for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259317; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gDUmdghtMAyCegm7L5TJffotsreIuyhWtE7FUPEkJ/8=; b=R+EdWXqAse/4wqcYq1bEroqg6xedj23i5wcrTW3/ojaqW0sHVMBO1VOrz4ve/fEV6gmBiQ LjMFpf2Ucz4lV7VX0B6i32xLqi4CRuK8lJZkOeecOgfUv+3fXH7RNkeIW93As1OdovU1ua 953EOZwXuwWUpxmxJFtvB2ixapu0Bno= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-NaKwDGiLN2S7OzmPNkWy_A-1; Fri, 09 Oct 2020 12:01:52 -0400 X-MC-Unique: NaKwDGiLN2S7OzmPNkWy_A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0493801F95; Fri, 9 Oct 2020 16:01:51 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9669E38A; Fri, 9 Oct 2020 16:01:48 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 08/12] netfilter: Reorder functions Date: Fri, 9 Oct 2020 12:01:18 -0400 Message-Id: <20201009160122.1662082-9-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Li Zhijian , Jason Wang , Markus Armbruster , Zhang Chen , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Trivial code reordering in some filter backends, to make the next changes easier to review. Signed-off-by: Eduardo Habkost --- Cc: Jason Wang Cc: Zhang Chen Cc: Li Zhijian Cc: qemu-devel@nongnu.org --- net/filter-buffer.c | 20 ++++++++++---------- net/filter-mirror.c | 36 ++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/net/filter-buffer.c b/net/filter-buffer.c index d8392be53c..95e384865f 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -144,16 +144,6 @@ static void filter_buffer_status_changed(NetFilterState *nf, Error **errp) } } -static void filter_buffer_class_init(ObjectClass *oc, void *data) -{ - NetFilterClass *nfc = NETFILTER_CLASS(oc); - - nfc->setup = filter_buffer_setup; - nfc->cleanup = filter_buffer_cleanup; - nfc->receive_iov = filter_buffer_receive_iov; - nfc->status_changed = filter_buffer_status_changed; -} - static void filter_buffer_get_interval(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -182,6 +172,16 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v, s->interval = value; } +static void filter_buffer_class_init(ObjectClass *oc, void *data) +{ + NetFilterClass *nfc = NETFILTER_CLASS(oc); + + nfc->setup = filter_buffer_setup; + nfc->cleanup = filter_buffer_cleanup; + nfc->receive_iov = filter_buffer_receive_iov; + nfc->status_changed = filter_buffer_status_changed; +} + static void filter_buffer_init(Object *obj) { object_property_add(obj, "interval", "uint32", diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 088d4dcace..26b783011a 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -284,24 +284,6 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp) } } -static void filter_mirror_class_init(ObjectClass *oc, void *data) -{ - NetFilterClass *nfc = NETFILTER_CLASS(oc); - - nfc->setup = filter_mirror_setup; - nfc->cleanup = filter_mirror_cleanup; - nfc->receive_iov = filter_mirror_receive_iov; -} - -static void filter_redirector_class_init(ObjectClass *oc, void *data) -{ - NetFilterClass *nfc = NETFILTER_CLASS(oc); - - nfc->setup = filter_redirector_setup; - nfc->cleanup = filter_redirector_cleanup; - nfc->receive_iov = filter_redirector_receive_iov; -} - static char *filter_redirector_get_indev(Object *obj, Error **errp) { MirrorState *s = FILTER_REDIRECTOR(obj); @@ -388,6 +370,24 @@ static void filter_redirector_set_vnet_hdr(Object *obj, s->vnet_hdr = value; } +static void filter_mirror_class_init(ObjectClass *oc, void *data) +{ + NetFilterClass *nfc = NETFILTER_CLASS(oc); + + nfc->setup = filter_mirror_setup; + nfc->cleanup = filter_mirror_cleanup; + nfc->receive_iov = filter_mirror_receive_iov; +} + +static void filter_redirector_class_init(ObjectClass *oc, void *data) +{ + NetFilterClass *nfc = NETFILTER_CLASS(oc); + + nfc->setup = filter_redirector_setup; + nfc->cleanup = filter_redirector_cleanup; + nfc->receive_iov = filter_redirector_receive_iov; +} + static void filter_mirror_init(Object *obj) { MirrorState *s = FILTER_MIRROR(obj); From patchwork Fri Oct 9 16:01:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 303311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFE2FC433DF for ; Fri, 9 Oct 2020 16:19:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 711102225D for ; Fri, 9 Oct 2020 16:19:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QIaq0T0w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 711102225D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv70-0006GK-HC for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:19:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuqN-0003uZ-O1 for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuqJ-0001AU-Pe for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NiK1eGhRYiWBwFt5WcyRbVIOl/6mfFts0JPaOb20ZeA=; b=QIaq0T0wPG/rVgkJhonDL5rlzxwsjv7/5NP7YFbjho8t7UN5so1AsSbfbAMusAfEoeqQ+o SqOeldkh3irtmmUjgWq9HhJhhQIFSCyDklYsBKjCzKU7ilyA/EzL66lTOzVtpId99DGu92 YMmxIUZ60f0Gy5cUKON6HhH+CBRp0d0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-484-000dvkytMsaQqpl0ocHdJA-1; Fri, 09 Oct 2020 12:01:56 -0400 X-MC-Unique: 000dvkytMsaQqpl0ocHdJA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F6A0803F74; Fri, 9 Oct 2020 16:01:55 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 575637EB77; Fri, 9 Oct 2020 16:01:52 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 09/12] netfilter: Use class properties Date: Fri, 9 Oct 2020 12:01:19 -0400 Message-Id: <20201009160122.1662082-10-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Li Zhijian , Jason Wang , Markus Armbruster , Zhang Chen , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost --- Cc: Jason Wang Cc: Zhang Chen Cc: Li Zhijian Cc: qemu-devel@nongnu.org --- net/dump.c | 10 +++++----- net/filter-buffer.c | 12 ++++-------- net/filter-mirror.c | 28 ++++++++++++++-------------- net/filter-rewriter.c | 7 ++++--- net/filter.c | 24 ++++++++++++------------ 5 files changed, 39 insertions(+), 42 deletions(-) diff --git a/net/dump.c b/net/dump.c index 7fd448d2e1..4d538d82a6 100644 --- a/net/dump.c +++ b/net/dump.c @@ -224,11 +224,6 @@ static void filter_dump_instance_init(Object *obj) NetFilterDumpState *nfds = FILTER_DUMP(obj); nfds->maxlen = 65536; - - object_property_add(obj, "maxlen", "uint32", filter_dump_get_maxlen, - filter_dump_set_maxlen, NULL, NULL); - object_property_add_str(obj, "file", file_dump_get_filename, - file_dump_set_filename); } static void filter_dump_instance_finalize(Object *obj) @@ -242,6 +237,11 @@ static void filter_dump_class_init(ObjectClass *oc, void *data) { NetFilterClass *nfc = NETFILTER_CLASS(oc); + object_class_property_add(oc, "maxlen", "uint32", filter_dump_get_maxlen, + filter_dump_set_maxlen, NULL, NULL); + object_class_property_add_str(oc, "file", file_dump_get_filename, + file_dump_set_filename); + nfc->setup = filter_dump_setup; nfc->cleanup = filter_dump_cleanup; nfc->receive_iov = filter_dump_receive_iov; diff --git a/net/filter-buffer.c b/net/filter-buffer.c index 95e384865f..283dc9cbe6 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -176,24 +176,20 @@ static void filter_buffer_class_init(ObjectClass *oc, void *data) { NetFilterClass *nfc = NETFILTER_CLASS(oc); + object_class_property_add(oc, "interval", "uint32", + filter_buffer_get_interval, + filter_buffer_set_interval, NULL, NULL); + nfc->setup = filter_buffer_setup; nfc->cleanup = filter_buffer_cleanup; nfc->receive_iov = filter_buffer_receive_iov; nfc->status_changed = filter_buffer_status_changed; } -static void filter_buffer_init(Object *obj) -{ - object_property_add(obj, "interval", "uint32", - filter_buffer_get_interval, - filter_buffer_set_interval, NULL, NULL); -} - static const TypeInfo filter_buffer_info = { .name = TYPE_FILTER_BUFFER, .parent = TYPE_NETFILTER, .class_init = filter_buffer_class_init, - .instance_init = filter_buffer_init, .instance_size = sizeof(FilterBufferState), }; diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 26b783011a..f8e65007c0 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -374,6 +374,12 @@ static void filter_mirror_class_init(ObjectClass *oc, void *data) { NetFilterClass *nfc = NETFILTER_CLASS(oc); + object_class_property_add_str(oc, "outdev", filter_mirror_get_outdev, + filter_mirror_set_outdev); + object_class_property_add_bool(oc, "vnet_hdr_support", + filter_mirror_get_vnet_hdr, + filter_mirror_set_vnet_hdr); + nfc->setup = filter_mirror_setup; nfc->cleanup = filter_mirror_cleanup; nfc->receive_iov = filter_mirror_receive_iov; @@ -383,6 +389,14 @@ static void filter_redirector_class_init(ObjectClass *oc, void *data) { NetFilterClass *nfc = NETFILTER_CLASS(oc); + object_class_property_add_str(oc, "indev", filter_redirector_get_indev, + filter_redirector_set_indev); + object_class_property_add_str(oc, "outdev", filter_redirector_get_outdev, + filter_redirector_set_outdev); + object_class_property_add_bool(oc, "vnet_hdr_support", + filter_redirector_get_vnet_hdr, + filter_redirector_set_vnet_hdr); + nfc->setup = filter_redirector_setup; nfc->cleanup = filter_redirector_cleanup; nfc->receive_iov = filter_redirector_receive_iov; @@ -392,28 +406,14 @@ static void filter_mirror_init(Object *obj) { MirrorState *s = FILTER_MIRROR(obj); - object_property_add_str(obj, "outdev", filter_mirror_get_outdev, - filter_mirror_set_outdev); - s->vnet_hdr = false; - object_property_add_bool(obj, "vnet_hdr_support", - filter_mirror_get_vnet_hdr, - filter_mirror_set_vnet_hdr); } static void filter_redirector_init(Object *obj) { MirrorState *s = FILTER_REDIRECTOR(obj); - object_property_add_str(obj, "indev", filter_redirector_get_indev, - filter_redirector_set_indev); - object_property_add_str(obj, "outdev", filter_redirector_get_outdev, - filter_redirector_set_outdev); - s->vnet_hdr = false; - object_property_add_bool(obj, "vnet_hdr_support", - filter_redirector_get_vnet_hdr, - filter_redirector_set_vnet_hdr); } static void filter_mirror_fini(Object *obj) diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index dc3c27a489..ae358059d9 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -416,15 +416,16 @@ static void filter_rewriter_init(Object *obj) s->vnet_hdr = false; s->failover_mode = FAILOVER_MODE_OFF; - object_property_add_bool(obj, "vnet_hdr_support", - filter_rewriter_get_vnet_hdr, - filter_rewriter_set_vnet_hdr); } static void colo_rewriter_class_init(ObjectClass *oc, void *data) { NetFilterClass *nfc = NETFILTER_CLASS(oc); + object_class_property_add_bool(oc, "vnet_hdr_support", + filter_rewriter_get_vnet_hdr, + filter_rewriter_set_vnet_hdr); + nfc->setup = colo_rewriter_setup; nfc->cleanup = colo_rewriter_cleanup; nfc->receive_iov = colo_rewriter_receive_iov; diff --git a/net/filter.c b/net/filter.c index eac8ba1e9c..3fe88fa43f 100644 --- a/net/filter.c +++ b/net/filter.c @@ -212,18 +212,6 @@ static void netfilter_init(Object *obj) nf->on = true; nf->insert_before_flag = false; nf->position = g_strdup("tail"); - - object_property_add_str(obj, "netdev", - netfilter_get_netdev_id, netfilter_set_netdev_id); - object_property_add_enum(obj, "queue", "NetFilterDirection", - &NetFilterDirection_lookup, - netfilter_get_direction, netfilter_set_direction); - object_property_add_str(obj, "status", - netfilter_get_status, netfilter_set_status); - object_property_add_str(obj, "position", - netfilter_get_position, netfilter_set_position); - object_property_add_str(obj, "insert", - netfilter_get_insert, netfilter_set_insert); } static void netfilter_complete(UserCreatable *uc, Error **errp) @@ -350,6 +338,18 @@ static void netfilter_class_init(ObjectClass *oc, void *data) UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); NetFilterClass *nfc = NETFILTER_CLASS(oc); + object_class_property_add_str(oc, "netdev", + netfilter_get_netdev_id, netfilter_set_netdev_id); + object_class_property_add_enum(oc, "queue", "NetFilterDirection", + &NetFilterDirection_lookup, + netfilter_get_direction, netfilter_set_direction); + object_class_property_add_str(oc, "status", + netfilter_get_status, netfilter_set_status); + object_class_property_add_str(oc, "position", + netfilter_get_position, netfilter_set_position); + object_class_property_add_str(oc, "insert", + netfilter_get_insert, netfilter_set_insert); + ucc->complete = netfilter_complete; nfc->handle_event = default_handle_event; } From patchwork Fri Oct 9 16:01:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 303314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC9EAC43467 for ; Fri, 9 Oct 2020 16:11:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 799272227E for ; Fri, 9 Oct 2020 16:11:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OjbjTYWY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 799272227E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQuzC-00060x-8M for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:11:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuqP-0003wM-AB for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34825) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuqM-0001Cx-Bk for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x/0WU02UGw93rIL/U7xfUdD3VvJQmzc6XB5lCRxb7ac=; b=OjbjTYWYVrO6uhi9N9LVHpB9XGlgtyyvHD2j110uW/zMi+uZNXluaerlrX8uEAGMKN+Ns6 XAvl3uY/sHNKV9q0jsoWJlD1x9vBWsvreIfsuTEMZmqFjdwfcvegSFL3j8CsBE996CGdzP /XzFEZWHnGEVL1NRB+hWI6+Ic7fnyKQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-OPSQWlvbPbKlaXr9hbZ92w-1; Fri, 09 Oct 2020 12:02:03 -0400 X-MC-Unique: OPSQWlvbPbKlaXr9hbZ92w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E2E2835B50 for ; Fri, 9 Oct 2020 16:02:02 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D6815C1C7; Fri, 9 Oct 2020 16:01:56 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 10/12] input: Use class properties Date: Fri, 9 Oct 2020 12:01:20 -0400 Message-Id: <20201009160122.1662082-11-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow , Markus Armbruster , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instance properties make introspection hard and are not shown by "-object ...,help". Convert them to class properties. Signed-off-by: Eduardo Habkost Acked-by: Gerd Hoffmann --- Cc: Gerd Hoffmann Cc: qemu-devel@nongnu.org --- ui/input-barrier.c | 44 ++++++++++++++++++++++---------------------- ui/input-linux.c | 27 ++++++++++++++------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/ui/input-barrier.c b/ui/input-barrier.c index a047919fde..8e886a6495 100644 --- a/ui/input-barrier.c +++ b/ui/input-barrier.c @@ -689,34 +689,34 @@ static void input_barrier_instance_init(Object *obj) ib->y_origin = 0; ib->width = 1920; ib->height = 1080; - - object_property_add_str(obj, "name", - input_barrier_get_name, - input_barrier_set_name); - object_property_add_str(obj, "server", - input_barrier_get_server, - input_barrier_set_server); - object_property_add_str(obj, "port", - input_barrier_get_port, - input_barrier_set_port); - object_property_add_str(obj, "x-origin", - input_barrier_get_x_origin, - input_barrier_set_x_origin); - object_property_add_str(obj, "y-origin", - input_barrier_get_y_origin, - input_barrier_set_y_origin); - object_property_add_str(obj, "width", - input_barrier_get_width, - input_barrier_set_width); - object_property_add_str(obj, "height", - input_barrier_get_height, - input_barrier_set_height); } static void input_barrier_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + object_class_property_add_str(oc, "name", + input_barrier_get_name, + input_barrier_set_name); + object_class_property_add_str(oc, "server", + input_barrier_get_server, + input_barrier_set_server); + object_class_property_add_str(oc, "port", + input_barrier_get_port, + input_barrier_set_port); + object_class_property_add_str(oc, "x-origin", + input_barrier_get_x_origin, + input_barrier_set_x_origin); + object_class_property_add_str(oc, "y-origin", + input_barrier_get_y_origin, + input_barrier_set_y_origin); + object_class_property_add_str(oc, "width", + input_barrier_get_width, + input_barrier_set_width); + object_class_property_add_str(oc, "height", + input_barrier_get_height, + input_barrier_set_height); + ucc->complete = input_barrier_complete; } diff --git a/ui/input-linux.c b/ui/input-linux.c index ab351a4187..df3dff8898 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -489,25 +489,26 @@ static void input_linux_set_grab_toggle(Object *obj, int value, static void input_linux_instance_init(Object *obj) { - object_property_add_str(obj, "evdev", - input_linux_get_evdev, - input_linux_set_evdev); - object_property_add_bool(obj, "grab_all", - input_linux_get_grab_all, - input_linux_set_grab_all); - object_property_add_bool(obj, "repeat", - input_linux_get_repeat, - input_linux_set_repeat); - object_property_add_enum(obj, "grab-toggle", "GrabToggleKeys", - &GrabToggleKeys_lookup, - input_linux_get_grab_toggle, - input_linux_set_grab_toggle); } static void input_linux_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + object_class_property_add_str(oc, "evdev", + input_linux_get_evdev, + input_linux_set_evdev); + object_class_property_add_bool(oc, "grab_all", + input_linux_get_grab_all, + input_linux_set_grab_all); + object_class_property_add_bool(oc, "repeat", + input_linux_get_repeat, + input_linux_set_repeat); + object_class_property_add_enum(oc, "grab-toggle", "GrabToggleKeys", + &GrabToggleKeys_lookup, + input_linux_get_grab_toggle, + input_linux_set_grab_toggle); + ucc->complete = input_linux_complete; } From patchwork Fri Oct 9 16:01:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B19EC43457 for ; Fri, 9 Oct 2020 16:10:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8838C2227E for ; Fri, 9 Oct 2020 16:10:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MdH67Bdv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8838C2227E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQuy0-0004fk-KO for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:10:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuqX-0003zi-GG for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuqR-0001Dg-Qn for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V6ZeMhapG7XRhWAt5UK9AHGNMYXnP5KbDP4eNV88Xtw=; b=MdH67BdvSL4hmpgVwvkmeuBWeHNWB8of4fH0XYL6L8s70wsGPzolncVCXn5x3BLV2zf5wW 88UOMAiBW2A4OWGkbV/uCPQ9FkkltxYhRpRwDk2DtegDCj8/Yss59wgcUPxRKeJLxZYEmH gmS5YKkWGvztMKHy1njKYuAWNx05kps= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-330oxqEBOomz438RgQoKhA-1; Fri, 09 Oct 2020 12:02:07 -0400 X-MC-Unique: 330oxqEBOomz438RgQoKhA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 798351007B00 for ; Fri, 9 Oct 2020 16:02:06 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46E157665B; Fri, 9 Oct 2020 16:02:03 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 11/12] [RFC] qom: Property lock mechanism Date: Fri, 9 Oct 2020 12:01:21 -0400 Message-Id: <20201009160122.1662082-12-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a mechanism to allow QOM types to prevent writable instance properties from being registered. This will be used by types that expose all QOM properties in user-visible interfaces like object-add and device_add, to ensure our external interfaces are not affected by dynamic QOM properties. Signed-off-by: Eduardo Habkost --- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- include/qom/object.h | 17 +++++++++ qom/object.c | 28 ++++++++++++++ tests/test-qdev-global-props.c | 70 ++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 1634294e4f..a124cf897d 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -137,6 +137,8 @@ struct ObjectClass ObjectUnparent *unparent; GHashTable *properties; + /* instance properties locked. See object_class_lock_properties() */ + bool properties_locked; }; /** @@ -1867,6 +1869,21 @@ void object_property_set_description(Object *obj, const char *name, void object_class_property_set_description(ObjectClass *klass, const char *name, const char *description); +/** + * object_class_lock_properties: + * @oc: the object class to have properties locked + * + * Prevent all subtypes of @oc from having writeable instance + * properties. If @oc is an interface type, this also affects all + * classes implementing the interface. + * + * This can be used by QOM types that have all QOM properties + * exposed to the external world (e.g. #TYPE_USER_CREATABLE) to + * ensure all user-writable properties are introspectable at the + * class level. + */ +void object_class_lock_properties(ObjectClass *oc); + /** * object_child_foreach: * @obj: the object whose children will be navigated diff --git a/qom/object.c b/qom/object.c index bb32f5d3ad..73f27b8b7e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -498,6 +498,27 @@ static void object_class_property_init_all(Object *obj) } } +void object_class_lock_properties(ObjectClass *oc) +{ + oc->properties_locked = true; +} + +static bool object_class_properties_locked(ObjectClass *oc) +{ + GSList *i = NULL; + + if (oc->properties_locked) { + return true; + } + for (i = oc->interfaces; i; i = i->next) { + ObjectClass *ic = i->data; + if (ic->properties_locked) { + return true; + } + } + return false; +} + static void object_initialize_with_type(Object *obj, size_t size, TypeImpl *type) { type_initialize(type); @@ -1192,8 +1213,15 @@ object_property_try_add(Object *obj, const char *name, const char *type, void *opaque, Error **errp) { ObjectProperty *prop; + ObjectClass *oc = object_get_class(obj); size_t name_len = strlen(name); + if (set && object_class_properties_locked(oc)) { + error_setg(errp, "writable instance property not allowed for type %s", + object_class_get_name(oc)); + return NULL; + } + if (name_len >= 3 && !memcmp(name + name_len - 3, "[*]", 4)) { int i; ObjectProperty *ret; diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index c8862cac5f..590c916c4b 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -58,6 +58,9 @@ static void static_prop_class_init(ObjectClass *oc, void *data) dc->realize = NULL; device_class_set_props(dc, static_props); + + /* test_proplist_lock() will check if property locking works */ + object_class_lock_properties(oc); } static const TypeInfo static_prop_type = { @@ -213,6 +216,69 @@ static const TypeInfo nondevice_type = { .parent = TYPE_OBJECT, }; +static void locked_interface_class_base_init(ObjectClass *klass, void *data) +{ + object_class_lock_properties(klass); +} + +#define TYPE_LOCKED_INTERFACE "locked-interface" +static const TypeInfo locked_interface_type = { + .name = TYPE_LOCKED_INTERFACE, + .parent = TYPE_INTERFACE, + .class_base_init = locked_interface_class_base_init, +}; + +#define TYPE_LOCKED_BY_INTERFACE "locked-by-interface" +static const TypeInfo locked_by_interface_type = { + .name = TYPE_LOCKED_BY_INTERFACE, + .parent = TYPE_OBJECT, + .interfaces = (InterfaceInfo[]) { + { TYPE_LOCKED_INTERFACE }, + { }, + }, +}; + +/* Make sure QOM property locking works as expected */ +static void test_proplist_lock(void) +{ + g_autoptr(Object) dynamic_obj = object_new(TYPE_DYNAMIC_PROPS); + g_autoptr(Object) static_obj = object_new(TYPE_STATIC_PROPS); + g_autoptr(Object) locked = object_new(TYPE_LOCKED_BY_INTERFACE); + Error *err = NULL; + + /* read-only property: should always work */ + object_property_try_add(dynamic_obj, "dynamic-prop-ro", "uint32", + prop1_accessor, NULL, + NULL, NULL, &error_abort); + object_property_try_add(static_obj, "dynamic-prop-ro", "uint32", + prop1_accessor, NULL, + NULL, NULL, &error_abort); + object_property_try_add(locked, "dynamic-prop-ro", "uint32", + prop1_accessor, NULL, + NULL, NULL, &error_abort); + + + /* read-write property: */ + + /* TYPE_DYNAMIC_PROPS is not locked */ + object_property_try_add(dynamic_obj, "dynamic-prop-rw", "uint32", + prop1_accessor, prop1_accessor, + NULL, NULL, &error_abort); + + /* TYPE_STATIC_PROPS is locked */ + object_property_try_add(static_obj, "dynamic-prop-rw", "uint32", + prop1_accessor, prop1_accessor, + NULL, NULL, &err); + error_free_or_abort(&err); + + /* TYPE_LOCKED_BY_INTERFACE is locked by interface type */ + object_property_try_add(locked, "dynamic-prop-rw", "uint32", + prop1_accessor, prop1_accessor, + NULL, NULL, &err); + error_free_or_abort(&err); +} + + /* Test setting of dynamic properties using global properties */ static void test_dynamic_globalprop_subprocess(void) { @@ -294,6 +360,10 @@ int main(int argc, char **argv) type_register_static(&hotplug_type); type_register_static(&nohotplug_type); type_register_static(&nondevice_type); + type_register_static(&locked_interface_type); + type_register_static(&locked_by_interface_type); + + g_test_add_func("/qdev/properties/locking", test_proplist_lock); g_test_add_func("/qdev/properties/static/default/subprocess", test_static_prop_subprocess); From patchwork Fri Oct 9 16:01:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 271729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73A6CC433E7 for ; Fri, 9 Oct 2020 16:13:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 20E182225D for ; Fri, 9 Oct 2020 16:13:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bEF6P2Rw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20E182225D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQv17-0008K0-C0 for qemu-devel@archiver.kernel.org; Fri, 09 Oct 2020 12:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQuqe-000407-Si for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kQuqX-0001E0-8E for qemu-devel@nongnu.org; Fri, 09 Oct 2020 12:02:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602259334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3K8tXU6aq8VGFAZW5fsFeYLPxQQLh3GInrtH5l6YUng=; b=bEF6P2RwoiK6L52FliD1MYg7EEaX/SV1jAbY7Wyv5g9LytYkHJxi+L5lvQ3qDzYoFpxBO2 WEo68/lbhw/d7t70gA+AMZ9enSUjXXLaN17K68GfHWGNulWLr1OeNv2FF0/nOcBnaBnahS Md0KBaUSJ8nuutX9Lgt0OGWvINyN6uY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-N57T0fw8MyKAWd0hLA-Seg-1; Fri, 09 Oct 2020 12:02:11 -0400 X-MC-Unique: N57T0fw8MyKAWd0hLA-Seg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6EA518A073A for ; Fri, 9 Oct 2020 16:02:10 +0000 (UTC) Received: from localhost (ovpn-119-102.rdu2.redhat.com [10.10.119.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AA2460BE2; Fri, 9 Oct 2020 16:02:07 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 12/12] [RFC] qom: Lock properties of all TYPE_USER_CREATABLE types Date: Fri, 9 Oct 2020 12:01:22 -0400 Message-Id: <20201009160122.1662082-13-ehabkost@redhat.com> In-Reply-To: <20201009160122.1662082-1-ehabkost@redhat.com> References: <20201009160122.1662082-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/09 02:34:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" TYPE_USER_CREATABLE types expose all QOM properties through `-object` and `object-add`. Lock the properties on TYPE_USER_CREATABLE so we will never add new writable instance properties to those types. Signed-off-by: Eduardo Habkost --- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- qom/object_interfaces.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e8e1523960..40123d4b50 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -293,6 +293,16 @@ bool user_creatable_del(const char *id, Error **errp) return true; } +static void user_creatable_class_init(ObjectClass *klass, void *data) +{ + /* + * User-creatable QOM types expose all writable QOM properties + * to the external world through `-object` and `object-add`, + * so all writable properties must be registered at class level. + */ + object_class_lock_properties(klass); +} + void user_creatable_cleanup(void) { object_unparent(object_get_objects_root()); @@ -304,6 +314,7 @@ static void register_types(void) .name = TYPE_USER_CREATABLE, .parent = TYPE_INTERFACE, .class_size = sizeof(UserCreatableClass), + .class_init = user_creatable_class_init, }; type_register_static(&uc_interface_info);