exec: Only count mapped memory backends for qemu_getrampagesize()
commit7d5489e6d15e2922e45a41e4808d03a48457a5ee
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 26 Mar 2019 03:33:33 +0000 (26 14:33 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Fri, 29 Mar 2019 03:24:08 +0000 (29 14:24 +1100)
treebfa1414f87fcf10a412f015bb4544e4dfcdf71aa
parent273fef83f6c669f76fe25f419502ed123dfe15d2
exec: Only count mapped memory backends for qemu_getrampagesize()

qemu_getrampagesize() works out the minimum host page size backing any of
guest RAM.  This is required in a few places, such as for POWER8 PAPR KVM
guests, because limitations of the hardware virtualization mean the guest
can't use pagesizes larger than the host pages backing its memory.

However, it currently checks against *every* memory backend, whether or not
it is actually mapped into guest memory at the moment.  This is incorrect.

This can cause a problem attempting to add memory to a POWER8 pseries KVM
guest which is configured to allow hugepages in the guest (e.g.
-machine cap-hpt-max-page-size=16m).  If you attempt to add non-hugepage,
you can (correctly) create a memory backend, however it (correctly) will
throw an error when you attempt to map that memory into the guest by
'device_add'ing a pc-dimm.

What's not correct is that if you then reset the guest a startup check
against qemu_getrampagesize() will cause a fatal error because of the new
memory object, even though it's not mapped into the guest.

This patch corrects the problem by adjusting find_max_supported_pagesize()
(called from qemu_getrampagesize() via object_child_foreach) to exclude
non-mapped memory backends.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: David Hildenbrand <david@redhat.com>
exec.c