All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] cleanup savevm
@ 2019-04-24  0:46 ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: quintela, dgilbert, Wei Yang

There are several trivial cleanup for savevm.

  * remove duplicate check
  * more restrict check
  * reorder load sequence
  * wrap several steps into qemu_loadvm_state_header

Wei Yang (4):
  migration/savevm: remove duplicate check of migration_is_blocked
  migration/savevm: use migration_is_blocked to validate
  migration/savevm: load_header before load_setup
  migration/savevm: wrap into qemu_loadvm_state_header()

 migration/savevm.c | 75 +++++++++++++++++++++++++---------------------
 1 file changed, 41 insertions(+), 34 deletions(-)

-- 
2.19.1

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 0/4] cleanup savevm
@ 2019-04-24  0:46 ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wei Yang, dgilbert, quintela

There are several trivial cleanup for savevm.

  * remove duplicate check
  * more restrict check
  * reorder load sequence
  * wrap several steps into qemu_loadvm_state_header

Wei Yang (4):
  migration/savevm: remove duplicate check of migration_is_blocked
  migration/savevm: use migration_is_blocked to validate
  migration/savevm: load_header before load_setup
  migration/savevm: wrap into qemu_loadvm_state_header()

 migration/savevm.c | 75 +++++++++++++++++++++++++---------------------
 1 file changed, 41 insertions(+), 34 deletions(-)

-- 
2.19.1



^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
@ 2019-04-24  0:46   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: quintela, dgilbert, Wei Yang

Current call flow of save_snapshot is:

  save_snapshot
    migration_is_blocked
      qemu_savevm_state
        migration_is_blocked

Since qemu_savevm_state is only called in save_snapshot, this means
migration_is_blocked has been already checked.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 92af2471cd..2eea604624 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
         return -EINVAL;
     }
 
-    if (migration_is_blocked(errp)) {
-        return -EINVAL;
-    }
-
     if (migrate_use_block()) {
         error_setg(errp, "Block migration and snapshots are incompatible");
         return -EINVAL;
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
@ 2019-04-24  0:46   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wei Yang, dgilbert, quintela

Current call flow of save_snapshot is:

  save_snapshot
    migration_is_blocked
      qemu_savevm_state
        migration_is_blocked

Since qemu_savevm_state is only called in save_snapshot, this means
migration_is_blocked has been already checked.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 92af2471cd..2eea604624 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
         return -EINVAL;
     }
 
-    if (migration_is_blocked(errp)) {
-        return -EINVAL;
-    }
-
     if (migrate_use_block()) {
         error_setg(errp, "Block migration and snapshots are incompatible");
         return -EINVAL;
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
@ 2019-04-24  0:46   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: quintela, dgilbert, Wei Yang

migration_is_blocked() is used in migrate_prepare() and
save_snapshot(), this is more proper to use this instead of
qemu_savevm_state_blocked() in qemu_loadvm_state().

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 2eea604624..6c61056cde 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2406,7 +2406,7 @@ int qemu_loadvm_state(QEMUFile *f)
     unsigned int v;
     int ret;
 
-    if (qemu_savevm_state_blocked(&local_err)) {
+    if (migration_is_blocked(&local_err)) {
         error_report_err(local_err);
         return -EINVAL;
     }
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
@ 2019-04-24  0:46   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wei Yang, dgilbert, quintela

migration_is_blocked() is used in migrate_prepare() and
save_snapshot(), this is more proper to use this instead of
qemu_savevm_state_blocked() in qemu_loadvm_state().

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 2eea604624..6c61056cde 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2406,7 +2406,7 @@ int qemu_loadvm_state(QEMUFile *f)
     unsigned int v;
     int ret;
 
-    if (qemu_savevm_state_blocked(&local_err)) {
+    if (migration_is_blocked(&local_err)) {
         error_report_err(local_err);
         return -EINVAL;
     }
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 3/4] migration/savevm: load_header before load_setup
@ 2019-04-24  0:46   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: quintela, dgilbert, Wei Yang

In migration_thread() and qemu_savevm_state(), we savevm_state in
following sequence:

    qemu_savevm_state_header(f);
    qemu_savevm_state_setup(f);

Then it would be more proper to loadvm_state in the save sequence.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 6c61056cde..a80ae83663 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2427,10 +2427,6 @@ int qemu_loadvm_state(QEMUFile *f)
         return -ENOTSUP;
     }
 
-    if (qemu_loadvm_state_setup(f) != 0) {
-        return -EINVAL;
-    }
-
     if (migrate_get_current()->send_configuration) {
         if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
             error_report("Configuration section missing");
@@ -2445,6 +2441,10 @@ int qemu_loadvm_state(QEMUFile *f)
         }
     }
 
+    if (qemu_loadvm_state_setup(f) != 0) {
+        return -EINVAL;
+    }
+
     cpu_synchronize_all_pre_loadvm();
 
     ret = qemu_loadvm_state_main(f, mis);
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 3/4] migration/savevm: load_header before load_setup
@ 2019-04-24  0:46   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wei Yang, dgilbert, quintela

In migration_thread() and qemu_savevm_state(), we savevm_state in
following sequence:

    qemu_savevm_state_header(f);
    qemu_savevm_state_setup(f);

Then it would be more proper to loadvm_state in the save sequence.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 6c61056cde..a80ae83663 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2427,10 +2427,6 @@ int qemu_loadvm_state(QEMUFile *f)
         return -ENOTSUP;
     }
 
-    if (qemu_loadvm_state_setup(f) != 0) {
-        return -EINVAL;
-    }
-
     if (migrate_get_current()->send_configuration) {
         if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
             error_report("Configuration section missing");
@@ -2445,6 +2441,10 @@ int qemu_loadvm_state(QEMUFile *f)
         }
     }
 
+    if (qemu_loadvm_state_setup(f) != 0) {
+        return -EINVAL;
+    }
+
     cpu_synchronize_all_pre_loadvm();
 
     ret = qemu_loadvm_state_main(f, mis);
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 4/4] migration/savevm: wrap into qemu_loadvm_state_header()
@ 2019-04-24  0:47   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: quintela, dgilbert, Wei Yang

On source side, we have qemu_savevm_state_header() to send related data,
while on the receiving side those steps are scattered in
qemu_loadvm_state().

This patch wrap those related steps into qemu_loadvm_state_header() to
make it friendly to read.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 69 +++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 29 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index a80ae83663..64d23682c6 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2256,6 +2256,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
     return 0;
 }
 
+static int qemu_loadvm_state_header(QEMUFile *f)
+{
+    unsigned int v;
+    int ret;
+
+    v = qemu_get_be32(f);
+    if (v != QEMU_VM_FILE_MAGIC) {
+        error_report("Not a migration stream");
+        return -EINVAL;
+    }
+
+    v = qemu_get_be32(f);
+    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
+        error_report("SaveVM v2 format is obsolete and don't work anymore");
+        return -ENOTSUP;
+    }
+    if (v != QEMU_VM_FILE_VERSION) {
+        error_report("Unsupported migration stream version");
+        return -ENOTSUP;
+    }
+
+    if (migrate_get_current()->send_configuration) {
+        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
+            error_report("Configuration section missing");
+            qemu_loadvm_state_cleanup();
+            return -EINVAL;
+        }
+        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
+
+        if (ret) {
+            qemu_loadvm_state_cleanup();
+            return ret;
+        }
+    }
+    return 0;
+}
+
 static int qemu_loadvm_state_setup(QEMUFile *f)
 {
     SaveStateEntry *se;
@@ -2403,7 +2440,6 @@ int qemu_loadvm_state(QEMUFile *f)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();
     Error *local_err = NULL;
-    unsigned int v;
     int ret;
 
     if (migration_is_blocked(&local_err)) {
@@ -2411,34 +2447,9 @@ int qemu_loadvm_state(QEMUFile *f)
         return -EINVAL;
     }
 
-    v = qemu_get_be32(f);
-    if (v != QEMU_VM_FILE_MAGIC) {
-        error_report("Not a migration stream");
-        return -EINVAL;
-    }
-
-    v = qemu_get_be32(f);
-    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
-        error_report("SaveVM v2 format is obsolete and don't work anymore");
-        return -ENOTSUP;
-    }
-    if (v != QEMU_VM_FILE_VERSION) {
-        error_report("Unsupported migration stream version");
-        return -ENOTSUP;
-    }
-
-    if (migrate_get_current()->send_configuration) {
-        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
-            error_report("Configuration section missing");
-            qemu_loadvm_state_cleanup();
-            return -EINVAL;
-        }
-        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
-
-        if (ret) {
-            qemu_loadvm_state_cleanup();
-            return ret;
-        }
+    ret = qemu_loadvm_state_header(f);
+    if (ret) {
+        return ret;
     }
 
     if (qemu_loadvm_state_setup(f) != 0) {
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PATCH 4/4] migration/savevm: wrap into qemu_loadvm_state_header()
@ 2019-04-24  0:47   ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-24  0:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wei Yang, dgilbert, quintela

On source side, we have qemu_savevm_state_header() to send related data,
while on the receiving side those steps are scattered in
qemu_loadvm_state().

This patch wrap those related steps into qemu_loadvm_state_header() to
make it friendly to read.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/savevm.c | 69 +++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 29 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index a80ae83663..64d23682c6 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2256,6 +2256,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
     return 0;
 }
 
+static int qemu_loadvm_state_header(QEMUFile *f)
+{
+    unsigned int v;
+    int ret;
+
+    v = qemu_get_be32(f);
+    if (v != QEMU_VM_FILE_MAGIC) {
+        error_report("Not a migration stream");
+        return -EINVAL;
+    }
+
+    v = qemu_get_be32(f);
+    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
+        error_report("SaveVM v2 format is obsolete and don't work anymore");
+        return -ENOTSUP;
+    }
+    if (v != QEMU_VM_FILE_VERSION) {
+        error_report("Unsupported migration stream version");
+        return -ENOTSUP;
+    }
+
+    if (migrate_get_current()->send_configuration) {
+        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
+            error_report("Configuration section missing");
+            qemu_loadvm_state_cleanup();
+            return -EINVAL;
+        }
+        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
+
+        if (ret) {
+            qemu_loadvm_state_cleanup();
+            return ret;
+        }
+    }
+    return 0;
+}
+
 static int qemu_loadvm_state_setup(QEMUFile *f)
 {
     SaveStateEntry *se;
@@ -2403,7 +2440,6 @@ int qemu_loadvm_state(QEMUFile *f)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();
     Error *local_err = NULL;
-    unsigned int v;
     int ret;
 
     if (migration_is_blocked(&local_err)) {
@@ -2411,34 +2447,9 @@ int qemu_loadvm_state(QEMUFile *f)
         return -EINVAL;
     }
 
-    v = qemu_get_be32(f);
-    if (v != QEMU_VM_FILE_MAGIC) {
-        error_report("Not a migration stream");
-        return -EINVAL;
-    }
-
-    v = qemu_get_be32(f);
-    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
-        error_report("SaveVM v2 format is obsolete and don't work anymore");
-        return -ENOTSUP;
-    }
-    if (v != QEMU_VM_FILE_VERSION) {
-        error_report("Unsupported migration stream version");
-        return -ENOTSUP;
-    }
-
-    if (migrate_get_current()->send_configuration) {
-        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
-            error_report("Configuration section missing");
-            qemu_loadvm_state_cleanup();
-            return -EINVAL;
-        }
-        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
-
-        if (ret) {
-            qemu_loadvm_state_cleanup();
-            return ret;
-        }
+    ret = qemu_loadvm_state_header(f);
+    if (ret) {
+        return ret;
     }
 
     if (qemu_loadvm_state_setup(f) != 0) {
-- 
2.19.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
  2019-04-24  0:46   ` Wei Yang
  (?)
@ 2019-04-25 19:20   ` Daniel Henrique Barboza
  2019-04-26  0:39       ` Wei Yang
  -1 siblings, 1 reply; 25+ messages in thread
From: Daniel Henrique Barboza @ 2019-04-25 19:20 UTC (permalink / raw)
  To: Wei Yang, qemu-devel; +Cc: dgilbert, quintela



On 4/23/19 9:46 PM, Wei Yang wrote:
> Current call flow of save_snapshot is:
>
>    save_snapshot
>      migration_is_blocked
>        qemu_savevm_state
>          migration_is_blocked
>
> Since qemu_savevm_state is only called in save_snapshot, this means
> migration_is_blocked has been already checked.

I think it would be a nice touch to add a comment in qemu_savevm_state,
saying that the function must be called with migration_is_blocked()
context. Just in case someone else in the future ends up re-using the
function.


Other than that, +1 for less code duplication.


Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>




>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>   migration/savevm.c | 4 ----
>   1 file changed, 4 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 92af2471cd..2eea604624 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>           return -EINVAL;
>       }
>   
> -    if (migration_is_blocked(errp)) {
> -        return -EINVAL;
> -    }
> -
>       if (migrate_use_block()) {
>           error_setg(errp, "Block migration and snapshots are incompatible");
>           return -EINVAL;

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
  2019-04-24  0:46   ` Wei Yang
  (?)
@ 2019-04-25 20:55   ` Daniel Henrique Barboza
  2019-04-26  0:51       ` Wei Yang
  -1 siblings, 1 reply; 25+ messages in thread
From: Daniel Henrique Barboza @ 2019-04-25 20:55 UTC (permalink / raw)
  To: Wei Yang, qemu-devel; +Cc: dgilbert, quintela



On 4/23/19 9:46 PM, Wei Yang wrote:
> migration_is_blocked() is used in migrate_prepare() and
> save_snapshot(), this is more proper to use this instead of
> qemu_savevm_state_blocked() in qemu_loadvm_state().


migration_is_blocked() does an additional verification:

"if (migration_blockers)"

comparing to what was previously done in qemu_loadvm_state.

I've checked what migration_blockers does and it is a GList used
for callers to block the migration process. This is used via
'migration_add_blocker', from migration.c.

'migration_add_blocker' is called all over the place, most notably
in  _realize() functions  and _open() functions from block.

Thus, I am not sure if this change will impact the use of
qemu_loadvm_state() from load_snapshot() (i.e. can load_snapshot
be called with migration_blockers?). It's better to someone
with a better understanding of this code to comment on that.


DHB



> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>   migration/savevm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 2eea604624..6c61056cde 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2406,7 +2406,7 @@ int qemu_loadvm_state(QEMUFile *f)
>       unsigned int v;
>       int ret;
>   
> -    if (qemu_savevm_state_blocked(&local_err)) {
> +    if (migration_is_blocked(&local_err)) {
>           error_report_err(local_err);
>           return -EINVAL;
>       }

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] migration/savevm: wrap into qemu_loadvm_state_header()
  2019-04-24  0:47   ` Wei Yang
  (?)
@ 2019-04-25 22:07   ` Daniel Henrique Barboza
  -1 siblings, 0 replies; 25+ messages in thread
From: Daniel Henrique Barboza @ 2019-04-25 22:07 UTC (permalink / raw)
  To: Wei Yang, qemu-devel; +Cc: dgilbert, quintela



On 4/23/19 9:47 PM, Wei Yang wrote:
> On source side, we have qemu_savevm_state_header() to send related data,
> while on the receiving side those steps are scattered in
> qemu_loadvm_state().
>
> This patch wrap those related steps into qemu_loadvm_state_header() to
> make it friendly to read.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>


Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>


> ---
>   migration/savevm.c | 69 +++++++++++++++++++++++++++-------------------
>   1 file changed, 40 insertions(+), 29 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index a80ae83663..64d23682c6 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2256,6 +2256,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
>       return 0;
>   }
>   
> +static int qemu_loadvm_state_header(QEMUFile *f)
> +{
> +    unsigned int v;
> +    int ret;
> +
> +    v = qemu_get_be32(f);
> +    if (v != QEMU_VM_FILE_MAGIC) {
> +        error_report("Not a migration stream");
> +        return -EINVAL;
> +    }
> +
> +    v = qemu_get_be32(f);
> +    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
> +        error_report("SaveVM v2 format is obsolete and don't work anymore");
> +        return -ENOTSUP;
> +    }
> +    if (v != QEMU_VM_FILE_VERSION) {
> +        error_report("Unsupported migration stream version");
> +        return -ENOTSUP;
> +    }
> +
> +    if (migrate_get_current()->send_configuration) {
> +        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
> +            error_report("Configuration section missing");
> +            qemu_loadvm_state_cleanup();
> +            return -EINVAL;
> +        }
> +        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
> +
> +        if (ret) {
> +            qemu_loadvm_state_cleanup();
> +            return ret;
> +        }
> +    }
> +    return 0;
> +}
> +
>   static int qemu_loadvm_state_setup(QEMUFile *f)
>   {
>       SaveStateEntry *se;
> @@ -2403,7 +2440,6 @@ int qemu_loadvm_state(QEMUFile *f)
>   {
>       MigrationIncomingState *mis = migration_incoming_get_current();
>       Error *local_err = NULL;
> -    unsigned int v;
>       int ret;
>   
>       if (migration_is_blocked(&local_err)) {
> @@ -2411,34 +2447,9 @@ int qemu_loadvm_state(QEMUFile *f)
>           return -EINVAL;
>       }
>   
> -    v = qemu_get_be32(f);
> -    if (v != QEMU_VM_FILE_MAGIC) {
> -        error_report("Not a migration stream");
> -        return -EINVAL;
> -    }
> -
> -    v = qemu_get_be32(f);
> -    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
> -        error_report("SaveVM v2 format is obsolete and don't work anymore");
> -        return -ENOTSUP;
> -    }
> -    if (v != QEMU_VM_FILE_VERSION) {
> -        error_report("Unsupported migration stream version");
> -        return -ENOTSUP;
> -    }
> -
> -    if (migrate_get_current()->send_configuration) {
> -        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
> -            error_report("Configuration section missing");
> -            qemu_loadvm_state_cleanup();
> -            return -EINVAL;
> -        }
> -        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
> -
> -        if (ret) {
> -            qemu_loadvm_state_cleanup();
> -            return ret;
> -        }
> +    ret = qemu_loadvm_state_header(f);
> +    if (ret) {
> +        return ret;
>       }
>   
>       if (qemu_loadvm_state_setup(f) != 0) {

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
@ 2019-04-26  0:39       ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-26  0:39 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: Wei Yang, qemu-devel, dgilbert, quintela

On Thu, Apr 25, 2019 at 04:20:57PM -0300, Daniel Henrique Barboza wrote:
>
>
>On 4/23/19 9:46 PM, Wei Yang wrote:
>> Current call flow of save_snapshot is:
>> 
>>    save_snapshot
>>      migration_is_blocked
>>        qemu_savevm_state
>>          migration_is_blocked
>> 
>> Since qemu_savevm_state is only called in save_snapshot, this means
>> migration_is_blocked has been already checked.
>
>I think it would be a nice touch to add a comment in qemu_savevm_state,
>saying that the function must be called with migration_is_blocked()
>context. Just in case someone else in the future ends up re-using the
>function.
>

That's reasonable, let me add a comment for qemu_savevm_state().

>
>Other than that, +1 for less code duplication.
>
>
>Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>
>
>
>
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>   migration/savevm.c | 4 ----
>>   1 file changed, 4 deletions(-)
>> 
>> diff --git a/migration/savevm.c b/migration/savevm.c
>> index 92af2471cd..2eea604624 100644
>> --- a/migration/savevm.c
>> +++ b/migration/savevm.c
>> @@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>>           return -EINVAL;
>>       }
>> -    if (migration_is_blocked(errp)) {
>> -        return -EINVAL;
>> -    }
>> -
>>       if (migrate_use_block()) {
>>           error_setg(errp, "Block migration and snapshots are incompatible");
>>           return -EINVAL;

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
@ 2019-04-26  0:39       ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-26  0:39 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: quintela, Wei Yang, dgilbert, qemu-devel

On Thu, Apr 25, 2019 at 04:20:57PM -0300, Daniel Henrique Barboza wrote:
>
>
>On 4/23/19 9:46 PM, Wei Yang wrote:
>> Current call flow of save_snapshot is:
>> 
>>    save_snapshot
>>      migration_is_blocked
>>        qemu_savevm_state
>>          migration_is_blocked
>> 
>> Since qemu_savevm_state is only called in save_snapshot, this means
>> migration_is_blocked has been already checked.
>
>I think it would be a nice touch to add a comment in qemu_savevm_state,
>saying that the function must be called with migration_is_blocked()
>context. Just in case someone else in the future ends up re-using the
>function.
>

That's reasonable, let me add a comment for qemu_savevm_state().

>
>Other than that, +1 for less code duplication.
>
>
>Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>
>
>
>
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>   migration/savevm.c | 4 ----
>>   1 file changed, 4 deletions(-)
>> 
>> diff --git a/migration/savevm.c b/migration/savevm.c
>> index 92af2471cd..2eea604624 100644
>> --- a/migration/savevm.c
>> +++ b/migration/savevm.c
>> @@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>>           return -EINVAL;
>>       }
>> -    if (migration_is_blocked(errp)) {
>> -        return -EINVAL;
>> -    }
>> -
>>       if (migrate_use_block()) {
>>           error_setg(errp, "Block migration and snapshots are incompatible");
>>           return -EINVAL;

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
@ 2019-04-26  0:51       ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-26  0:51 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: Wei Yang, qemu-devel, dgilbert, quintela

On Thu, Apr 25, 2019 at 05:55:15PM -0300, Daniel Henrique Barboza wrote:
>
>
>On 4/23/19 9:46 PM, Wei Yang wrote:
>> migration_is_blocked() is used in migrate_prepare() and
>> save_snapshot(), this is more proper to use this instead of
>> qemu_savevm_state_blocked() in qemu_loadvm_state().
>
>
>migration_is_blocked() does an additional verification:
>
>"if (migration_blockers)"
>
>comparing to what was previously done in qemu_loadvm_state.
>
>I've checked what migration_blockers does and it is a GList used
>for callers to block the migration process. This is used via
>'migration_add_blocker', from migration.c.
>
>'migration_add_blocker' is called all over the place, most notably
>in  _realize() functions  and _open() functions from block.
>
>Thus, I am not sure if this change will impact the use of
>qemu_loadvm_state() from load_snapshot() (i.e. can load_snapshot
>be called with migration_blockers?). It's better to someone
>with a better understanding of this code to comment on that.
>

Well, when you look into the source side of migration:

qmp_migrate
  migrate_prepare
    migration_is_blocked

This means if migration_is_blocked fails, the source will not start migration.
And it is the same as save_snapshot.

>From my understanding, when we load a vm, it should check the same
requirement.

-- 
Wei Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
@ 2019-04-26  0:51       ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-04-26  0:51 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: quintela, Wei Yang, dgilbert, qemu-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 1344 bytes --]

On Thu, Apr 25, 2019 at 05:55:15PM -0300, Daniel Henrique Barboza wrote:
>
>
>On 4/23/19 9:46 PM, Wei Yang wrote:
>> migration_is_blocked() is used in migrate_prepare() and
>> save_snapshot(), this is more proper to use this instead of
>> qemu_savevm_state_blocked() in qemu_loadvm_state().
>
>
>migration_is_blocked() does an additional verification:
>
>"if (migration_blockers)"
>
>comparing to what was previously done in qemu_loadvm_state.
>
>I've checked what migration_blockers does and it is a GList used
>for callers to block the migration process. This is used via
>'migration_add_blocker', from migration.c.
>
>'migration_add_blocker' is called all over the place, most notably
>in  _realize() functions  and _open() functions from block.
>
>Thus, I am not sure if this change will impact the use of
>qemu_loadvm_state() from load_snapshot() (i.e. can load_snapshot
>be called with migration_blockers?). It's better to someone
>with a better understanding of this code to comment on that.
>

Well, when you look into the source side of migration:

qmp_migrate
  migrate_prepare
    migration_is_blocked

This means if migration_is_blocked fails, the source will not start migration.
And it is the same as save_snapshot.

From my understanding, when we load a vm, it should check the same
requirement.

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
  2019-04-24  0:46   ` Wei Yang
  (?)
  (?)
@ 2019-05-14 14:46   ` Dr. David Alan Gilbert
  -1 siblings, 0 replies; 25+ messages in thread
From: Dr. David Alan Gilbert @ 2019-05-14 14:46 UTC (permalink / raw)
  To: Wei Yang; +Cc: qemu-devel, quintela

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> Current call flow of save_snapshot is:
> 
>   save_snapshot
>     migration_is_blocked
>       qemu_savevm_state
>         migration_is_blocked
> 
> Since qemu_savevm_state is only called in save_snapshot, this means
> migration_is_blocked has been already checked.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/savevm.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 92af2471cd..2eea604624 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>          return -EINVAL;
>      }
>  
> -    if (migration_is_blocked(errp)) {
> -        return -EINVAL;
> -    }
> -
>      if (migrate_use_block()) {
>          error_setg(errp, "Block migration and snapshots are incompatible");
>          return -EINVAL;
> -- 
> 2.19.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
  2019-04-26  0:51       ` Wei Yang
  (?)
@ 2019-05-14 15:18       ` Dr. David Alan Gilbert
  2019-05-15  6:38         ` Wei Yang
  -1 siblings, 1 reply; 25+ messages in thread
From: Dr. David Alan Gilbert @ 2019-05-14 15:18 UTC (permalink / raw)
  To: Wei Yang; +Cc: Daniel Henrique Barboza, qemu-devel, quintela

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> On Thu, Apr 25, 2019 at 05:55:15PM -0300, Daniel Henrique Barboza wrote:
> >
> >
> >On 4/23/19 9:46 PM, Wei Yang wrote:
> >> migration_is_blocked() is used in migrate_prepare() and
> >> save_snapshot(), this is more proper to use this instead of
> >> qemu_savevm_state_blocked() in qemu_loadvm_state().
> >
> >
> >migration_is_blocked() does an additional verification:
> >
> >"if (migration_blockers)"
> >
> >comparing to what was previously done in qemu_loadvm_state.
> >
> >I've checked what migration_blockers does and it is a GList used
> >for callers to block the migration process. This is used via
> >'migration_add_blocker', from migration.c.
> >
> >'migration_add_blocker' is called all over the place, most notably
> >in  _realize() functions  and _open() functions from block.
> >
> >Thus, I am not sure if this change will impact the use of
> >qemu_loadvm_state() from load_snapshot() (i.e. can load_snapshot
> >be called with migration_blockers?). It's better to someone
> >with a better understanding of this code to comment on that.
> >
> 
> Well, when you look into the source side of migration:
> 
> qmp_migrate
>   migrate_prepare
>     migration_is_blocked
> 
> This means if migration_is_blocked fails, the source will not start migration.
> And it is the same as save_snapshot.
> 
> From my understanding, when we load a vm, it should check the same
> requirement.

I've been thinking about this, and I think I agree with Daniel on this.
The 'migration_blockers' list tells you that something about the
*current* state of a device means that it can't be migrated - e.g.
a 9pfs with a mounted filesystem can't be migrated.

If we're about to reload the state from a snapshot, then the saved
snapshot's state must have been migratable, so that's OK.

(Whether all the device code is actually OK about being reset in
that state is a different question; but I think it should be).

Dave

> -- 
> Wei Yang
> Help you, Help me
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 3/4] migration/savevm: load_header before load_setup
  2019-04-24  0:46   ` Wei Yang
  (?)
@ 2019-05-14 15:45   ` Dr. David Alan Gilbert
  -1 siblings, 0 replies; 25+ messages in thread
From: Dr. David Alan Gilbert @ 2019-05-14 15:45 UTC (permalink / raw)
  To: Wei Yang; +Cc: qemu-devel, quintela

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> In migration_thread() and qemu_savevm_state(), we savevm_state in
> following sequence:
> 
>     qemu_savevm_state_header(f);
>     qemu_savevm_state_setup(f);
> 
> Then it would be more proper to loadvm_state in the save sequence.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Yes, OK, I think that makes sense; the loadvm_state_setup
and savevm_state_setup are actually quite different in what they do,
however it does make sense to do the loadvm_state_setup after
we have the configuration loaded, because then potentially it means
we can alter the setup.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>


> ---
>  migration/savevm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 6c61056cde..a80ae83663 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2427,10 +2427,6 @@ int qemu_loadvm_state(QEMUFile *f)
>          return -ENOTSUP;
>      }
>  
> -    if (qemu_loadvm_state_setup(f) != 0) {
> -        return -EINVAL;
> -    }
> -
>      if (migrate_get_current()->send_configuration) {
>          if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
>              error_report("Configuration section missing");
> @@ -2445,6 +2441,10 @@ int qemu_loadvm_state(QEMUFile *f)
>          }
>      }
>  
> +    if (qemu_loadvm_state_setup(f) != 0) {
> +        return -EINVAL;
> +    }
> +
>      cpu_synchronize_all_pre_loadvm();
>  
>      ret = qemu_loadvm_state_main(f, mis);
> -- 
> 2.19.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked
  2019-04-24  0:46   ` Wei Yang
                     ` (2 preceding siblings ...)
  (?)
@ 2019-05-14 15:55   ` Dr. David Alan Gilbert
  -1 siblings, 0 replies; 25+ messages in thread
From: Dr. David Alan Gilbert @ 2019-05-14 15:55 UTC (permalink / raw)
  To: Wei Yang; +Cc: qemu-devel, quintela

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> Current call flow of save_snapshot is:
> 
>   save_snapshot
>     migration_is_blocked
>       qemu_savevm_state
>         migration_is_blocked
> 
> Since qemu_savevm_state is only called in save_snapshot, this means
> migration_is_blocked has been already checked.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Queued 1,3,4

> ---
>  migration/savevm.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 92af2471cd..2eea604624 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1412,10 +1412,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
>          return -EINVAL;
>      }
>  
> -    if (migration_is_blocked(errp)) {
> -        return -EINVAL;
> -    }
> -
>      if (migrate_use_block()) {
>          error_setg(errp, "Block migration and snapshots are incompatible");
>          return -EINVAL;
> -- 
> 2.19.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
  2019-05-14 15:18       ` Dr. David Alan Gilbert
@ 2019-05-15  6:38         ` Wei Yang
  2019-05-15  7:03           ` Wei Yang
  0 siblings, 1 reply; 25+ messages in thread
From: Wei Yang @ 2019-05-15  6:38 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: quintela, Daniel Henrique Barboza, Wei Yang, qemu-devel

On Tue, May 14, 2019 at 04:18:14PM +0100, Dr. David Alan Gilbert wrote:
>* Wei Yang (richardw.yang@linux.intel.com) wrote:
>> 
>> Well, when you look into the source side of migration:
>> 
>> qmp_migrate
>>   migrate_prepare
>>     migration_is_blocked
>> 
>> This means if migration_is_blocked fails, the source will not start migration.
>> And it is the same as save_snapshot.
>> 
>> From my understanding, when we load a vm, it should check the same
>> requirement.
>
>I've been thinking about this, and I think I agree with Daniel on this.
>The 'migration_blockers' list tells you that something about the
>*current* state of a device means that it can't be migrated - e.g.
>a 9pfs with a mounted filesystem can't be migrated.
>
>If we're about to reload the state from a snapshot, then the saved
>snapshot's state must have been migratable, so that's OK.
>

The situation is on a vm with 'migration_blockers' still could reload from a
snapshot.

This sounds reasonable. Thanks :-)

>(Whether all the device code is actually OK about being reset in
>that state is a different question; but I think it should be).
>
>Dave
>
>> -- 
>> Wei Yang
>> Help you, Help me
>--
>Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
  2019-05-15  6:38         ` Wei Yang
@ 2019-05-15  7:03           ` Wei Yang
  2019-05-15  9:38             ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 25+ messages in thread
From: Wei Yang @ 2019-05-15  7:03 UTC (permalink / raw)
  To: Wei Yang
  Cc: quintela, Daniel Henrique Barboza, Dr. David Alan Gilbert, qemu-devel

On Wed, May 15, 2019 at 02:38:27PM +0800, Wei Yang wrote:
>On Tue, May 14, 2019 at 04:18:14PM +0100, Dr. David Alan Gilbert wrote:
>>* Wei Yang (richardw.yang@linux.intel.com) wrote:
>>> 
>>> Well, when you look into the source side of migration:
>>> 
>>> qmp_migrate
>>>   migrate_prepare
>>>     migration_is_blocked
>>> 
>>> This means if migration_is_blocked fails, the source will not start migration.
>>> And it is the same as save_snapshot.
>>> 
>>> From my understanding, when we load a vm, it should check the same
>>> requirement.
>>
>>I've been thinking about this, and I think I agree with Daniel on this.
>>The 'migration_blockers' list tells you that something about the
>>*current* state of a device means that it can't be migrated - e.g.
>>a 9pfs with a mounted filesystem can't be migrated.
>>
>>If we're about to reload the state from a snapshot, then the saved
>>snapshot's state must have been migratable, so that's OK.
>>
>
>The situation is on a vm with 'migration_blockers' still could reload from a
>snapshot.
>
>This sounds reasonable. Thanks :-)
>

Well, this is still a little strange. The means source vm and destination vm
could have different configuration. Is this common?

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
  2019-05-15  7:03           ` Wei Yang
@ 2019-05-15  9:38             ` Dr. David Alan Gilbert
  2019-05-15 12:28               ` Wei Yang
  0 siblings, 1 reply; 25+ messages in thread
From: Dr. David Alan Gilbert @ 2019-05-15  9:38 UTC (permalink / raw)
  To: Wei Yang; +Cc: Daniel Henrique Barboza, qemu-devel, quintela

* Wei Yang (richardw.yang@linux.intel.com) wrote:
> On Wed, May 15, 2019 at 02:38:27PM +0800, Wei Yang wrote:
> >On Tue, May 14, 2019 at 04:18:14PM +0100, Dr. David Alan Gilbert wrote:
> >>* Wei Yang (richardw.yang@linux.intel.com) wrote:
> >>> 
> >>> Well, when you look into the source side of migration:
> >>> 
> >>> qmp_migrate
> >>>   migrate_prepare
> >>>     migration_is_blocked
> >>> 
> >>> This means if migration_is_blocked fails, the source will not start migration.
> >>> And it is the same as save_snapshot.
> >>> 
> >>> From my understanding, when we load a vm, it should check the same
> >>> requirement.
> >>
> >>I've been thinking about this, and I think I agree with Daniel on this.
> >>The 'migration_blockers' list tells you that something about the
> >>*current* state of a device means that it can't be migrated - e.g.
> >>a 9pfs with a mounted filesystem can't be migrated.
> >>
> >>If we're about to reload the state from a snapshot, then the saved
> >>snapshot's state must have been migratable, so that's OK.
> >>
> >
> >The situation is on a vm with 'migration_blockers' still could reload from a
> >snapshot.
> >
> >This sounds reasonable. Thanks :-)
> >
> 
> Well, this is still a little strange. The means source vm and destination vm
> could have different configuration. Is this common?

