57359f7
From cc96677469388bad3d66479379735cf75db069e3 Mon Sep 17 00:00:00 2001
57359f7
From: Paolo Bonzini <pbonzini@redhat.com>
57359f7
Date: Mon, 20 Jun 2016 16:32:39 +0200
57359f7
Subject: [PATCH] scsi: esp: fix migration
57359f7
57359f7
Commit 926cde5 ("scsi: esp: make cmdbuf big enough for maximum CDB size",
57359f7
2016-06-16) changed the size of a migrated field.  Split it in two
57359f7
parts, and only migrate the second part in a new vmstate version.
57359f7
57359f7
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
57359f7
---
57359f7
 hw/scsi/esp.c               |    5 +++--
57359f7
 include/migration/vmstate.h |    5 ++++-
57359f7
 2 files changed, 7 insertions(+), 3 deletions(-)
57359f7
57359f7
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
57359f7
index baa0a2c..1f2f2d3 100644
57359f7
--- a/hw/scsi/esp.c
57359f7
+++ b/hw/scsi/esp.c
57359f7
@@ -574,7 +574,7 @@ static bool esp_mem_accepts(void *opaque, hwaddr addr,
57359f7
 
57359f7
 const VMStateDescription vmstate_esp = {
57359f7
     .name ="esp",
57359f7
-    .version_id = 3,
57359f7
+    .version_id = 4,
57359f7
     .minimum_version_id = 3,
57359f7
     .fields = (VMStateField[]) {
57359f7
         VMSTATE_BUFFER(rregs, ESPState),
57359f7
@@ -585,7 +585,8 @@ const VMStateDescription vmstate_esp = {
57359f7
         VMSTATE_BUFFER(ti_buf, ESPState),
57359f7
         VMSTATE_UINT32(status, ESPState),
57359f7
         VMSTATE_UINT32(dma, ESPState),
57359f7
-        VMSTATE_BUFFER(cmdbuf, ESPState),
57359f7
+        VMSTATE_PARTIAL_BUFFER(cmdbuf, ESPState, 16),
57359f7
+        VMSTATE_BUFFER_START_MIDDLE_V(cmdbuf, ESPState, 16, 4),
57359f7
         VMSTATE_UINT32(cmdlen, ESPState),
57359f7
         VMSTATE_UINT32(do_cmd, ESPState),
57359f7
         VMSTATE_UINT32(dma_left, ESPState),
57359f7
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
57359f7
index 25ea58a..15ea767 100644
57359f7
--- a/include/migration/vmstate.h
57359f7
+++ b/include/migration/vmstate.h
57359f7
@@ -904,8 +904,11 @@ extern const VMStateInfo vmstate_info_bitmap;
57359f7
 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size)                         \
57359f7
     VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
57359f7
 
57359f7
+#define VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, _v) \
57359f7
+    VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, _start, sizeof(typeof_field(_s, _f)))
57359f7
+
57359f7
 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
57359f7
-    VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
57359f7
+    VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, 0)
57359f7
 
57359f7
 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size)                        \
57359f7
     VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size)
57359f7
-- 
57359f7
1.7.0.4
57359f7