提交 cf472f48 编写于 作者: L lvivier@redhat.com 提交者: David Gibson

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:

    90c647db Fix pflash migration
Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
上级 c573fc03
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册