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