aboutsummaryrefslogtreecommitdiff
path: root/vmstate.c
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2014-10-02 19:56:02 +1000
committerJuan Quintela <quintela@trasno.org>2014-10-14 09:35:48 +0200
commit94ed706d53a9018f24c67374c71f358fca2f0413 (patch)
treec152b50ee203d0f6cf9a52b7b65054490f0deeda /vmstate.c
parent7ea2d269cb84ca7a2f4b7c3735634176f7c1dc35 (diff)
downloadqemu-94ed706d53a9018f24c67374c71f358fca2f0413.zip
qemu-94ed706d53a9018f24c67374c71f358fca2f0413.tar.gz
qemu-94ed706d53a9018f24c67374c71f358fca2f0413.tar.bz2
vmstate: Allow dynamic allocation for VBUFFER during migration
This extends use of VMS_ALLOC flag from arrays to VBUFFER as well. This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of VMS_ALLOC and uses uint32_t type for a size. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'vmstate.c')
-rw-r--r--vmstate.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/vmstate.c b/vmstate.c
index ef2f87b..3dde574 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -49,9 +49,16 @@ static void *vmstate_base_addr(void *opaque, VMStateField *field, bool alloc)
if (field->flags & VMS_POINTER) {
if (alloc && (field->flags & VMS_ALLOC)) {
- int n_elems = vmstate_n_elems(opaque, field);
- if (n_elems) {
- gsize size = n_elems * field->size;
+ gsize size = 0;
+ if (field->flags & VMS_VBUFFER) {
+ size = vmstate_size(opaque, field);
+ } else {
+ int n_elems = vmstate_n_elems(opaque, field);
+ if (n_elems) {
+ size = n_elems * field->size;
+ }
+ }
+ if (size) {
*((void **)base_addr + field->start) = g_malloc(size);
}
}