Instance properties make introspection hard and are not shown by
"-object ...,help".  Convert them to class properties.

Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
Cc: Laurent Vivier <lviv...@redhat.com>
Cc: Amit Shah <a...@kernel.org>
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;
 }
 
-- 
2.26.2


Reply via email to