Memory: Only call ramblock_ptr when needed in qemu_ram_writeback
It is possible that a ramblock doesn't have memory that QEMU can access, this is the case with the Xen hypervisor. In order to avoid to trigger an assert, only call ramblock_ptr() when needed in qemu_ram_writeback(). This should fix migration of Xen guests that was broken with bd108a44bc29 ("migration: ram: Switch to ram block writeback"). Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20191219154323.325255-1-anthony.perard@citrix.com>
This commit is contained in:
parent
32d0b7be68
commit
5d4c954931
4
exec.c
4
exec.c
@ -2116,14 +2116,13 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
|
|||||||
*/
|
*/
|
||||||
void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
|
void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
|
||||||
{
|
{
|
||||||
void *addr = ramblock_ptr(block, start);
|
|
||||||
|
|
||||||
/* The requested range should fit in within the block range */
|
/* The requested range should fit in within the block range */
|
||||||
g_assert((start + length) <= block->used_length);
|
g_assert((start + length) <= block->used_length);
|
||||||
|
|
||||||
#ifdef CONFIG_LIBPMEM
|
#ifdef CONFIG_LIBPMEM
|
||||||
/* The lack of support for pmem should not block the sync */
|
/* The lack of support for pmem should not block the sync */
|
||||||
if (ramblock_is_pmem(block)) {
|
if (ramblock_is_pmem(block)) {
|
||||||
|
void *addr = ramblock_ptr(block, start);
|
||||||
pmem_persist(addr, length);
|
pmem_persist(addr, length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2134,6 +2133,7 @@ void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
|
|||||||
* specified as persistent (or is not one) - use the msync.
|
* specified as persistent (or is not one) - use the msync.
|
||||||
* Less optimal but still achieves the same goal
|
* Less optimal but still achieves the same goal
|
||||||
*/
|
*/
|
||||||
|
void *addr = ramblock_ptr(block, start);
|
||||||
if (qemu_msync(addr, length, block->fd)) {
|
if (qemu_msync(addr, length, block->fd)) {
|
||||||
warn_report("%s: failed to sync memory range: start: "
|
warn_report("%s: failed to sync memory range: start: "
|
||||||
RAM_ADDR_FMT " length: " RAM_ADDR_FMT,
|
RAM_ADDR_FMT " length: " RAM_ADDR_FMT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user