[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/32] migration/savevm.c: migrate non-default page s
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 05/32] migration/savevm.c: migrate non-default page size |
Date: |
Mon, 24 Oct 2016 18:25:01 +0100 |
Add a subsection to vmstate_configuration which is present
only if the guest is using a target page size which is
different from the default. This allows us to helpfully
diagnose attempts to migrate between machines which
are using different target page sizes.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
---
migration/savevm.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/migration/savevm.c b/migration/savevm.c
index a831ec2..cfcbbd0 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -265,6 +265,7 @@ typedef struct SaveState {
bool skip_configuration;
uint32_t len;
const char *name;
+ uint32_t target_page_bits;
} SaveState;
static SaveState savevm_state = {
@@ -286,6 +287,19 @@ static void configuration_pre_save(void *opaque)
state->len = strlen(current_name);
state->name = current_name;
+ state->target_page_bits = TARGET_PAGE_BITS;
+}
+
+static int configuration_pre_load(void *opaque)
+{
+ SaveState *state = opaque;
+
+ /* If there is no target-page-bits subsection it means the source
+ * predates the variable-target-page-bits support and is using the
+ * minimum possible value for this CPU.
+ */
+ state->target_page_bits = TARGET_PAGE_BITS_MIN;
+ return 0;
}
static int configuration_post_load(void *opaque, int version_id)
@@ -298,12 +312,43 @@ static int configuration_post_load(void *opaque, int
version_id)
(int) state->len, state->name, current_name);
return -EINVAL;
}
+
+ if (state->target_page_bits != TARGET_PAGE_BITS) {
+ error_report("Received TARGET_PAGE_BITS is %d but local is %d",
+ state->target_page_bits, TARGET_PAGE_BITS);
+ return -EINVAL;
+ }
+
return 0;
}
+/* The target-page-bits subsection is present only if the
+ * target page size is not the same as the default (ie the
+ * minimum page size for a variable-page-size guest CPU).
+ * If it is present then it contains the actual target page
+ * bits for the machine, and migration will fail if the
+ * two ends don't agree about it.
+ */
+static bool vmstate_target_page_bits_needed(void *opaque)
+{
+ return TARGET_PAGE_BITS > TARGET_PAGE_BITS_MIN;
+}
+
+static const VMStateDescription vmstate_target_page_bits = {
+ .name = "configuration/target-page-bits",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = vmstate_target_page_bits_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32(target_page_bits, SaveState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_configuration = {
.name = "configuration",
.version_id = 1,
+ .pre_load = configuration_pre_load,
.post_load = configuration_post_load,
.pre_save = configuration_pre_save,
.fields = (VMStateField[]) {
@@ -311,6 +356,10 @@ static const VMStateDescription vmstate_configuration = {
VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, 0, len),
VMSTATE_END_OF_LIST()
},
+ .subsections = (const VMStateDescription*[]) {
+ &vmstate_target_page_bits,
+ NULL
+ }
};
static void dump_vmstate_vmsd(FILE *out_file,
--
2.7.4
- [Qemu-devel] [PULL 25/32] i2c: Fix SMBus read transactions to avoid double events, (continued)
- [Qemu-devel] [PULL 25/32] i2c: Fix SMBus read transactions to avoid double events, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 26/32] timer: stm32f2xx_timer: add check for prescaler value, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 31/32] target-arm: Implement new HLT trap for semihosting, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 18/32] tests: ptimer: Change the copyright comment, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 10/32] hw/ptimer: Add "continuous trigger" policy, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 21/32] tests: Add tests for the ARM MPTimer, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 13/32] tests: ptimer: Add tests for "no immediate trigger" policy, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 02/32] exec.c: Remove static allocation of sub_section of sub_page, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 28/32] hw/arm: QOM'ify pxa2xx_gpio.c, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 08/32] hw/ptimer: Add "wraparound after one period" policy, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 05/32] migration/savevm.c: migrate non-default page size,
Peter Maydell <=
- [Qemu-devel] [PULL 19/32] tests: ptimer: Replace 10000 with 1, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 17/32] tests: ptimer: Add tests for "no counter round down" policy, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 15/32] tests: ptimer: Add tests for "no immediate reload" policy, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 32/32] i2c: Add asserts for second smbus i2c_start_transfer(), Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 09/32] tests: ptimer: Add tests for "wraparound after one period" policy, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 04/32] cpu: Support a target CPU having a variable page size, Peter Maydell, 2016/10/24
- [Qemu-devel] [PULL 03/32] translate-all.c: Compute L1 page table properties at runtime, Peter Maydell, 2016/10/24
- Re: [Qemu-devel] [PULL 00/32] target-arm queue, no-reply, 2016/10/24
- Re: [Qemu-devel] [PULL 00/32] target-arm queue, Peter Maydell, 2016/10/25