Skip to contentSkip to conversation

target-sparc: Update to use VMStateDescription

PATCH Superseded Peter Maydell 4 participants 11 messages Aug 10, 2015 – Aug 18, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover target-sparc: Update to use VMStateDescription

This patchset updates target-sparc to use VMStateDescription rather than hand-written save/load functions. (This and CRIS are the last two targets still using the old approach.)

It's based on some patches from back in 2012 by Juan which I've updated, rebased and made some tweaks to.

This is a migration compatibility break; we don't care about cross-version migration on SPARC guests, and not having to maintain the old wire format allows a cleaner vmstate description in several ways.

NB that the 'split cpu_put_psr' patch seems to me to be a bugfix in and of itself, since currently we might try to call cpu_check_irqs() and deliver interrupts while we're halfway through updating a PSR value...

Juan Quintela (2):
vmstate: introduce CPU_DoubleU arrays
target-sparc: Convert to VMStateDescription

Peter Maydell (2):
target-sparc: Split cpu_put_psr into side-effect and no-side-effect
parts
target-sparc: Don't flush TLB in cpu_load function

 hw/sparc64/sun4u.c          |  20 ---
 include/migration/vmstate.h |   7 +
 migration/vmstate.c         |  23 +++
 target-sparc/cpu-qom.h      |   4 +
 target-sparc/cpu.c          |   1 +
 target-sparc/cpu.h          |   7 +-
 target-sparc/machine.c      | 360 ++++++++++++++++++++------------------------
 target-sparc/win_helper.c   |  19 ++-
 8 files changed, 210 insertions(+), 231 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 vmstate: introduce CPU_DoubleU arrays

From: Juan Quintela <[email protected]>

Add vmstate support for migrating arrays of CPU_DoubleU via VMSTATE_CPUDOUBLE_ARRAY.

[PMM: rebased, since files have all moved since 2012;
added VMSTATE_CPUDOUBLE_ARRAY_V for consistency with FLOAT64]

---
 include/migration/vmstate.h |  7 +++++++
 migration/vmstate.c         | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)
include/migration/vmstate.h +7 -0
index 2e5a97d..a234d44 100644
@@ -154,6 +154,7 @@ extern const VMStateInfo vmstate_info_uint32;
 extern const VMStateInfo vmstate_info_uint64;
 
 extern const VMStateInfo vmstate_info_float64;
+extern const VMStateInfo vmstate_info_cpudouble;
 
 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_buffer;
@@ -769,6 +770,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
     VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0)
 
+#define VMSTATE_CPUDOUBLE_ARRAY_V(_f, _s, _n, _v)                     \
+    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_cpudouble, CPU_DoubleU)
+
+#define VMSTATE_CPUDOUBLE_ARRAY(_f, _s, _n)                           \
+    VMSTATE_CPUDOUBLE_ARRAY_V(_f, _s, _n, 0)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
 
migration/vmstate.c +23 -0
index e8ccf22..f70fe59 100644
@@ -794,6 +794,29 @@ const VMStateInfo vmstate_info_float64 = {
     .put  = put_float64,
 };
 
+/* CPU_DoubleU type */
+
+static int get_cpudouble(QEMUFile *f, void *pv, size_t size)
+{
+    CPU_DoubleU *v = pv;
+    qemu_get_be32s(f, &v->l.upper);
+    qemu_get_be32s(f, &v->l.lower);
+    return 0;
+}
+
+static void put_cpudouble(QEMUFile *f, void *pv, size_t size)
+{
+    CPU_DoubleU *v = pv;
+    qemu_put_be32s(f, &v->l.upper);
+    qemu_put_be32s(f, &v->l.lower);
+}
+
+const VMStateInfo vmstate_info_cpudouble = {
+    .name = "CPU_Double_U",
+    .get  = get_cpudouble,
+    .put  = put_cpudouble,
+};
+
 /* uint8_t buffers */
 
 static int get_buffer(QEMUFile *f, void *pv, size_t size)
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/4 target-sparc: Split cpu_put_psr into side-effect and no-side-effect parts

In reply to Peter Maydell

For inbound migration we really want to be able to set the PSR without having any side effects, but cpu_put_psr() calls cpu_check_irqs() which might try to deliver CPU interrupts. Split cpu_put_psr() into the no-side-effect and side-effect parts.

This includes reordering the cpu_check_irqs() to the end of cpu_put_psr(), because that function may actually end up calling cpu_interrupt(), which does not seem like a good thing to happen in the middle of updating the PSR.

