[PATCH 02/18] migration/vmstate: Introduce vmstate_no_state_to_migrate

Philippe Mathieu-Daudé posted 18 patches 5 years, 3 months ago
There is a newer version of this series
[PATCH 02/18] migration/vmstate: Introduce vmstate_no_state_to_migrate
Posted by Philippe Mathieu-Daudé 5 years, 3 months ago
Introduce a special state to indicate when an object doesn't
have anything in its state to migrate.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/migration/vmstate.h | 1 +
 migration/vmstate.c         | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index af7d80cd4e..0922bc8efa 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -195,6 +195,7 @@ struct VMStateDescription {
 };
 
 extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
+extern const VMStateDescription vmstate_no_state_to_migrate;
 
 extern const VMStateInfo vmstate_info_bool;
 
diff --git a/migration/vmstate.c b/migration/vmstate.c
index bafa890384..d640cafad3 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -20,6 +20,13 @@
 #include "trace.h"
 #include "qjson.h"
 
+const VMStateDescription vmstate_no_state_to_migrate = {
+    .name = "empty-state",
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
                                    void *opaque, QJSON *vmdesc);
 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
-- 
2.21.3


Re: [PATCH 02/18] migration/vmstate: Introduce vmstate_no_state_to_migrate
Posted by Peter Maydell 5 years, 2 months ago
On Fri, 3 Jul 2020 at 21:19, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Introduce a special state to indicate when an object doesn't
> have anything in its state to migrate.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/migration/vmstate.h | 1 +
>  migration/vmstate.c         | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index af7d80cd4e..0922bc8efa 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -195,6 +195,7 @@ struct VMStateDescription {
>  };
>
>  extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
> +extern const VMStateDescription vmstate_no_state_to_migrate;
>
>  extern const VMStateInfo vmstate_info_bool;
>
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index bafa890384..d640cafad3 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -20,6 +20,13 @@
>  #include "trace.h"
>  #include "qjson.h"
>
> +const VMStateDescription vmstate_no_state_to_migrate = {
> +    .name = "empty-state",
> +    .fields = (VMStateField[]) {
> +        VMSTATE_END_OF_LIST()
> +    }
> +};

Does this definitely not put any data into the migration stream?
We don't want to change what's on the wire for machines that
use devices that start using this. (If it does by default, it
would be easy to make the migration code special case the
magic symbol to act like "no vmsd specified").

thanks
-- PMM

Re: [PATCH 02/18] migration/vmstate: Introduce vmstate_no_state_to_migrate
Posted by Dr. David Alan Gilbert 5 years, 2 months ago
* Peter Maydell (peter.maydell@linaro.org) wrote:
> On Fri, 3 Jul 2020 at 21:19, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> >
> > Introduce a special state to indicate when an object doesn't
> > have anything in its state to migrate.
> >
> > Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > ---
> >  include/migration/vmstate.h | 1 +
> >  migration/vmstate.c         | 7 +++++++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> > index af7d80cd4e..0922bc8efa 100644
> > --- a/include/migration/vmstate.h
> > +++ b/include/migration/vmstate.h
> > @@ -195,6 +195,7 @@ struct VMStateDescription {
> >  };
> >
> >  extern const VMStateDescription vmstate_dummy; /* Exclusively for linux-user */
> > +extern const VMStateDescription vmstate_no_state_to_migrate;
> >
> >  extern const VMStateInfo vmstate_info_bool;
> >
> > diff --git a/migration/vmstate.c b/migration/vmstate.c
> > index bafa890384..d640cafad3 100644
> > --- a/migration/vmstate.c
> > +++ b/migration/vmstate.c
> > @@ -20,6 +20,13 @@
> >  #include "trace.h"
> >  #include "qjson.h"
> >
> > +const VMStateDescription vmstate_no_state_to_migrate = {
> > +    .name = "empty-state",
> > +    .fields = (VMStateField[]) {
> > +        VMSTATE_END_OF_LIST()
> > +    }
> > +};
> 
> Does this definitely not put any data into the migration stream?
> We don't want to change what's on the wire for machines that
> use devices that start using this. (If it does by default, it
> would be easy to make the migration code special case the
> magic symbol to act like "no vmsd specified").

I'd need to test it to be sure, but I think if we added a .needed
to vmstate_no_state_to_migrate with a function that always returned
false, then I think the stream would stay unchanged.

Dave

> thanks
> -- PMM
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK