diff mbox series

[13/13] migration: Use vmstate_register_any() for vmware_vga

Message ID 20231019190831.20363-14-quintela@redhat.com
State New
Headers show
Series migration: Check for duplicates on vmstate_register() | expand

Commit Message

Juan Quintela Oct. 19, 2023, 7:08 p.m. UTC
I have no idea if we can have more than one vmware_vga device, so play
it safe.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/display/vmware_vga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Berger Oct. 19, 2023, 8:42 p.m. UTC | #1
On 10/19/23 15:08, Juan Quintela wrote:
> I have no idea if we can have more than one vmware_vga device, so play
> it safe.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>

> ---
>   hw/display/vmware_vga.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
> index 09591fbd39..7490d43881 100644
> --- a/hw/display/vmware_vga.c
> +++ b/hw/display/vmware_vga.c
> @@ -1264,7 +1264,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,
>
>       vga_common_init(&s->vga, OBJECT(dev), &error_fatal);
>       vga_init(&s->vga, OBJECT(dev), address_space, io, true);
> -    vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
> +    vmstate_register_any(NULL, &vmstate_vga_common, &s->vga);

And the first one registered with 'any' will again have instance_id = 0 
assigned. So there's no side effect to be expected with any of these 
device, I suppose.


>       s->new_depth = 32;
>   }
>
Juan Quintela Oct. 20, 2023, 7:33 a.m. UTC | #2
Stefan Berger <stefanb@linux.ibm.com> wrote:
> On 10/19/23 15:08, Juan Quintela wrote:
>> I have no idea if we can have more than one vmware_vga device, so play
>> it safe.
>>
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
>
>> ---
>>   hw/display/vmware_vga.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
>> index 09591fbd39..7490d43881 100644
>> --- a/hw/display/vmware_vga.c
>> +++ b/hw/display/vmware_vga.c
>> @@ -1264,7 +1264,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,
>>
>>       vga_common_init(&s->vga, OBJECT(dev), &error_fatal);
>>       vga_init(&s->vga, OBJECT(dev), address_space, io, true);
>> -    vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
>> +    vmstate_register_any(NULL, &vmstate_vga_common, &s->vga);
>
> And the first one registered with 'any' will again have instance_id =
> 0 assigned. So there's no side effect to be expected with any of these
> device, I suppose.

I will really change all the remaining registrations with 0 to any.

* If there is only a registration for that device: nothing changes
* If there is more than one registration for that device: It *could*
  work (from the migration point of view).

But then there are devices that *clearly* will not be able to have more
than one instance, so 0 is the best option there.  On top of my head:

* cpu-timers
* replay
* migration global_state

And the rest that I put on the cover letter are basically devices that
are used only once on the board initilization routine, so I feel safe
leaving them with zero.

Thanks for the review, Juan.
diff mbox series

Patch

diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 09591fbd39..7490d43881 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1264,7 +1264,7 @@  static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,
 
     vga_common_init(&s->vga, OBJECT(dev), &error_fatal);
     vga_init(&s->vga, OBJECT(dev), address_space, io, true);
-    vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
+    vmstate_register_any(NULL, &vmstate_vga_common, &s->vga);
     s->new_depth = 32;
 }