---
 target-sparc/cpu.h        |  1 +
 target-sparc/win_helper.c | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
target-sparc/cpu.h +1 -0
index 0522b65..9a4a010 100644
@@ -542,6 +542,7 @@ int cpu_sparc_exec(CPUState *cpu);
 /* win_helper.c */
 target_ulong cpu_get_psr(CPUSPARCState *env1);
 void cpu_put_psr(CPUSPARCState *env1, target_ulong val);
+void cpu_put_psr_raw(CPUSPARCState *env1, target_ulong val);
 #ifdef TARGET_SPARC64
 target_ulong cpu_get_ccr(CPUSPARCState *env1);
 void cpu_put_ccr(CPUSPARCState *env1, target_ulong val);
target-sparc/win_helper.c +12 -7
index f01ae08..5b6d7b5 100644
@@ -64,23 +64,28 @@ target_ulong cpu_get_psr(CPUSPARCState *env)
 #endif
 }
 
-void cpu_put_psr(CPUSPARCState *env, target_ulong val)
+void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val)
 {
     env->psr = val & PSR_ICC;
 #if !defined(TARGET_SPARC64)
     env->psref = (val & PSR_EF) ? 1 : 0;
     env->psrpil = (val & PSR_PIL) >> 8;
-#endif
-#if ((!defined(TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
-    cpu_check_irqs(env);
-#endif
-#if !defined(TARGET_SPARC64)
     env->psrs = (val & PSR_S) ? 1 : 0;
     env->psrps = (val & PSR_PS) ? 1 : 0;
     env->psret = (val & PSR_ET) ? 1 : 0;
-    cpu_set_cwp(env, val & PSR_CWP);
 #endif
     env->cc_op = CC_OP_FLAGS;
+#if !defined(TARGET_SPARC64)
+    cpu_set_cwp(env, val & PSR_CWP);
+#endif
+}
+
+void cpu_put_psr(CPUSPARCState *env, target_ulong val)
+{
+    cpu_put_psr_raw(env, val);
+#if ((!defined(TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
+    cpu_check_irqs(env);
+#endif
 }
 
 int cpu_cwp_inc(CPUSPARCState *env, int cwp)
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/4 target-sparc: Don't flush TLB in cpu_load function

In reply to Peter Maydell

There's no need to flush the TLB in the SPARC cpu_load function: we're guaranteed to be loading state into a fresh clean configuration.

---
 target-sparc/machine.c | 1 -
 1 file changed, 1 deletion(-)
target-sparc/machine.c +0 -1
index 3f3de4c..7d03759 100644
@@ -213,6 +213,5 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_be64s(f, &env->ssr);
     cpu_get_timer(f, env->hstick);
 #endif
-    tlb_flush(CPU(cpu), 1);
     return 0;
 }
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/4 target-sparc: Convert to VMStateDescription

In reply to Peter Maydell

From: Juan Quintela <[email protected]>

Convert the SPARC CPU from cpu_load/save functions to VMStateDescription. Note that this is a migration compatibility break (which is OK as we don't try to support cross-version migration on SPARC).

[PMM:
* Rebase and update to apply to master
* Register via dc->vmsd
* VMSTATE_STRUCT_POINTER now takes type, not pointer-to-type
* QEMUTimer* are migrated via VMSTATE_TIMER_PTR
* Squash in another patch from Juan that arrayifies the state descriptions for immuregs, dmmuregs, itlb and dtlb, since we're going to break VM state compatibility anyway
* Put CPUTimer vmstate struct inside TARGET_SPARC64 ifdef
* Save the whole of env.regbase rather than having a complicated scheme for only saving the part we're using
* Convert handling of PSR to use a vmstate_psr, like Alpha and ARM
]

---
 hw/sparc64/sun4u.c     |  20 ---
 target-sparc/cpu-qom.h |   4 +
 target-sparc/cpu.c     |   1 +
 target-sparc/cpu.h     |   6 -
 target-sparc/machine.c | 359 ++++++++++++++++++++++---------------------------
 5 files changed, 167 insertions(+), 223 deletions(-)
hw/sparc64/sun4u.c +0 -20
index 30cfa0e..93dca10 100644
@@ -358,26 +358,6 @@ typedef struct ResetData {
     uint64_t prom_addr;
 } ResetData;
 
-void cpu_put_timer(QEMUFile *f, CPUTimer *s)
-{
-    qemu_put_be32s(f, &s->frequency);
-    qemu_put_be32s(f, &s->disabled);
-    qemu_put_be64s(f, &s->disabled_mask);
-    qemu_put_sbe64s(f, &s->clock_offset);
-
-    timer_put(f, s->qtimer);
-}
-
-void cpu_get_timer(QEMUFile *f, CPUTimer *s)
-{
-    qemu_get_be32s(f, &s->frequency);
-    qemu_get_be32s(f, &s->disabled);
-    qemu_get_be64s(f, &s->disabled_mask);
-    qemu_get_sbe64s(f, &s->clock_offset);
-
-    timer_get(f, s->qtimer);
-}
-
 static CPUTimer *cpu_timer_create(const char *name, SPARCCPU *cpu,
                                   QEMUBHFunc *cb, uint32_t frequency,
                                   uint64_t disabled_mask)
target-sparc/cpu-qom.h +4 -0
index 477c4d5..5096b10 100644
@@ -75,6 +75,10 @@ static inline SPARCCPU *sparc_env_get_cpu(CPUSPARCState *env)
 
 #define ENV_OFFSET offsetof(SPARCCPU, env)
 
+#ifndef CONFIG_USER_ONLY
+extern const struct VMStateDescription vmstate_sparc_cpu;
+#endif
+
 void sparc_cpu_do_interrupt(CPUState *cpu);
 void sparc_cpu_dump_state(CPUState *cpu, FILE *f,
                           fprintf_function cpu_fprintf, int flags);
target-sparc/cpu.c +1 -0
index 9528e3a..aea0a99 100644
@@ -847,6 +847,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)
     cc->do_unassigned_access = sparc_cpu_unassigned_access;
     cc->do_unaligned_access = sparc_cpu_do_unaligned_access;
     cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug;
+    dc->vmsd = &vmstate_sparc_cpu;
 #endif
 
 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
target-sparc/cpu.h +0 -6
index 9a4a010..bf4164e 100644
@@ -377,10 +377,6 @@ struct CPUTimer
 
 typedef struct CPUTimer CPUTimer;
 
-struct QEMUFile;
-void cpu_put_timer(struct QEMUFile *f, CPUTimer *s);
-void cpu_get_timer(struct QEMUFile *f, CPUTimer *s);
-
 typedef struct CPUSPARCState CPUSPARCState;
 
 struct CPUSPARCState {
@@ -603,8 +599,6 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list
 
-#define CPU_SAVE_VERSION 7
-
 /* MMU modes definitions */
 #if defined (TARGET_SPARC64)
 #define MMU_USER_IDX   0
target-sparc/machine.c +162 -197

376 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

Re: [Qemu-devel] [PATCH 4/4] target-sparc: Convert to VMStateDescription

target-sparc/machine.c line 15

Quoted 3 lines · Peter Maydell
target-sparc/machine.c +0 -3
-    // if env->cwp == env->nwindows - 1, this will set the ins of the last
-    // window as the outs of the first window
-    cpu_set_cwp(env, env->cwp);

Out of curiosity, what migrates env->cwp for SPARC64?

Paolo

#6 lore raw
In reply to Peter Maydell
Quoted 26 lines · Peter Maydell

This patchset updates target-sparc to use VMStateDescription rather than hand-written save/load functions. (This and CRIS are the last two targets still using the old approach.)

It's based on some patches from back in 2012 by Juan which I've updated, rebased and made some tweaks to.

This is a migration compatibility break; we don't care about cross-version migration on SPARC guests, and not having to maintain the old wire format allows a cleaner vmstate description in several ways.

NB that the 'split cpu_put_psr' patch seems to me to be a bugfix in and of itself, since currently we might try to call cpu_check_irqs() and deliver interrupts while we're halfway through updating a PSR value...

Juan Quintela (2):
vmstate: introduce CPU_DoubleU arrays
target-sparc: Convert to VMStateDescription

Peter Maydell (2):
target-sparc: Split cpu_put_psr into side-effect and no-side-effect
parts
target-sparc: Don't flush TLB in cpu_load function

Quoted 9 lines
 hw/sparc64/sun4u.c          |  20 ---
 include/migration/vmstate.h |   7 +
 migration/vmstate.c         |  23 +++
 target-sparc/cpu-qom.h      |   4 +
 target-sparc/cpu.c          |   1 +
 target-sparc/cpu.h          |   7 +-
 target-sparc/machine.c      | 360 ++++++++++++++++++++------------------------
 target-sparc/win_helper.c   |  19 ++-
 8 files changed, 210 insertions(+), 231 deletions(-)

Hi Peter,

Thanks for looking into this! In general the patches look very reasonable (although I will need to give them a more thorough testing when I get a chance) - my only concern is the break in migration compatibility. Am I right in thinking that with this patch applied a loadvm cannot restore a savevm from an earlier version?

Not so much for qemu-system-sparc64 which is still somewhat experimental, however qemu-system-sparc has become very usable since 2012 with the advent of the cg3 and OpenBIOS changes that can now run Solaris/SunOS and I do have a slight concern that people could lose their qcow2 snapshots. Then again if we document this loudly in the release notes then I guess it is possible to convert a snapshot back to a raw, boot that and then savevm it back to the newer qcow2 again...

ATB,

Mark.

#7 lore raw
Quoted 14 lines · Mark Cave-Ayland
Quoted 11 lines · Peter Maydell

This patchset updates target-sparc to use VMStateDescription rather than hand-written save/load functions. (This and CRIS are the last two targets still using the old approach.)

It's based on some patches from back in 2012 by Juan which I've updated, rebased and made some tweaks to.

This is a migration compatibility break; we don't care about cross-version migration on SPARC guests, and not having to maintain the old wire format allows a cleaner vmstate description in several ways.

Quoted 5 lines

Thanks for looking into this! In general the patches look very reasonable (although I will need to give them a more thorough testing when I get a chance) - my only concern is the break in migration compatibility. Am I right in thinking that with this patch applied a loadvm cannot restore a savevm from an earlier version?

Yep, that's what cross-version breaks imply.

Quoted 7 lines

Not so much for qemu-system-sparc64 which is still somewhat experimental, however qemu-system-sparc has become very usable since 2012 with the advent of the cg3 and OpenBIOS changes that can now run Solaris/SunOS and I do have a slight concern that people could lose their qcow2 snapshots. Then again if we document this loudly in the release notes then I guess it is possible to convert a snapshot back to a raw, boot that and then savevm it back to the newer qcow2 again...

If there's a migration break, then the old vm-snapshot is useless. You can load it on the old QEMU, obviously, but the new one will never run it. The best you can do is load the VM on the old QEMU and do a clean shutdown of it. Then you can do a cold boot on the new QEMU.

(Note that QEMU has several meanings of 'snapshot'; the one I have in mind here is the complete-saved-state-of-disk-and-VM you get via savevm. Snapshots which are just saved-state-of-disk are fine.)

Anyway, my assumption was that nobody cared much about migration compatibility for sparc (nobody has *ever* to my knowledge complained about compat breaks for ARM targets, which we've done fairly regularly over the last few years). They're very hard to keep working reliably, because you pretty much have to start defining per-version machines (like all the pc-i440fx-2.4, pc-i440fx-2.3, etc) so that each new version of QEMU can still produce a machine that is exactly like the one the previous ones did, and you need to test to make sure you haven't accidentally broken migration between versions. So mostly we've only cared for targets where there's serious usage as a VM target (x86, ppc, s390 more recently). (If you've never tested 'savevm on qemu 2.3 and loadvm on 2.4" then I'd probably put even odds on it being at least subtly broken.)

But this is in the end a target maintainer choice, so if you really want to maintain cross-version compat I can do that. The downside is that you end up with either (a) a really ugly vmstate because it has to maintain unnatural field orders or on-the-wire state or (b) a bunch of code that's only exercised on migration from older QEMU. I think the most awkward part here is that the old wire format wants to send the ITLB and DTLB structures interleaved, which means you can't just define them as being arrays of structs. Juan's original 2012 patchset actually did the conversion as a compatible change followed by a breaking change -- this is the patch which does the breaking-change:
http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03818.html
The diffstat is "9 insertions(+), 163 deletions(-)"...

Let me know what you'd prefer here.

thanks
-- PMM

#8 lore raw
In reply to Mark Cave-Ayland

Hi Mark,

Quoted 46 lines · Mark Cave-Ayland
Quoted 26 lines · Peter Maydell

This patchset updates target-sparc to use VMStateDescription rather than hand-written save/load functions. (This and CRIS are the last two targets still using the old approach.)

It's based on some patches from back in 2012 by Juan which I've updated, rebased and made some tweaks to.

This is a migration compatibility break; we don't care about cross-version migration on SPARC guests, and not having to maintain the old wire format allows a cleaner vmstate description in several ways.

NB that the 'split cpu_put_psr' patch seems to me to be a bugfix in and of itself, since currently we might try to call cpu_check_irqs() and deliver interrupts while we're halfway through updating a PSR value...

Juan Quintela (2):
vmstate: introduce CPU_DoubleU arrays
target-sparc: Convert to VMStateDescription

Peter Maydell (2):
target-sparc: Split cpu_put_psr into side-effect and no-side-effect
parts
target-sparc: Don't flush TLB in cpu_load function

Quoted 9 lines
 hw/sparc64/sun4u.c          |  20 ---
 include/migration/vmstate.h |   7 +
 migration/vmstate.c         |  23 +++
 target-sparc/cpu-qom.h      |   4 +
 target-sparc/cpu.c          |   1 +
 target-sparc/cpu.h          |   7 +-
 target-sparc/machine.c      | 360 ++++++++++++++++++++------------------------
 target-sparc/win_helper.c   |  19 ++-
 8 files changed, 210 insertions(+), 231 deletions(-)

Hi Peter,

Thanks for looking into this! In general the patches look very reasonable (although I will need to give them a more thorough testing when I get a chance) - my only concern is the break in migration compatibility. Am I right in thinking that with this patch applied a loadvm cannot restore a savevm from an earlier version?

Quoted 7 lines

Not so much for qemu-system-sparc64 which is still somewhat experimental, however qemu-system-sparc has become very usable since 2012 with the advent of the cg3 and OpenBIOS changes that can now run Solaris/SunOS and I do have a slight concern that people could lose their qcow2 snapshots. Then again if we document this loudly in the release notes then I guess it is possible to convert a snapshot back to a raw, boot that and then savevm it back to the newer qcow2 again...

I think you and Peter speak about different snapshots. The filesystem snapshots are not affected with this series, so no need to convert qcow2 back and force.
What would be broken is the live system snapshot - it won't be possible to live migrate from one QEMU version to another one without rebooting the guest.
But I guess a reboot for a QEMU upgrade is not too expensive for our current users.

ATB,
Artyom

Signature · 4 lines
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
#9 lore raw

On 14/08/15 13:15, Artyom Tarasenko wrote:

Hi Artyom,

Quoted 58 lines

Hi Mark,

Quoted 46 lines · Mark Cave-Ayland
Quoted 26 lines · Peter Maydell

This patchset updates target-sparc to use VMStateDescription rather than hand-written save/load functions. (This and CRIS are the last two targets still using the old approach.)

It's based on some patches from back in 2012 by Juan which I've updated, rebased and made some tweaks to.

This is a migration compatibility break; we don't care about cross-version migration on SPARC guests, and not having to maintain the old wire format allows a cleaner vmstate description in several ways.

NB that the 'split cpu_put_psr' patch seems to me to be a bugfix in and of itself, since currently we might try to call cpu_check_irqs() and deliver interrupts while we're halfway through updating a PSR value...

Juan Quintela (2):
vmstate: introduce CPU_DoubleU arrays
target-sparc: Convert to VMStateDescription

Peter Maydell (2):
target-sparc: Split cpu_put_psr into side-effect and no-side-effect
parts
target-sparc: Don't flush TLB in cpu_load function

Quoted 9 lines
 hw/sparc64/sun4u.c          |  20 ---
 include/migration/vmstate.h |   7 +
 migration/vmstate.c         |  23 +++
 target-sparc/cpu-qom.h      |   4 +
 target-sparc/cpu.c          |   1 +
 target-sparc/cpu.h          |   7 +-
 target-sparc/machine.c      | 360 ++++++++++++++++++++------------------------
 target-sparc/win_helper.c   |  19 ++-
 8 files changed, 210 insertions(+), 231 deletions(-)

Hi Peter,

Thanks for looking into this! In general the patches look very reasonable (although I will need to give them a more thorough testing when I get a chance) - my only concern is the break in migration compatibility. Am I right in thinking that with this patch applied a loadvm cannot restore a savevm from an earlier version?

Quoted 7 lines

Not so much for qemu-system-sparc64 which is still somewhat experimental, however qemu-system-sparc has become very usable since 2012 with the advent of the cg3 and OpenBIOS changes that can now run Solaris/SunOS and I do have a slight concern that people could lose their qcow2 snapshots. Then again if we document this loudly in the release notes then I guess it is possible to convert a snapshot back to a raw, boot that and then savevm it back to the newer qcow2 again...

Quoted 8 lines

I think you and Peter speak about different snapshots. The filesystem snapshots are not affected with this series, so no need to convert qcow2 back and force.
What would be broken is the live system snapshot - it won't be possible to live migrate from one QEMU version to another one without rebooting the guest.
But I guess a reboot for a QEMU upgrade is not too expensive for our current users.

Let me try and clarify myself a bit more here - I do have some test snapshots with qcow2 images created with "savevm" which also saves the complete machine state alongside the disk image snapshot to enable me to jump straight to a specific point in time.

I was wondering if it would be possible to "loadvm" a machine state from a snapshot running under the old QEMU version so that the image can be shutdown correctly and then bring up just the qcow2 filesystem snapshot in the new QEMU version, at which point I can get the VM to a similar point and then "savevm" again to get back to where I was. If that is the case then I'm okay with the changes as long as we note this in the release notes (so I'm also fine with requiring a reboot after the upgrade).

