qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] virtio-mem: Handle preallocation with migration
@ 2022-01-25 13:57 David Hildenbrand
  2022-01-25 13:57 ` [PATCH v2 1/2] virtio-mem: Fail if a memory backend with "prealloc=on" is specified David Hildenbrand
  2022-01-25 13:57 ` [PATCH v2 2/2] virtio-mem: Handle preallocation with migration David Hildenbrand
  0 siblings, 2 replies; 4+ messages in thread
From: David Hildenbrand @ 2022-01-25 13:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michal Privoznik, Juan Quintela, Michael S . Tsirkin,
	Dr . David Alan Gilbert, David Hildenbrand

While playing with migration of virtio-mem with an ordinary file backing,
I realized that migration and prealloc doesn't currently work as expected
for virtio-mem, especially when migrating zeropages or skipping migration
of some pages.

In contrast to ordinary memory backend preallocation, virtio-mem
preallocates memory before plugging blocks to the guest. Consequently,
when migrating we are not actually preallocating on the destination but
"only" migrate pages. When migrating the zeropage, we might not end up
allocating actual backend memory.

Postcopy needs some extra care, and I realized that prealloc+postcopy is
shaky in general. Let's at least try to mimic what ordinary
prealloc+postcopy does: temporarily allocate the memory, discard it, and
cross fingers that we'll still have sufficient memory when postcopy
actually tries placing pages.

For postcopy to work with prealloc=on, we need a matching "requested-size"
on source and destination, meaning we have to start QEMU on the destination
with the current "requested-size" on the source. Only that way, we can try
temporarily allocating the "requested-size" to see if there is a
fundamental issue. If we detect a mismatch, we don't start postcopy.

Cc: Juan Quintela <quintela@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Michal Privoznik <mprivozn@redhat.com>

v1 -> v2:
- Added RBs and Tested-bys
- "virtio-mem: Fail if a memory backend with "prealloc=on" is specified"
-- Fail instead of warn
-- Adjust subject/description

David Hildenbrand (2):
  virtio-mem: Fail if a memory backend with "prealloc=on" is specified
  virtio-mem: Handle preallocation with migration

 hw/virtio/virtio-mem.c         | 142 +++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-mem.h |   6 ++
 2 files changed, 148 insertions(+)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-31 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-25 13:57 [PATCH v2 0/2] virtio-mem: Handle preallocation with migration David Hildenbrand
2022-01-25 13:57 ` [PATCH v2 1/2] virtio-mem: Fail if a memory backend with "prealloc=on" is specified David Hildenbrand
2022-01-25 13:57 ` [PATCH v2 2/2] virtio-mem: Handle preallocation with migration David Hildenbrand
2022-01-31 10:40   ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).