summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlvivier@redhat.com <lvivier@redhat.com>2016-07-21 14:05:46 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2016-07-25 10:19:30 +1000
commitcf472f48d57a533cc46ee651159abcbe0b362df0 (patch)
treefbb54f4b49b1c4ad5ecea8120ebd612894b6da6c
parentc573fc03da65e35bf44bce0448ea12801e3631ac (diff)
spapr: fix spapr-nvram migration
When spapr-nvram is backed by a file using pflash interface, migration fails on the destination guest with assert: bdrv_co_pwritev: Assertion `!(bs->open_flags & 0x0800)' failed. This avoids the problem by delaying the pflash update until after the device loads complete. This fix is similar to the one for the pflash_cfi01 migration: 90c647d Fix pflash migration Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--hw/nvram/spapr_nvram.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
index 019f25dc58..4de5f705d8 100644
--- a/hw/nvram/spapr_nvram.c
+++ b/hw/nvram/spapr_nvram.c
@@ -39,6 +39,7 @@ typedef struct sPAPRNVRAM {
uint32_t size;
uint8_t *buf;
BlockBackend *blk;
+ VMChangeStateEntry *vmstate;
} sPAPRNVRAM;
#define TYPE_VIO_SPAPR_NVRAM "spapr-nvram"
@@ -185,19 +186,25 @@ static int spapr_nvram_pre_load(void *opaque)
return 0;
}
+static void postload_update_cb(void *opaque, int running, RunState state)
+{
+ sPAPRNVRAM *nvram = opaque;
+
+ /* This is called after bdrv_invalidate_cache_all. */
+
+ qemu_del_vm_change_state_handler(nvram->vmstate);
+ nvram->vmstate = NULL;
+
+ blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0);
+}
+
static int spapr_nvram_post_load(void *opaque, int version_id)
{
sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(opaque);
if (nvram->blk) {
- int alen = blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0);
-
- if (alen < 0) {
- return alen;
- }
- if (alen != nvram->size) {
- return -1;
- }
+ nvram->vmstate = qemu_add_vm_change_state_handler(postload_update_cb,
+ nvram);
}
return 0;