diff mbox series

[03/24] rng-egd: Register "chardev" as class property

Message ID 20200921221045.699690-4-ehabkost@redhat.com
State New, archived
Headers show
Series qom: Convert some properties to class properties | expand

Commit Message

Eduardo Habkost Sept. 21, 2020, 10:10 p.m. UTC
Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Amit Shah <amit@kernel.org>
Cc: qemu-devel@nongnu.org
---
 backends/rng-egd.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Daniel P. Berrangé Sept. 23, 2020, 9:59 a.m. UTC | #1
On Mon, Sep 21, 2020 at 06:10:24PM -0400, Eduardo Habkost wrote:
> Class properties make QOM introspection simpler and easier, as
> they don't require an object to be instantiated.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Amit Shah <amit@kernel.org>
> Cc: qemu-devel@nongnu.org
> ---
>  backends/rng-egd.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
diff mbox series

Patch

diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index d905fe657c5..d3a8b1ebe2a 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -137,12 +137,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);
@@ -157,6 +151,8 @@  static void rng_egd_class_init(ObjectClass *klass, void *data)
 
     rbc->request_entropy = rng_egd_request_entropy;
     rbc->opened = rng_egd_opened;
+    object_class_property_add_str(klass, "chardev",
+                                  rng_egd_get_chardev, rng_egd_set_chardev);
 }
 
 static const TypeInfo rng_egd_info = {
@@ -164,7 +160,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,
 };