diff mbox series

[01/24] cryptodev-vhost-user: Register "chardev" as class property

Message ID 20200921221045.699690-2-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: "Gonglei (Arei)" <arei.gonglei@huawei.com>
Cc: qemu-devel@nongnu.org
---
 backends/cryptodev-vhost-user.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Gonglei (Arei) Sept. 22, 2020, 1:27 a.m. UTC | #1
> -----Original Message-----
> From: Eduardo Habkost [mailto:ehabkost@redhat.com]
> Sent: Tuesday, September 22, 2020 6:10 AM
> To: qemu-devel@nongnu.org
> Cc: Paolo Bonzini <pbonzini@redhat.com>; Daniel P. Berrange
> <berrange@redhat.com>; John Snow <jsnow@redhat.com>; Gonglei (Arei)
> <arei.gonglei@huawei.com>
> Subject: [PATCH 01/24] cryptodev-vhost-user: Register "chardev" as class
> property
> 
> 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: "Gonglei (Arei)" <arei.gonglei@huawei.com>
> Cc: qemu-devel@nongnu.org
> ---

Reviewed-by: Gonglei <arei.gonglei@huawei.com>

Regards,
-Gonglei

>  backends/cryptodev-vhost-user.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/backends/cryptodev-vhost-user.c
> b/backends/cryptodev-vhost-user.c index 41089dede15..690738c6c95
> 100644
> --- a/backends/cryptodev-vhost-user.c
> +++ b/backends/cryptodev-vhost-user.c
> @@ -336,13 +336,6 @@ cryptodev_vhost_user_get_chardev(Object *obj,
> Error **errp)
>      return NULL;
>  }
> 
> -static void cryptodev_vhost_user_instance_int(Object *obj) -{
> -    object_property_add_str(obj, "chardev",
> -                            cryptodev_vhost_user_get_chardev,
> -                            cryptodev_vhost_user_set_chardev);
> -}
> -
>  static void cryptodev_vhost_user_finalize(Object *obj)  {
>      CryptoDevBackendVhostUser *s =
> @@ -363,13 +356,17 @@ cryptodev_vhost_user_class_init(ObjectClass *oc,
> void *data)
>      bc->create_session = cryptodev_vhost_user_sym_create_session;
>      bc->close_session = cryptodev_vhost_user_sym_close_session;
>      bc->do_sym_op = NULL;
> +
> +    object_class_property_add_str(oc, "chardev",
> +                                  cryptodev_vhost_user_get_chardev,
> +                                  cryptodev_vhost_user_set_chardev);
> +
>  }
> 
>  static const TypeInfo cryptodev_vhost_user_info = {
>      .name = TYPE_CRYPTODEV_BACKEND_VHOST_USER,
>      .parent = TYPE_CRYPTODEV_BACKEND,
>      .class_init = cryptodev_vhost_user_class_init,
> -    .instance_init = cryptodev_vhost_user_instance_int,
>      .instance_finalize = cryptodev_vhost_user_finalize,
>      .instance_size = sizeof(CryptoDevBackendVhostUser),
>  };
> --
> 2.26.2
diff mbox series

Patch

diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index 41089dede15..690738c6c95 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -336,13 +336,6 @@  cryptodev_vhost_user_get_chardev(Object *obj, Error **errp)
     return NULL;
 }
 
-static void cryptodev_vhost_user_instance_int(Object *obj)
-{
-    object_property_add_str(obj, "chardev",
-                            cryptodev_vhost_user_get_chardev,
-                            cryptodev_vhost_user_set_chardev);
-}
-
 static void cryptodev_vhost_user_finalize(Object *obj)
 {
     CryptoDevBackendVhostUser *s =
@@ -363,13 +356,17 @@  cryptodev_vhost_user_class_init(ObjectClass *oc, void *data)
     bc->create_session = cryptodev_vhost_user_sym_create_session;
     bc->close_session = cryptodev_vhost_user_sym_close_session;
     bc->do_sym_op = NULL;
+
+    object_class_property_add_str(oc, "chardev",
+                                  cryptodev_vhost_user_get_chardev,
+                                  cryptodev_vhost_user_set_chardev);
+
 }
 
 static const TypeInfo cryptodev_vhost_user_info = {
     .name = TYPE_CRYPTODEV_BACKEND_VHOST_USER,
     .parent = TYPE_CRYPTODEV_BACKEND,
     .class_init = cryptodev_vhost_user_class_init,
-    .instance_init = cryptodev_vhost_user_instance_int,
     .instance_finalize = cryptodev_vhost_user_finalize,
     .instance_size = sizeof(CryptoDevBackendVhostUser),
 };