ATB,

Mark.

#10 lore raw

Hi Mark,

Quoted 76 lines · Mark Cave-Ayland

On 14/08/15 13:15, Artyom Tarasenko wrote:

Hi Artyom,

Quoted 58 lines

Hi Mark,

Quoted 46 lines · Mark Cave-Ayland
Quoted 26 lines · Peter Maydell

This patchset updates target-sparc to use VMStateDescription rather than hand-written save/load functions. (This and CRIS are the last two targets still using the old approach.)

It's based on some patches from back in 2012 by Juan which I've updated, rebased and made some tweaks to.

This is a migration compatibility break; we don't care about cross-version migration on SPARC guests, and not having to maintain the old wire format allows a cleaner vmstate description in several ways.

NB that the 'split cpu_put_psr' patch seems to me to be a bugfix in and of itself, since currently we might try to call cpu_check_irqs() and deliver interrupts while we're halfway through updating a PSR value...

Juan Quintela (2):
vmstate: introduce CPU_DoubleU arrays
target-sparc: Convert to VMStateDescription

Peter Maydell (2):
target-sparc: Split cpu_put_psr into side-effect and no-side-effect
parts
target-sparc: Don't flush TLB in cpu_load function

Quoted 9 lines
 hw/sparc64/sun4u.c          |  20 ---
 include/migration/vmstate.h |   7 +
 migration/vmstate.c         |  23 +++
 target-sparc/cpu-qom.h      |   4 +
 target-sparc/cpu.c          |   1 +
 target-sparc/cpu.h          |   7 +-
 target-sparc/machine.c      | 360 ++++++++++++++++++++------------------------
 target-sparc/win_helper.c   |  19 ++-
 8 files changed, 210 insertions(+), 231 deletions(-)