It's not different configuration that I'm worried about here; but it's different runtime state.
Items can get added/removed from migration_blockers dynamically
depending on the behaviour of the guest; e.g. a device might only
migratable in certain states.

Dave


> -- 
> Wei Yang
> Help you, Help me
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate
  2019-05-15  9:38             ` Dr. David Alan Gilbert
@ 2019-05-15 12:28               ` Wei Yang
  0 siblings, 0 replies; 25+ messages in thread
From: Wei Yang @ 2019-05-15 12:28 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: quintela, Daniel Henrique Barboza, Wei Yang, qemu-devel

On Wed, May 15, 2019 at 10:38:37AM +0100, Dr. David Alan Gilbert wrote:
>* Wei Yang (richardw.yang@linux.intel.com) wrote:
>> On Wed, May 15, 2019 at 02:38:27PM +0800, Wei Yang wrote:
>> >On Tue, May 14, 2019 at 04:18:14PM +0100, Dr. David Alan Gilbert wrote:
>> >>* Wei Yang (richardw.yang@linux.intel.com) wrote:
>> >>> 
>> >>> Well, when you look into the source side of migration:
>> >>> 
>> >>> qmp_migrate
>> >>>   migrate_prepare
>> >>>     migration_is_blocked
>> >>> 
>> >>> This means if migration_is_blocked fails, the source will not start migration.
>> >>> And it is the same as save_snapshot.
>> >>> 
>> >>> From my understanding, when we load a vm, it should check the same
>> >>> requirement.
>> >>
>> >>I've been thinking about this, and I think I agree with Daniel on this.
>> >>The 'migration_blockers' list tells you that something about the
>> >>*current* state of a device means that it can't be migrated - e.g.
>> >>a 9pfs with a mounted filesystem can't be migrated.
>> >>
>> >>If we're about to reload the state from a snapshot, then the saved
>> >>snapshot's state must have been migratable, so that's OK.
>> >>
>> >
>> >The situation is on a vm with 'migration_blockers' still could reload from a
>> >snapshot.
>> >
>> >This sounds reasonable. Thanks :-)
>> >
>> 
>> Well, this is still a little strange. The means source vm and destination vm
>> could have different configuration. Is this common?
>
>It's not different configuration that I'm worried about here; but it's different runtime state.
>Items can get added/removed from migration_blockers dynamically
>depending on the behaviour of the guest; e.g. a device might only
>migratable in certain states.
>

I am not familiar with the usage of migration_blockers, just found one case
when we add a reason to it. -- vhost_dev_init().

Per my understanding, this is a device. We specify it in command line or use
hot-plug to add it. To me, guest may not alter the add/remove? Looks even we
have one such device, we still could load vm. This looks not bad, but we have
the different devices from source. 

BTW, migration works if source and destination have different devices?

As you mentioned, these is some case where guest could add/remove a reason to
migration_blockers.  This is what you concerned right?

Do we need to limit the usage of migration_blockers? Just use this in the case
you concerned?

>Dave
>
>
>> -- 
>> Wei Yang
>> Help you, Help me
>--
>Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2019-05-15 12:29 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24  0:46 [Qemu-devel] [PATCH 0/4] cleanup savevm Wei Yang
2019-04-24  0:46 ` Wei Yang
2019-04-24  0:46 ` [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked Wei Yang
2019-04-24  0:46   ` Wei Yang
2019-04-25 19:20   ` Daniel Henrique Barboza
2019-04-26  0:39     ` Wei Yang
2019-04-26  0:39       ` Wei Yang
2019-05-14 14:46   ` Dr. David Alan Gilbert
2019-05-14 15:55   ` Dr. David Alan Gilbert
2019-04-24  0:46 ` [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate Wei Yang
2019-04-24  0:46   ` Wei Yang
2019-04-25 20:55   ` Daniel Henrique Barboza
2019-04-26  0:51     ` Wei Yang
2019-04-26  0:51       ` Wei Yang
2019-05-14 15:18       ` Dr. David Alan Gilbert
2019-05-15  6:38         ` Wei Yang
2019-05-15  7:03           ` Wei Yang
2019-05-15  9:38             ` Dr. David Alan Gilbert
2019-05-15 12:28               ` Wei Yang
2019-04-24  0:46 ` [Qemu-devel] [PATCH 3/4] migration/savevm: load_header before load_setup Wei Yang
2019-04-24  0:46   ` Wei Yang
2019-05-14 15:45   ` Dr. David Alan Gilbert
2019-04-24  0:47 ` [Qemu-devel] [PATCH 4/4] migration/savevm: wrap into qemu_loadvm_state_header() Wei Yang
2019-04-24  0:47   ` Wei Yang
2019-04-25 22:07   ` Daniel Henrique Barboza

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.