diff mbox

[for-2.4,v3,1/3] migration: Fix global state with Xen.

Message ID 1438612161-15822-2-git-send-email-anthony.perard@citrix.com
State New
Headers show

Commit Message

Anthony PERARD Aug. 3, 2015, 2:29 p.m. UTC
When doing migration via the QMP command xen_save_devices_state, the
current runstate is not store into the global state section. Also the
current runstate is not the one we want on the receiver side.

During migration, the Xen toolstack paused QEMU before save the devices
state. Also, the toolstack expect QEMU to autostart when the migration is
finished.
So this patch store "running" as it's current runstate.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 include/migration/migration.h | 1 +
 migration/migration.c         | 7 +++++++
 migration/savevm.c            | 1 +
 3 files changed, 9 insertions(+)

Comments

Stefano Stabellini Aug. 3, 2015, 2:53 p.m. UTC | #1
On Mon, 3 Aug 2015, Anthony PERARD wrote:
> When doing migration via the QMP command xen_save_devices_state, the
> current runstate is not store into the global state section. Also the
> current runstate is not the one we want on the receiver side.
> 
> During migration, the Xen toolstack paused QEMU before save the devices
> state. Also, the toolstack expect QEMU to autostart when the migration is
> finished.
> So this patch store "running" as it's current runstate.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Amit, Juan,

if you are OK with this patch, I'll send a pull request with it and
patch #3.

Thanks,

Stefano


>  include/migration/migration.h | 1 +
>  migration/migration.c         | 7 +++++++
>  migration/savevm.c            | 1 +
>  3 files changed, 9 insertions(+)
> 
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index a2f8ed0..8334621 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -203,4 +203,5 @@ void register_global_state(void);
>  void global_state_set_optional(void);
>  void savevm_skip_configuration(void);
>  int global_state_store(void);
> +void global_state_store_running(void);
>  #endif
> diff --git a/migration/migration.c b/migration/migration.c
> index fd4f99b..662e77e 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -122,6 +122,13 @@ int global_state_store(void)
>      return 0;
>  }
>  
> +void global_state_store_running(void)
> +{
> +    const char *state = RunState_lookup[RUN_STATE_RUNNING];
> +    strncpy((char *)global_state.runstate,
> +           state, sizeof(global_state.runstate));
> +}
> +
>  static bool global_state_received(void)
>  {
>      return global_state.received;
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 81dbe58..6071215 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1394,6 +1394,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
>  
>      saved_vm_running = runstate_is_running();
>      vm_stop(RUN_STATE_SAVE_VM);
> +    global_state_store_running();
>  
>      f = qemu_fopen(filename, "wb");
>      if (!f) {
> -- 
> Anthony PERARD
>
Amit Shah Aug. 3, 2015, 4:06 p.m. UTC | #2
On (Mon) 03 Aug 2015 [15:53:57], Stefano Stabellini wrote:
> On Mon, 3 Aug 2015, Anthony PERARD wrote:
> > When doing migration via the QMP command xen_save_devices_state, the
> > current runstate is not store into the global state section. Also the
> > current runstate is not the one we want on the receiver side.
> > 
> > During migration, the Xen toolstack paused QEMU before save the devices
> > state. Also, the toolstack expect QEMU to autostart when the migration is
> > finished.
> > So this patch store "running" as it's current runstate.
> > 
> > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> Amit, Juan,
> 
> if you are OK with this patch, I'll send a pull request with it and
> patch #3.

Juan is away for the week.

I'm fine with patches 1 and 3 here; you may pick them up, thanks.


		Amit
diff mbox

Patch

diff --git a/include/migration/migration.h b/include/migration/migration.h
index a2f8ed0..8334621 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -203,4 +203,5 @@  void register_global_state(void);
 void global_state_set_optional(void);
 void savevm_skip_configuration(void);
 int global_state_store(void);
+void global_state_store_running(void);
 #endif
diff --git a/migration/migration.c b/migration/migration.c
index fd4f99b..662e77e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -122,6 +122,13 @@  int global_state_store(void)
     return 0;
 }
 
+void global_state_store_running(void)
+{
+    const char *state = RunState_lookup[RUN_STATE_RUNNING];
+    strncpy((char *)global_state.runstate,
+           state, sizeof(global_state.runstate));
+}
+
 static bool global_state_received(void)
 {
     return global_state.received;
diff --git a/migration/savevm.c b/migration/savevm.c
index 81dbe58..6071215 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1394,6 +1394,7 @@  void qmp_xen_save_devices_state(const char *filename, Error **errp)
 
     saved_vm_running = runstate_is_running();
     vm_stop(RUN_STATE_SAVE_VM);
+    global_state_store_running();
 
     f = qemu_fopen(filename, "wb");
     if (!f) {