diff mbox series

hw/ipmi: Move vmsd registration to device class

Message ID Z_AAPdpBWQjXq6fJ@mail.minyard.net (mailing list archive)
State New
Headers show
Series hw/ipmi: Move vmsd registration to device class | expand

Commit Message

Corey Minyard April 4, 2025, 3:52 p.m. UTC
It's the right way to do it now, and it handles multiple instances
properly.  I need multiple instances for some testing I'm doing so this
is the right thing to do.

Tested by doing:

   (qemu) migrate -d exec:cat>filen.mig

before and after the fix, then:

   scripts/analyze-migration.py -d desc -f file1.mig >file1.json
   scripts/analyze-migration.py -d desc -f file2.mig >file2.json
   diff file1.json file2.json

with no differences.

Signed-off-by: Corey Minyard <corey@minyard.net>
---
 hw/ipmi/ipmi_bmc_extern.c |  3 +--
 hw/ipmi/ipmi_bmc_sim.c    |  3 +--
 hw/ipmi/isa_ipmi_bt.c     |  3 +--
 hw/ipmi/isa_ipmi_kcs.c    | 12 +++++-------
 4 files changed, 8 insertions(+), 13 deletions(-)

Comments

Philippe Mathieu-Daudé April 4, 2025, 4:13 p.m. UTC | #1
Cc'ing migration maintainers