Hi Peter,

Thanks for looking into this! In general the patches look very reasonable (although I will need to give them a more thorough testing when I get a chance) - my only concern is the break in migration compatibility. Am I right in thinking that with this patch applied a loadvm cannot restore a savevm from an earlier version?

Quoted 7 lines

Not so much for qemu-system-sparc64 which is still somewhat experimental, however qemu-system-sparc has become very usable since 2012 with the advent of the cg3 and OpenBIOS changes that can now run Solaris/SunOS and I do have a slight concern that people could lose their qcow2 snapshots. Then again if we document this loudly in the release notes then I guess it is possible to convert a snapshot back to a raw, boot that and then savevm it back to the newer qcow2 again...

Quoted 8 lines

I think you and Peter speak about different snapshots. The filesystem snapshots are not affected with this series, so no need to convert qcow2 back and force.
What would be broken is the live system snapshot - it won't be possible to live migrate from one QEMU version to another one without rebooting the guest.
But I guess a reboot for a QEMU upgrade is not too expensive for our current users.

Let me try and clarify myself a bit more here - I do have some test snapshots with qcow2 images created with "savevm" which also saves the complete machine state alongside the disk image snapshot to enable me to jump straight to a specific point in time.

Quoted 7 lines

I was wondering if it would be possible to "loadvm" a machine state from a snapshot running under the old QEMU version so that the image can be shutdown correctly and then bring up just the qcow2 filesystem snapshot in the new QEMU version, at which point I can get the VM to a similar point and then "savevm" again to get back to where I was. If that is the case then I'm okay with the changes as long as we note this in the release notes (so I'm also fine with requiring a reboot after the upgrade).

I haven't tested this patch set, but yes, you describe exaclty the sequence which should work for the migration.

Artyom

Signature · 4 lines
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu