qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/3] Remove of loadvm handlers
@ 2017-05-30  8:37 Juan Quintela
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy Juan Quintela
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Juan Quintela @ 2017-05-30  8:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Hi

Changes from v1
- store load_version_id field to SaveStateHandler
- Adjust everything to use it

Thanks to Laurent to point that to me.

Please Review.

[v1]
We just have a loadvm handlers that are a new list only used in a
single place.  Just move everything to use the savevm_handlers (yes,
it is a list, and we could have a better name).

Once there, vmstate_load() had three arguments but only needs two.  Fix that.

Juan Quintela (3):
  migration: Use savevm_handlers instead of loadvm copy
  migration: loadvm handlers are not used
  migration: Remove section_id parameter from vmstate_load

 include/migration/migration.h |  5 ----
 include/migration/vmstate.h   |  2 --
 include/qemu/typedefs.h       |  1 -
 migration/migration.c         |  2 --
 migration/savevm.c            | 61 ++++++++++++++-----------------------------
 5 files changed, 19 insertions(+), 52 deletions(-)

-- 
2.9.4

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

* [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy
  2017-05-30  8:37 [Qemu-devel] [PATCH v2 0/3] Remove of loadvm handlers Juan Quintela
@ 2017-05-30  8:37 ` Juan Quintela
  2017-05-30  9:19   ` Laurent Vivier
  2017-05-30 17:30   ` Dr. David Alan Gilbert
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 2/3] migration: loadvm handlers are not used Juan Quintela
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 3/3] migration: Remove section_id parameter from vmstate_load Juan Quintela
  2 siblings, 2 replies; 9+ messages in thread
From: Juan Quintela @ 2017-05-30  8:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

There is no reason for having the loadvm_handlers at all.  There is
only one use, and we can use the savevm handlers.

We will remove the loadvm handlers on a following patch.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/savevm.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index d971e5e..d7c08c3 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -251,6 +251,8 @@ typedef struct SaveStateEntry {
     int instance_id;
     int alias_id;
     int version_id;
+    /* version id read from the stream */
+    int load_version_id;
     int section_id;
     SaveVMHandlers *ops;
     const VMStateDescription *vmsd;
@@ -1792,7 +1794,7 @@ struct LoadStateEntry {
  * Returns: true if the footer was good
  *          false if there is a problem (and calls error_report to say why)
  */
-static bool check_section_footer(QEMUFile *f, LoadStateEntry *le)
+static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)
 {
     uint8_t read_mark;
     uint32_t read_section_id;
@@ -1805,15 +1807,15 @@ static bool check_section_footer(QEMUFile *f, LoadStateEntry *le)
     read_mark = qemu_get_byte(f);
 
     if (read_mark != QEMU_VM_SECTION_FOOTER) {
-        error_report("Missing section footer for %s", le->se->idstr);
+        error_report("Missing section footer for %s", se->idstr);
         return false;
     }
 
     read_section_id = qemu_get_be32(f);
-    if (read_section_id != le->section_id) {
+    if (read_section_id != se->section_id) {
         error_report("Mismatched section id in footer for %s -"
                      " read 0x%x expected 0x%x",
-                     le->se->idstr, read_section_id, le->section_id);
+                     se->idstr, read_section_id, se->section_id);
         return false;
     }
 
@@ -1866,6 +1868,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
                      version_id, idstr, se->version_id);
         return -EINVAL;
     }
+    se->load_version_id = version_id;
 
     /* Validate if it is a device's state */
     if (xen_enabled() && se->is_ram) {
@@ -1881,13 +1884,13 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
     le->version_id = version_id;
     QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
 
-    ret = vmstate_load(f, le->se, le->version_id);
+    ret = vmstate_load(f, se, se->load_version_id);
     if (ret < 0) {
         error_report("error while loading state for instance 0x%x of"
                      " device '%s'", instance_id, idstr);
         return ret;
     }
-    if (!check_section_footer(f, le)) {
+    if (!check_section_footer(f, se)) {
         return -EINVAL;
     }
 
@@ -1898,29 +1901,29 @@ static int
 qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
 {
     uint32_t section_id;
-    LoadStateEntry *le;
+    SaveStateEntry *se;
     int ret;
 
     section_id = qemu_get_be32(f);
 
     trace_qemu_loadvm_state_section_partend(section_id);
-    QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
-        if (le->section_id == section_id) {
+    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
+        if (se->section_id == section_id) {
             break;
         }
     }
-    if (le == NULL) {
+    if (se == NULL) {
         error_report("Unknown savevm section %d", section_id);
         return -EINVAL;
     }
 
-    ret = vmstate_load(f, le->se, le->version_id);
+    ret = vmstate_load(f, se, se->load_version_id);
     if (ret < 0) {
         error_report("error while loading state section id %d(%s)",
-                     section_id, le->se->idstr);
+                     section_id, se->idstr);
         return ret;
     }
-    if (!check_section_footer(f, le)) {
+    if (!check_section_footer(f, se)) {
         return -EINVAL;
     }
 
-- 
2.9.4

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

* [Qemu-devel] [PATCH v2 2/3] migration: loadvm handlers are not used
  2017-05-30  8:37 [Qemu-devel] [PATCH v2 0/3] Remove of loadvm handlers Juan Quintela
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy Juan Quintela
@ 2017-05-30  8:37 ` Juan Quintela
  2017-05-30  9:36   ` Laurent Vivier
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 3/3] migration: Remove section_id parameter from vmstate_load Juan Quintela
  2 siblings, 1 reply; 9+ messages in thread
From: Juan Quintela @ 2017-05-30  8:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

So we remove all traces of them.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/migration.h |  5 -----
 include/migration/vmstate.h   |  2 --
 include/qemu/typedefs.h       |  1 -
 migration/migration.c         |  2 --
 migration/savevm.c            | 26 --------------------------
 5 files changed, 36 deletions(-)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index 0e807b6..d1a353a 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -50,8 +50,6 @@ enum mig_rp_message_type {
     MIG_RP_MSG_MAX
 };
 
-typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head;
-
 /* State for the incoming migration */
 struct MigrationIncomingState {
     QEMUFile *from_src_file;
@@ -89,9 +87,6 @@ struct MigrationIncomingState {
     /* The coroutine we should enter (back) after failover */
     Coroutine *migration_incoming_co;
     QemuSemaphore colo_incoming_sem;
-
-    /* See savevm.c */
-    LoadStateEntry_Head loadvm_handlers;
 };
 
 MigrationIncomingState *migration_incoming_get_current(void);
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f97411d..6689562 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -1020,8 +1020,6 @@ extern const VMStateInfo vmstate_info_qtailq;
 
 #define SELF_ANNOUNCE_ROUNDS 5
 
-void loadvm_free_handlers(MigrationIncomingState *mis);
-
 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                        void *opaque, int version_id);
 void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 33a6aa1..51958bf 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -39,7 +39,6 @@ typedef struct I2SCodec I2SCodec;
 typedef struct ISABus ISABus;
 typedef struct ISADevice ISADevice;
 typedef struct IsaDma IsaDma;
-typedef struct LoadStateEntry LoadStateEntry;
 typedef struct MACAddr MACAddr;
 typedef struct MachineClass MachineClass;
 typedef struct MachineState MachineState;
diff --git a/migration/migration.c b/migration/migration.c
index ad29e53..891a260 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -121,7 +121,6 @@ MigrationIncomingState *migration_incoming_get_current(void)
     if (!once) {
         mis_current.state = MIGRATION_STATUS_NONE;
         memset(&mis_current, 0, sizeof(MigrationIncomingState));
-        QLIST_INIT(&mis_current.loadvm_handlers);
         qemu_mutex_init(&mis_current.rp_mutex);
         qemu_event_init(&mis_current.main_thread_load_event, false);
         once = true;
@@ -134,7 +133,6 @@ void migration_incoming_state_destroy(void)
     struct MigrationIncomingState *mis = migration_incoming_get_current();
 
     qemu_event_destroy(&mis->main_thread_load_event);
-    loadvm_free_handlers(mis);
 }
 
 
diff --git a/migration/savevm.c b/migration/savevm.c
index d7c08c3..14af5ad 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1781,13 +1781,6 @@ static int loadvm_process_command(QEMUFile *f)
     return 0;
 }
 
-struct LoadStateEntry {
-    QLIST_ENTRY(LoadStateEntry) entry;
-    SaveStateEntry *se;
-    int section_id;
-    int version_id;
-};
-
 /*
  * Read a footer off the wire and check that it matches the expected section
  *
@@ -1823,22 +1816,11 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)
     return true;
 }
 
-void loadvm_free_handlers(MigrationIncomingState *mis)
-{
-    LoadStateEntry *le, *new_le;
-
-    QLIST_FOREACH_SAFE(le, &mis->loadvm_handlers, entry, new_le) {
-        QLIST_REMOVE(le, entry);
-        g_free(le);
-    }
-}
-
 static int
 qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
 {
     uint32_t instance_id, version_id, section_id;
     SaveStateEntry *se;
-    LoadStateEntry *le;
     char idstr[256];
     int ret;
 
@@ -1876,14 +1858,6 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
         return -EINVAL;
     }
 
-    /* Add entry */
-    le = g_malloc0(sizeof(*le));
-
-    le->se = se;
-    le->section_id = section_id;
-    le->version_id = version_id;
-    QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
-
     ret = vmstate_load(f, se, se->load_version_id);
     if (ret < 0) {
         error_report("error while loading state for instance 0x%x of"
-- 
2.9.4

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

* [Qemu-devel] [PATCH v2 3/3] migration: Remove section_id parameter from vmstate_load
  2017-05-30  8:37 [Qemu-devel] [PATCH v2 0/3] Remove of loadvm handlers Juan Quintela
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy Juan Quintela
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 2/3] migration: loadvm handlers are not used Juan Quintela
@ 2017-05-30  8:37 ` Juan Quintela
  2017-05-30  9:36   ` Laurent Vivier
  2 siblings, 1 reply; 9+ messages in thread
From: Juan Quintela @ 2017-05-30  8:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Everything else assumes that we always load a device from its own
savevm handler.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/savevm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 14af5ad..e5dd7ef 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -723,13 +723,13 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
     }
 }
 
-static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
+static int vmstate_load(QEMUFile *f, SaveStateEntry *se)
 {
     trace_vmstate_load(se->idstr, se->vmsd ? se->vmsd->name : "(old)");
     if (!se->vmsd) {         /* Old style */
-        return se->ops->load_state(f, se->opaque, version_id);
+        return se->ops->load_state(f, se->opaque, se->load_version_id);
     }
-    return vmstate_load_state(f, se->vmsd, se->opaque, version_id);
+    return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id);
 }
 
 static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, QJSON *vmdesc)
@@ -1858,7 +1858,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
         return -EINVAL;
     }
 
-    ret = vmstate_load(f, se, se->load_version_id);
+    ret = vmstate_load(f, se);
     if (ret < 0) {
         error_report("error while loading state for instance 0x%x of"
                      " device '%s'", instance_id, idstr);
@@ -1891,7 +1891,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
         return -EINVAL;
     }
 
-    ret = vmstate_load(f, se, se->load_version_id);
+    ret = vmstate_load(f, se);
     if (ret < 0) {
         error_report("error while loading state section id %d(%s)",
                      section_id, se->idstr);
-- 
2.9.4

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

* Re: [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy Juan Quintela
@ 2017-05-30  9:19   ` Laurent Vivier
  2017-05-30 17:30   ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2017-05-30  9:19 UTC (permalink / raw)
  To: Juan Quintela, qemu-devel; +Cc: dgilbert, peterx

On 30/05/2017 10:37, Juan Quintela wrote:
> There is no reason for having the loadvm_handlers at all.  There is
> only one use, and we can use the savevm handlers.
> 
> We will remove the loadvm handlers on a following patch.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> ---
>  migration/savevm.c | 29 ++++++++++++++++-------------
>  1 file changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index d971e5e..d7c08c3 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -251,6 +251,8 @@ typedef struct SaveStateEntry {
>      int instance_id;
>      int alias_id;
>      int version_id;
> +    /* version id read from the stream */
> +    int load_version_id;
>      int section_id;
>      SaveVMHandlers *ops;
>      const VMStateDescription *vmsd;
> @@ -1792,7 +1794,7 @@ struct LoadStateEntry {
>   * Returns: true if the footer was good
>   *          false if there is a problem (and calls error_report to say why)
>   */
> -static bool check_section_footer(QEMUFile *f, LoadStateEntry *le)
> +static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)
>  {
>      uint8_t read_mark;
>      uint32_t read_section_id;
> @@ -1805,15 +1807,15 @@ static bool check_section_footer(QEMUFile *f, LoadStateEntry *le)
>      read_mark = qemu_get_byte(f);
>  
>      if (read_mark != QEMU_VM_SECTION_FOOTER) {
> -        error_report("Missing section footer for %s", le->se->idstr);
> +        error_report("Missing section footer for %s", se->idstr);
>          return false;
>      }
>  
>      read_section_id = qemu_get_be32(f);
> -    if (read_section_id != le->section_id) {
> +    if (read_section_id != se->section_id) {
>          error_report("Mismatched section id in footer for %s -"
>                       " read 0x%x expected 0x%x",
> -                     le->se->idstr, read_section_id, le->section_id);
> +                     se->idstr, read_section_id, se->section_id);
>          return false;
>      }
>  
> @@ -1866,6 +1868,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
>                       version_id, idstr, se->version_id);
>          return -EINVAL;
>      }
> +    se->load_version_id = version_id;
>  
>      /* Validate if it is a device's state */
>      if (xen_enabled() && se->is_ram) {
> @@ -1881,13 +1884,13 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
>      le->version_id = version_id;
>      QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
>  
> -    ret = vmstate_load(f, le->se, le->version_id);
> +    ret = vmstate_load(f, se, se->load_version_id);
>      if (ret < 0) {
>          error_report("error while loading state for instance 0x%x of"
>                       " device '%s'", instance_id, idstr);
>          return ret;
>      }
> -    if (!check_section_footer(f, le)) {
> +    if (!check_section_footer(f, se)) {
>          return -EINVAL;
>      }
>  
> @@ -1898,29 +1901,29 @@ static int
>  qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
>  {
>      uint32_t section_id;
> -    LoadStateEntry *le;
> +    SaveStateEntry *se;
>      int ret;
>  
>      section_id = qemu_get_be32(f);
>  
>      trace_qemu_loadvm_state_section_partend(section_id);
> -    QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
> -        if (le->section_id == section_id) {
> +    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
> +        if (se->section_id == section_id) {
>              break;
>          }
>      }
> -    if (le == NULL) {
> +    if (se == NULL) {
>          error_report("Unknown savevm section %d", section_id);
>          return -EINVAL;
>      }
>  
> -    ret = vmstate_load(f, le->se, le->version_id);
> +    ret = vmstate_load(f, se, se->load_version_id);
>      if (ret < 0) {
>          error_report("error while loading state section id %d(%s)",
> -                     section_id, le->se->idstr);
> +                     section_id, se->idstr);
>          return ret;
>      }
> -    if (!check_section_footer(f, le)) {
> +    if (!check_section_footer(f, se)) {
>          return -EINVAL;
>      }
>  
> 

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

* Re: [Qemu-devel] [PATCH v2 2/3] migration: loadvm handlers are not used
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 2/3] migration: loadvm handlers are not used Juan Quintela
@ 2017-05-30  9:36   ` Laurent Vivier
  0 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2017-05-30  9:36 UTC (permalink / raw)
  To: Juan Quintela, qemu-devel; +Cc: dgilbert, peterx

On 30/05/2017 10:37, Juan Quintela wrote:
> So we remove all traces of them.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> ---
>  include/migration/migration.h |  5 -----
>  include/migration/vmstate.h   |  2 --
>  include/qemu/typedefs.h       |  1 -
>  migration/migration.c         |  2 --
>  migration/savevm.c            | 26 --------------------------
>  5 files changed, 36 deletions(-)
> 
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index 0e807b6..d1a353a 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -50,8 +50,6 @@ enum mig_rp_message_type {
>      MIG_RP_MSG_MAX
>  };
>  
> -typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head;
> -
>  /* State for the incoming migration */
>  struct MigrationIncomingState {
>      QEMUFile *from_src_file;
> @@ -89,9 +87,6 @@ struct MigrationIncomingState {
>      /* The coroutine we should enter (back) after failover */
>      Coroutine *migration_incoming_co;
>      QemuSemaphore colo_incoming_sem;
> -
> -    /* See savevm.c */
> -    LoadStateEntry_Head loadvm_handlers;
>  };
>  
>  MigrationIncomingState *migration_incoming_get_current(void);
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index f97411d..6689562 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -1020,8 +1020,6 @@ extern const VMStateInfo vmstate_info_qtailq;
>  
>  #define SELF_ANNOUNCE_ROUNDS 5
>  
> -void loadvm_free_handlers(MigrationIncomingState *mis);
> -
>  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>                         void *opaque, int version_id);
>  void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
> diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
> index 33a6aa1..51958bf 100644
> --- a/include/qemu/typedefs.h
> +++ b/include/qemu/typedefs.h
> @@ -39,7 +39,6 @@ typedef struct I2SCodec I2SCodec;
>  typedef struct ISABus ISABus;
>  typedef struct ISADevice ISADevice;
>  typedef struct IsaDma IsaDma;
> -typedef struct LoadStateEntry LoadStateEntry;
>  typedef struct MACAddr MACAddr;
>  typedef struct MachineClass MachineClass;
>  typedef struct MachineState MachineState;
> diff --git a/migration/migration.c b/migration/migration.c
> index ad29e53..891a260 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -121,7 +121,6 @@ MigrationIncomingState *migration_incoming_get_current(void)
>      if (!once) {
>          mis_current.state = MIGRATION_STATUS_NONE;
>          memset(&mis_current, 0, sizeof(MigrationIncomingState));
> -        QLIST_INIT(&mis_current.loadvm_handlers);
>          qemu_mutex_init(&mis_current.rp_mutex);
>          qemu_event_init(&mis_current.main_thread_load_event, false);
>          once = true;
> @@ -134,7 +133,6 @@ void migration_incoming_state_destroy(void)
>      struct MigrationIncomingState *mis = migration_incoming_get_current();
>  
>      qemu_event_destroy(&mis->main_thread_load_event);
> -    loadvm_free_handlers(mis);
>  }
>  
>  
> diff --git a/migration/savevm.c b/migration/savevm.c
> index d7c08c3..14af5ad 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1781,13 +1781,6 @@ static int loadvm_process_command(QEMUFile *f)
>      return 0;
>  }
>  
> -struct LoadStateEntry {
> -    QLIST_ENTRY(LoadStateEntry) entry;
> -    SaveStateEntry *se;
> -    int section_id;
> -    int version_id;
> -};
> -
>  /*
>   * Read a footer off the wire and check that it matches the expected section
>   *
> @@ -1823,22 +1816,11 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)
>      return true;
>  }
>  
> -void loadvm_free_handlers(MigrationIncomingState *mis)
> -{
> -    LoadStateEntry *le, *new_le;
> -
> -    QLIST_FOREACH_SAFE(le, &mis->loadvm_handlers, entry, new_le) {
> -        QLIST_REMOVE(le, entry);
> -        g_free(le);
> -    }
> -}
> -
>  static int
>  qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
>  {
>      uint32_t instance_id, version_id, section_id;
>      SaveStateEntry *se;
> -    LoadStateEntry *le;
>      char idstr[256];
>      int ret;
>  
> @@ -1876,14 +1858,6 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
>          return -EINVAL;
>      }
>  
> -    /* Add entry */
> -    le = g_malloc0(sizeof(*le));
> -
> -    le->se = se;
> -    le->section_id = section_id;
> -    le->version_id = version_id;
> -    QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
> -
>      ret = vmstate_load(f, se, se->load_version_id);
>      if (ret < 0) {
>          error_report("error while loading state for instance 0x%x of"
> 

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

* Re: [Qemu-devel] [PATCH v2 3/3] migration: Remove section_id parameter from vmstate_load
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 3/3] migration: Remove section_id parameter from vmstate_load Juan Quintela
@ 2017-05-30  9:36   ` Laurent Vivier
  0 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2017-05-30  9:36 UTC (permalink / raw)
  To: Juan Quintela, qemu-devel; +Cc: dgilbert, peterx

On 30/05/2017 10:37, Juan Quintela wrote:
> Everything else assumes that we always load a device from its own
> savevm handler.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> ---
>  migration/savevm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 14af5ad..e5dd7ef 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -723,13 +723,13 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
>      }
>  }
>  
> -static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
> +static int vmstate_load(QEMUFile *f, SaveStateEntry *se)
>  {
>      trace_vmstate_load(se->idstr, se->vmsd ? se->vmsd->name : "(old)");
>      if (!se->vmsd) {         /* Old style */
> -        return se->ops->load_state(f, se->opaque, version_id);
> +        return se->ops->load_state(f, se->opaque, se->load_version_id);
>      }
> -    return vmstate_load_state(f, se->vmsd, se->opaque, version_id);
> +    return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id);
>  }
>  
>  static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, QJSON *vmdesc)
> @@ -1858,7 +1858,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
>          return -EINVAL;
>      }
>  
> -    ret = vmstate_load(f, se, se->load_version_id);
> +    ret = vmstate_load(f, se);
>      if (ret < 0) {
>          error_report("error while loading state for instance 0x%x of"
>                       " device '%s'", instance_id, idstr);
> @@ -1891,7 +1891,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
>          return -EINVAL;
>      }
>  
> -    ret = vmstate_load(f, se, se->load_version_id);
> +    ret = vmstate_load(f, se);
>      if (ret < 0) {
>          error_report("error while loading state section id %d(%s)",
>                       section_id, se->idstr);
> 

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

* Re: [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy
  2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy Juan Quintela
  2017-05-30  9:19   ` Laurent Vivier
@ 2017-05-30 17:30   ` Dr. David Alan Gilbert
  2017-05-30 18:35     ` Juan Quintela
  1 sibling, 1 reply; 9+ messages in thread
From: Dr. David Alan Gilbert @ 2017-05-30 17:30 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx

* Juan Quintela (quintela@redhat.com) wrote:
> There is no reason for having the loadvm_handlers at all.  There is
> only one use, and we can use the savevm handlers.
> 
> We will remove the loadvm handlers on a following patch.

<snip>

>      trace_qemu_loadvm_state_section_partend(section_id);
> -    QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
> -        if (le->section_id == section_id) {
> +    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
> +        if (se->section_id == section_id) {

Isn't this the problem?  What guarantees that the se->section_id
is the same as the source's section_id - I don't think anything.
It's just dynamically allocated in register_savevm_live so the
initialisation order on source/dest could be different and you'd
get different ID.  You can't update se->section_id
unless you guaranteed to updated all of them.

Dave

>              break;
>          }
>      }
> -    if (le == NULL) {
> +    if (se == NULL) {
>          error_report("Unknown savevm section %d", section_id);
>          return -EINVAL;
>      }
>  
> -    ret = vmstate_load(f, le->se, le->version_id);
> +    ret = vmstate_load(f, se, se->load_version_id);
>      if (ret < 0) {
>          error_report("error while loading state section id %d(%s)",
> -                     section_id, le->se->idstr);
> +                     section_id, se->idstr);
>          return ret;
>      }
> -    if (!check_section_footer(f, le)) {
> +    if (!check_section_footer(f, se)) {
>          return -EINVAL;
>      }
>  
> -- 
> 2.9.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy
  2017-05-30 17:30   ` Dr. David Alan Gilbert
@ 2017-05-30 18:35     ` Juan Quintela
  0 siblings, 0 replies; 9+ messages in thread
From: Juan Quintela @ 2017-05-30 18:35 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel, lvivier, peterx

"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> There is no reason for having the loadvm_handlers at all.  There is
>> only one use, and we can use the savevm handlers.
>> 
>> We will remove the loadvm handlers on a following patch.
>
> <snip>
>
>>      trace_qemu_loadvm_state_section_partend(section_id);
>> -    QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
>> -        if (le->section_id == section_id) {
>> +    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
>> +        if (se->section_id == section_id) {
>
> Isn't this the problem?  What guarantees that the se->section_id
> is the same as the source's section_id - I don't think anything.
> It's just dynamically allocated in register_savevm_live so the
> initialisation order on source/dest could be different and you'd
> get different ID.  You can't update se->section_id
> unless you guaranteed to updated all of them.

Ok.  It worked for me because I was using the same command line in both
sides.

Changed to add load_section_id and adjust all around.

Thanks, Juan.

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

end of thread, other threads:[~2017-05-30 18:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-30  8:37 [Qemu-devel] [PATCH v2 0/3] Remove of loadvm handlers Juan Quintela
2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 1/3] migration: Use savevm_handlers instead of loadvm copy Juan Quintela
2017-05-30  9:19   ` Laurent Vivier
2017-05-30 17:30   ` Dr. David Alan Gilbert
2017-05-30 18:35     ` Juan Quintela
2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 2/3] migration: loadvm handlers are not used Juan Quintela
2017-05-30  9:36   ` Laurent Vivier
2017-05-30  8:37 ` [Qemu-devel] [PATCH v2 3/3] migration: Remove section_id parameter from vmstate_load Juan Quintela
2017-05-30  9:36   ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).