On 4/4/25 17:52, Corey Minyard wrote:
> It's the right way to do it now, and it handles multiple instances
> properly.  I need multiple instances for some testing I'm doing so this
> is the right thing to do.
> 
> Tested by doing:
> 
>     (qemu) migrate -d exec:cat>filen.mig
> 
> before and after the fix, then:
> 
>     scripts/analyze-migration.py -d desc -f file1.mig >file1.json
>     scripts/analyze-migration.py -d desc -f file2.mig >file2.json
>     diff file1.json file2.json
> 
> with no differences.
> 
> Signed-off-by: Corey Minyard <corey@minyard.net>
> ---
>   hw/ipmi/ipmi_bmc_extern.c |  3 +--
>   hw/ipmi/ipmi_bmc_sim.c    |  3 +--
>   hw/ipmi/isa_ipmi_bt.c     |  3 +--
>   hw/ipmi/isa_ipmi_kcs.c    | 12 +++++-------
>   4 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
> index d015500254..3e9f8c5a50 100644
> --- a/hw/ipmi/ipmi_bmc_extern.c
> +++ b/hw/ipmi/ipmi_bmc_extern.c
> @@ -497,8 +497,6 @@ static void ipmi_bmc_extern_realize(DeviceState *dev, Error **errp)
>   
>       qemu_chr_fe_set_handlers(&ibe->chr, can_receive, receive,
>                                chr_event, NULL, ibe, NULL, true);
> -
> -    vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
>   }
>   
>   static void ipmi_bmc_extern_init(Object *obj)
> @@ -528,6 +526,7 @@ static void ipmi_bmc_extern_class_init(ObjectClass *oc, void *data)
>       bk->handle_reset = ipmi_bmc_extern_handle_reset;
>       dc->hotpluggable = false;
>       dc->realize = ipmi_bmc_extern_realize;
> +    dc->vmsd = &vmstate_ipmi_bmc_extern;
>       device_class_set_props(dc, ipmi_bmc_extern_properties);
>   }
>   
> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
> index 6157ac7120..bc0ddc52a9 100644
> --- a/hw/ipmi/ipmi_bmc_sim.c
> +++ b/hw/ipmi/ipmi_bmc_sim.c
> @@ -2187,8 +2187,6 @@ static void ipmi_sim_realize(DeviceState *dev, Error **errp)
>       register_cmds(ibs);
>   
>       ibs->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ipmi_timeout, ibs);
> -
> -    vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs);
>   }
>   
>   static const Property ipmi_sim_properties[] = {
> @@ -2212,6 +2210,7 @@ static void ipmi_sim_class_init(ObjectClass *oc, void *data)
>   
>       dc->hotpluggable = false;
>       dc->realize = ipmi_sim_realize;
> +    dc->vmsd = &vmstate_ipmi_sim;
>       device_class_set_props(dc, ipmi_sim_properties);
>       bk->handle_command = ipmi_sim_handle_command;
>   }
> diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
> index a1b66d5ee8..474a792c9a 100644
> --- a/hw/ipmi/isa_ipmi_bt.c
> +++ b/hw/ipmi/isa_ipmi_bt.c
> @@ -117,8 +117,6 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)
>       qdev_set_legacy_instance_id(dev, iib->bt.io_base, iib->bt.io_length);
>   
>       isa_register_ioport(isadev, &iib->bt.io, iib->bt.io_base);
> -
> -    vmstate_register(NULL, 0, &vmstate_ISAIPMIBTDevice, dev);
>   }
>   
>   static void isa_ipmi_bt_init(Object *obj)
> @@ -147,6 +145,7 @@ static void isa_ipmi_bt_class_init(ObjectClass *oc, void *data)
>       AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
>   
>       dc->realize = isa_ipmi_bt_realize;
> +    dc->vmsd = &vmstate_ISAIPMIBTDevice;
>       device_class_set_props(dc, ipmi_isa_properties);
>   
>       iic->get_backend_data = isa_ipmi_bt_get_backend_data;
> diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c
> index d9ebdd5371..94bbe45d35 100644
> --- a/hw/ipmi/isa_ipmi_kcs.c
> +++ b/hw/ipmi/isa_ipmi_kcs.c
> @@ -72,6 +72,10 @@ static bool vmstate_kcs_before_version2(void *opaque, int version)
>       return version <= 1;
>   }
>   
> +/*
> + * Version 1 had an incorrect name, it clashed with the BT IPMI
> + * device, so receive it, but transmit a different version.
> + */
>   static const VMStateDescription vmstate_ISAIPMIKCSDevice = {
>       .name = TYPE_IPMI_INTERFACE,
>       .version_id = 2,
> @@ -119,13 +123,6 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp)
>       qdev_set_legacy_instance_id(dev, iik->kcs.io_base, iik->kcs.io_length);
>   
>       isa_register_ioport(isadev, &iik->kcs.io, iik->kcs.io_base);
> -
> -    /*
> -     * Version 1 had an incorrect name, it clashed with the BT
> -     * IPMI device, so receive it, but transmit a different
> -     * version.
> -     */
> -    vmstate_register(NULL, 0, &vmstate_ISAIPMIKCSDevice, iik);
>   }
>   
>   static void isa_ipmi_kcs_init(Object *obj)
> @@ -154,6 +151,7 @@ static void isa_ipmi_kcs_class_init(ObjectClass *oc, void *data)
>       AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
>   
>       dc->realize = ipmi_isa_realize;
> +    dc->vmsd = &vmstate_ISAIPMIKCSDevice;
>       device_class_set_props(dc, ipmi_isa_properties);
>   
>       iic->get_backend_data = isa_ipmi_kcs_get_backend_data;

LGTM!

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Fabiano Rosas April 4, 2025, 6:17 p.m. UTC | #2
Corey Minyard <corey@minyard.net> writes:

> It's the right way to do it now, and it handles multiple instances
> properly.  I need multiple instances for some testing I'm doing so this
> is the right thing to do.
>
> Tested by doing:
>
>    (qemu) migrate -d exec:cat>filen.mig
>
> before and after the fix, then:
>
>    scripts/analyze-migration.py -d desc -f file1.mig >file1.json
>    scripts/analyze-migration.py -d desc -f file2.mig >file2.json
>    diff file1.json file2.json
>
> with no differences.
>
> Signed-off-by: Corey Minyard <corey@minyard.net>

Reviewed-by: Fabiano Rosas <farosas@suse.de>
diff mbox series

