diff mbox series

[10/13] migration: Improve example and documentation of vmstate_register()

Message ID 20231019190831.20363-11-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
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 docs/devel/migration.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Stefan Berger Oct. 19, 2023, 8:38 p.m. UTC | #1
On 10/19/23 15:08, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>   docs/devel/migration.rst | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst
> index c3e1400c0c..a9fde75862 100644
> --- a/docs/devel/migration.rst
> +++ b/docs/devel/migration.rst
> @@ -165,13 +165,17 @@ An example (from hw/input/pckbd.c)
>         }
>     };
>
> -We are declaring the state with name "pckbd".
> -The ``version_id`` is 3, and the fields are 4 uint8_t in a KBDState structure.
> -We registered this with:
> +We are declaring the state with name "pckbd".  The ``version_id`` is
> +3, and the fields are 4 uint8_t in a KBDState structure.  We

and there are 4  uint8_t fields in the KBDState structure.


> +registered this with one of those.  The first one will generate a

I am not sure what this means 'We registered this with one of those'. 
What is 'one of those'?

Maybe you mean: We register the KBDState with one of the following 
functions.

> +device ``instance_id`` different for each registration.  Use the
> +second one if you already have an id different for each instance of
> +the device:
... have an id that is is different for each ...
>
>   .. code:: c
>
> -    vmstate_register(NULL, 0, &vmstate_kbd, s);
> +    vmstate_register_any(NULL, &vmstate_kbd, s);
> +    vmstate_register(NULL, instance_id, &vmstate_kbd, s);
>
>   For devices that are ``qdev`` based, we can register the device in the class
>   init function:
Juan Quintela Oct. 20, 2023, 9:03 a.m. UTC | #2
Stefan Berger <stefanb@linux.ibm.com> wrote:
> On 10/19/23 15:08, Juan Quintela wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>   docs/devel/migration.rst | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst
>> index c3e1400c0c..a9fde75862 100644
>> --- a/docs/devel/migration.rst
>> +++ b/docs/devel/migration.rst
>> @@ -165,13 +165,17 @@ An example (from hw/input/pckbd.c)
>>         }
>>     };
>>
>> -We are declaring the state with name "pckbd".
>> -The ``version_id`` is 3, and the fields are 4 uint8_t in a KBDState structure.
>> -We registered this with:
>> +We are declaring the state with name "pckbd".  The ``version_id`` is
>> +3, and the fields are 4 uint8_t in a KBDState structure.  We
>
> and there are 4  uint8_t fields in the KBDState structure.

Done thanks.

>
>> +registered this with one of those.  The first one will generate a
>
> I am not sure what this means 'We registered this with one of
> those'. What is 'one of those'?

Changed to:

We
registered this ``VMSTATEDescription`` with one of the following
functions.

> Maybe you mean: We register the KBDState with one of the following
> functions.
>
>> +device ``instance_id`` different for each registration.  Use the
>> +second one if you already have an id different for each instance of
>> +the device:
> ... have an id that is is different for each ...

Done

>>
>>   .. code:: c
>>
>> -    vmstate_register(NULL, 0, &vmstate_kbd, s);
>> +    vmstate_register_any(NULL, &vmstate_kbd, s);
>> +    vmstate_register(NULL, instance_id, &vmstate_kbd, s);
>>
>>   For devices that are ``qdev`` based, we can register the device in the class
>>   init function:

Thanks
diff mbox series

Patch

diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst
index c3e1400c0c..a9fde75862 100644
--- a/docs/devel/migration.rst
+++ b/docs/devel/migration.rst
@@ -165,13 +165,17 @@  An example (from hw/input/pckbd.c)
       }
   };
 
-We are declaring the state with name "pckbd".
-The ``version_id`` is 3, and the fields are 4 uint8_t in a KBDState structure.
-We registered this with:
+We are declaring the state with name "pckbd".  The ``version_id`` is
+3, and the fields are 4 uint8_t in a KBDState structure.  We
+registered this with one of those.  The first one will generate a
+device ``instance_id`` different for each registration.  Use the
+second one if you already have an id different for each instance of
+the device:
 
 .. code:: c
 
-    vmstate_register(NULL, 0, &vmstate_kbd, s);
+    vmstate_register_any(NULL, &vmstate_kbd, s);
+    vmstate_register(NULL, instance_id, &vmstate_kbd, s);
 
 For devices that are ``qdev`` based, we can register the device in the class
 init function: