Skip to contentSkip to conversation

Regression fix for migration on Xen

GIT PULL Amit Shah 3 participants 6 messages Aug 3, 2015

lore
Share & tools
lore

Amit Shah

author
#0 lore raw

The following changes since commit cb48f67ad8c7b33c617d4f8144a27706e69fd688:

bsd-user: Fix operand to cpu_x86_exec (2015-07-30 12:38:49 +0100)

are available in the git repository at:

https://git.kernel.org/pub/scm/qemu/amit/migration for-2.4

for you to fetch changes up to 040f70812f1fc2523945a047982694d1ef1d9e1d:

migration: Add configuration section to vmstate with xen. (2015-08-03 11:42:39 +0530)

----------------------------------------------------------------
Fixes a regression with migration for the Xen machine type

----------------------------------------------------------------
Anthony PERARD (3):
migration: Fix regretion for xenfv machine.
migration: Fix global state with Xen.
migration: Add configuration section to vmstate with xen.

 hw/i386/pc_piix.c             | 3 +++
 include/migration/migration.h | 1 +
 migration/migration.c         | 7 +++++++
 migration/savevm.c            | 6 ++++++
 4 files changed, 17 insertions(+)
Signature · 1 line
2.4.3
author
#1 lore raw

[Qemu-devel] [PULL for-2.4 1/3] migration: Fix regretion for xenfv machine.

From: Anthony PERARD <[email protected]>

This fix migration from the same QEMU version and from previous QEMU version.

Quoted 1 line

From the global state section, we don't need runstate with Xen. Right now,

the way the Xen toolstack knows when QEMU is ready is when QEMU reach "running" runstate.

The configuration sectin and the section footers are not going to be present in previous version of QEMU with xenfv machine, so we skip them.

Message-Id: <[email protected]>

---
 hw/i386/pc_piix.c | 3 +++
 1 file changed, 3 insertions(+)
hw/i386/pc_piix.c +3 -0
index a896624..b18758d 100644
@@ -455,6 +455,9 @@ static void pc_xen_hvm_init(MachineState *machine)
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
     }
+    global_state_set_optional();
+    savevm_skip_configuration();
+    savevm_skip_section_footers();
 }
 #endif
 
Signature · 1 line
2.4.3
author
#2 lore raw

[Qemu-devel] [PULL for-2.4 2/3] migration: Fix global state with Xen.

In reply to Amit Shah

From: Anthony PERARD <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/migration/migration.h | 1 +
 migration/migration.c         | 7 +++++++
 migration/savevm.c            | 1 +
 3 files changed, 9 insertions(+)
include/migration/migration.h +1 -0
index a2f8ed0..8334621 100644
@@ -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
migration/migration.c +7 -0
index fd4f99b..175a397 100644
@@ -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];
+    memcpy((char *)global_state.runstate,
+           state, sizeof(global_state.runstate));
+}
+
 static bool global_state_received(void)
 {
     return global_state.received;
migration/savevm.c +1 -0
index 81dbe58..6071215 100644
@@ -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) {
Signature · 1 line
2.4.3
author
#4 lore raw

[Qemu-devel] [PULL for-2.4 3/3] migration: Add configuration section to vmstate with xen.

In reply to Amit Shah

From: Anthony PERARD <[email protected]>

This adds the configuration section in the vmstate saved by xen_save_devices_state.

Message-Id: <[email protected]>

---
 migration/savevm.c | 5 +++++
 1 file changed, 5 insertions(+)
migration/savevm.c +5 -0
index 6071215..b3f605c 100644
@@ -961,6 +961,11 @@ static int qemu_save_device_state(QEMUFile *f)
 
     cpu_synchronize_all_states();
 
+    if (!savevm_state.skip_configuration) {
+        qemu_put_byte(f, QEMU_VM_CONFIGURATION);
+        vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);
+    }
+
     QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
         if (se->is_ram) {
             continue;
Signature · 1 line
2.4.3
#3 lore raw

Re: [Qemu-devel] [PULL for-2.4 2/3] migration: Fix global state with Xen.

In reply to Amit Shah
Quoted 35 lines · * Amit Shah ([email protected]) wrote:

From: Anthony PERARD <[email protected]>

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.

Message-Id: <[email protected]>

---
 include/migration/migration.h | 1 +
 migration/migration.c         | 7 +++++++
 migration/savevm.c            | 1 +
 3 files changed, 9 insertions(+)
include/migration/migration.h +1 -0
index a2f8ed0..8334621 100644
@@ -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
migration/migration.c +0 -0
index fd4f99b..175a397 100644

migration/migration.c int global_state_store(void) · line 130

Quoted 9 lines
migration/migration.c +6 -0
@@ -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];
+    memcpy((char *)global_state.runstate,
+           state, sizeof(global_state.runstate));
+}

As mentioned previously, I think that needs to be a strcpy, NOT a memcpy; the RuNState_lookup[] array isn't guaranteed to be long enough to fulfill that memcpy.

Dave

Quoted 20 lines
migration/migration.c +1 -0
+
 static bool global_state_received(void)
 {
     return global_state.received;
migration/savevm.c +1 -0
index 81dbe58..6071215 100644
@@ -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) {
Signature · 1 line
2.4.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#5 lore raw
In reply to Amit Shah
Quoted 6 lines · Amit Shah

The following changes since commit cb48f67ad8c7b33c617d4f8144a27706e69fd688:

bsd-user: Fix operand to cpu_x86_exec (2015-07-30 12:38:49 +0100)

are available in the git repository at:

Quoted 8 lines

https://git.kernel.org/pub/scm/qemu/amit/migration for-2.4

for you to fetch changes up to 040f70812f1fc2523945a047982694d1ef1d9e1d:

migration: Add configuration section to vmstate with xen. (2015-08-03 11:42:39 +0530)

----------------------------------------------------------------
Fixes a regression with migration for the Xen machine type

Hi,

I do have an update on this series which would also fix 'pc,accel=xen' machine case, which I should send today.

And there is actually an issue with one of the patch, which should use strcpy instead of memcpy.

So please don't apply just yet.

Thanks,

Quoted 11 lines

----------------------------------------------------------------
Anthony PERARD (3):
migration: Fix regretion for xenfv machine.
migration: Fix global state with Xen.
migration: Add configuration section to vmstate with xen.

 hw/i386/pc_piix.c             | 3 +++
 include/migration/migration.h | 1 +
 migration/migration.c         | 7 +++++++
 migration/savevm.c            | 6 ++++++
 4 files changed, 17 insertions(+)
Signature · 1 line
Anthony PERARD