Patch

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index d015500254..3e9f8c5a50 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -497,8 +497,6 @@  static void ipmi_bmc_extern_realize(DeviceState *dev, Error **errp)
 
     qemu_chr_fe_set_handlers(&ibe->chr, can_receive, receive,
                              chr_event, NULL, ibe, NULL, true);
-
-    vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
 }
 
 static void ipmi_bmc_extern_init(Object *obj)
@@ -528,6 +526,7 @@  static void ipmi_bmc_extern_class_init(ObjectClass *oc, void *data)
     bk->handle_reset = ipmi_bmc_extern_handle_reset;
     dc->hotpluggable = false;
     dc->realize = ipmi_bmc_extern_realize;
+    dc->vmsd = &vmstate_ipmi_bmc_extern;
     device_class_set_props(dc, ipmi_bmc_extern_properties);
 }
 
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 6157ac7120..bc0ddc52a9 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -2187,8 +2187,6 @@  static void ipmi_sim_realize(DeviceState *dev, Error **errp)
     register_cmds(ibs);
 
     ibs->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ipmi_timeout, ibs);
-
-    vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs);
 }
 
 static const Property ipmi_sim_properties[] = {
@@ -2212,6 +2210,7 @@  static void ipmi_sim_class_init(ObjectClass *oc, void *data)
 
     dc->hotpluggable = false;
     dc->realize = ipmi_sim_realize;
+    dc->vmsd = &vmstate_ipmi_sim;
     device_class_set_props(dc, ipmi_sim_properties);
     bk->handle_command = ipmi_sim_handle_command;
 }
diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index a1b66d5ee8..474a792c9a 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -117,8 +117,6 @@  static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)
     qdev_set_legacy_instance_id(dev, iib->bt.io_base, iib->bt.io_length);
 
     isa_register_ioport(isadev, &iib->bt.io, iib->bt.io_base);
-
-    vmstate_register(NULL, 0, &vmstate_ISAIPMIBTDevice, dev);
 }
 
 static void isa_ipmi_bt_init(Object *obj)
@@ -147,6 +145,7 @@  static void isa_ipmi_bt_class_init(ObjectClass *oc, void *data)
     AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     dc->realize = isa_ipmi_bt_realize;
+    dc->vmsd = &vmstate_ISAIPMIBTDevice;
     device_class_set_props(dc, ipmi_isa_properties);
 
     iic->get_backend_data = isa_ipmi_bt_get_backend_data;
diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c
index d9ebdd5371..94bbe45d35 100644
--- a/hw/ipmi/isa_ipmi_kcs.c
+++ b/hw/ipmi/isa_ipmi_kcs.c
@@ -72,6 +72,10 @@  static bool vmstate_kcs_before_version2(void *opaque, int version)
     return version <= 1;
 }
 
+/*
+ * Version 1 had an incorrect name, it clashed with the BT IPMI
+ * device, so receive it, but transmit a different version.
+ */
 static const VMStateDescription vmstate_ISAIPMIKCSDevice = {
     .name = TYPE_IPMI_INTERFACE,
     .version_id = 2,
@@ -119,13 +123,6 @@  static void ipmi_isa_realize(DeviceState *dev, Error **errp)
     qdev_set_legacy_instance_id(dev, iik->kcs.io_base, iik->kcs.io_length);
 
     isa_register_ioport(isadev, &iik->kcs.io, iik->kcs.io_base);
-
-    /*
-     * Version 1 had an incorrect name, it clashed with the BT
-     * IPMI device, so receive it, but transmit a different
-     * version.
-     */
-    vmstate_register(NULL, 0, &vmstate_ISAIPMIKCSDevice, iik);
 }
 
 static void isa_ipmi_kcs_init(Object *obj)
@@ -154,6 +151,7 @@  static void isa_ipmi_kcs_class_init(ObjectClass *oc, void *data)
     AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     dc->realize = ipmi_isa_realize;
+    dc->vmsd = &vmstate_ISAIPMIKCSDevice;
     device_class_set_props(dc, ipmi_isa_properties);
 
     iic->get_backend_data = isa_ipmi_kcs_get_backend_data;