vmstate: Add preallocation for migrating arrays (VMS_ALLOC flag)
commitf32935ea2284fe833fdf4a0d6b2fe423fc08a1b2
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Fri, 30 May 2014 09:34:19 +0000 (30 19:34 +1000)
committerAlexander Graf <agraf@suse.de>
Fri, 27 Jun 2014 11:48:27 +0000 (27 13:48 +0200)
tree99d8fb3de1e432a07aef1e48ff26cc3bc3eb15d6
parent51bba713fe1120ba7b0542216278f10e48349589
vmstate: Add preallocation for migrating arrays (VMS_ALLOC flag)

There are few helpers already to support array migration. However they all
require the destination side to preallocate arrays before migration which
is not always possible due to unknown array size as it might be some
sort of dynamic state. One of the examples is an array of MSIX-enabled
devices in SPAPR PHB - this array may vary from 0 to 65536 entries and
its size depends on guest's ability to enable MSIX or do PCI hotplug.

This adds new VMSTATE_VARRAY_STRUCT_ALLOC macro which is pretty similar to
VMSTATE_STRUCT_VARRAY_POINTER_INT32 but it can alloc memory for migratign
array on the destination side.

This defines VMS_ALLOC flag for a field.

This changes vmstate_base_addr() to do the allocation when receiving
migration.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[agraf: drop g_malloc_n usage]
Signed-off-by: Alexander Graf <agraf@suse.de>
include/migration/vmstate.h
vmstate.c