diff mbox series

[PULL,20/39] hw/s390x/s390-stattrib: Simplify handling of the "migration-enabled" property

Message ID 20231024131305.87468-21-quintela@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,01/39] migration/doc: Add contents | expand

Commit Message

Juan Quintela Oct. 24, 2023, 1:12 p.m. UTC
From: Thomas Huth <thuth@redhat.com>

There's no need for dedicated handlers here if they don't do anything
special.

Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231020150554.664422-3-thuth@redhat.com>
---
 hw/s390x/s390-stattrib.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

Comments

Thomas Huth Oct. 26, 2023, 3:37 p.m. UTC | #1
On 24/10/2023 15.12, Juan Quintela wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> There's no need for dedicated handlers here if they don't do anything
> special.
> 
> Acked-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Acked-by: Juan Quintela <quintela@redhat.com>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> Message-ID: <20231020150554.664422-3-thuth@redhat.com>
> ---
>   hw/s390x/s390-stattrib.c | 26 ++++++--------------------
>   1 file changed, 6 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
> index 220e845d12..52f9fc036e 100644
> --- a/hw/s390x/s390-stattrib.c
> +++ b/hw/s390x/s390-stattrib.c
> @@ -13,6 +13,7 @@
>   #include "qemu/units.h"
>   #include "migration/qemu-file.h"
>   #include "migration/register.h"
> +#include "hw/qdev-properties.h"
>   #include "hw/s390x/storage-attributes.h"
>   #include "qemu/error-report.h"
>   #include "exec/ram_addr.h"
> @@ -340,6 +341,10 @@ static void s390_stattrib_realize(DeviceState *dev, Error **errp)
>       }
>   }
>   
> +static Property s390_stattrib_props[] = {
> +    DEFINE_PROP_BOOL("migration-enabled", S390StAttribState, migration_enabled, true),

This needs a  DEFINE_PROP_END_OF_LIST() here, too ... sorry for that!
/me is looking for his brown paper-bags...

  Thomas

> +};
> +
>   static void s390_stattrib_class_init(ObjectClass *oc, void *data)
>   {
>       DeviceClass *dc = DEVICE_CLASS(oc);
> @@ -347,22 +352,7 @@ static void s390_stattrib_class_init(ObjectClass *oc, void *data)
>       dc->hotpluggable = false;
>       set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>       dc->realize = s390_stattrib_realize;
> -}
> -
> -static inline bool s390_stattrib_get_migration_enabled(Object *obj,
> -                                                       Error **errp)
> -{
> -    S390StAttribState *s = S390_STATTRIB(obj);
> -
> -    return s->migration_enabled;
> -}
> -
> -static inline void s390_stattrib_set_migration_enabled(Object *obj, bool value,
> -                                            Error **errp)
> -{
> -    S390StAttribState *s = S390_STATTRIB(obj);
> -
> -    s->migration_enabled = value;
> +    device_class_set_props(dc, s390_stattrib_props);
>   }
>   
>   static SaveVMHandlers savevm_s390_stattrib_handlers = {
> @@ -383,10 +373,6 @@ static void s390_stattrib_instance_init(Object *obj)
>       register_savevm_live(TYPE_S390_STATTRIB, 0, 0,
>                            &savevm_s390_stattrib_handlers, sas);
>   
> -    object_property_add_bool(obj, "migration-enabled",
> -                             s390_stattrib_get_migration_enabled,
> -                             s390_stattrib_set_migration_enabled);
> -    object_property_set_bool(obj, "migration-enabled", true, NULL);
>       sas->migration_cur_gfn = 0;
>   }
>
diff mbox series

Patch

diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 220e845d12..52f9fc036e 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -13,6 +13,7 @@ 
 #include "qemu/units.h"
 #include "migration/qemu-file.h"
 #include "migration/register.h"
+#include "hw/qdev-properties.h"
 #include "hw/s390x/storage-attributes.h"
 #include "qemu/error-report.h"
 #include "exec/ram_addr.h"
@@ -340,6 +341,10 @@  static void s390_stattrib_realize(DeviceState *dev, Error **errp)
     }
 }
 
+static Property s390_stattrib_props[] = {
+    DEFINE_PROP_BOOL("migration-enabled", S390StAttribState, migration_enabled, true),
+};
+
 static void s390_stattrib_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
@@ -347,22 +352,7 @@  static void s390_stattrib_class_init(ObjectClass *oc, void *data)
     dc->hotpluggable = false;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     dc->realize = s390_stattrib_realize;
-}
-
-static inline bool s390_stattrib_get_migration_enabled(Object *obj,
-                                                       Error **errp)
-{
-    S390StAttribState *s = S390_STATTRIB(obj);
-
-    return s->migration_enabled;
-}
-
-static inline void s390_stattrib_set_migration_enabled(Object *obj, bool value,
-                                            Error **errp)
-{
-    S390StAttribState *s = S390_STATTRIB(obj);
-
-    s->migration_enabled = value;
+    device_class_set_props(dc, s390_stattrib_props);
 }
 
 static SaveVMHandlers savevm_s390_stattrib_handlers = {
@@ -383,10 +373,6 @@  static void s390_stattrib_instance_init(Object *obj)
     register_savevm_live(TYPE_S390_STATTRIB, 0, 0,
                          &savevm_s390_stattrib_handlers, sas);
 
-    object_property_add_bool(obj, "migration-enabled",
-                             s390_stattrib_get_migration_enabled,
-                             s390_stattrib_set_migration_enabled);
-    object_property_set_bool(obj, "migration-enabled", true, NULL);
     sas->migration_cur_gfn = 0;
 }