[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] vmstate: Add VMSTATE_OPAQUE to save/load comple
From: |
Roman Kiryanov |
Subject: |
Re: [Qemu-devel] [PATCH] vmstate: Add VMSTATE_OPAQUE to save/load complex data structures |
Date: |
Thu, 23 May 2019 10:00:44 -0700 |
Hi Dave, thank you for looking.
> Can you give me an example of where you would use it?
We use it in our host memory sharing device. I used the existing
macros for all fields I could, but unfortunately some state does not fit
into them. We use this new macro to save/load memory
allocators (for now we have malloc, but we are working on adding
Vulkan calls). For now the state looks this way:
class Allocator;
unordered_map<int, Allocator *> state;
class MallocAllocator: public Allocator {
unordered_map<int, vector<char>> state;
};
class VulkanAllocator: public Allocator {
// TBD
};
> I've been trying to get rid as many of the open-coded cases as possible
I saw this in the migration document. I used VMSTATE_INT32,
VMSTATE_STRUCT and VMSTATE_STRUCT_VARRAY_ALLOC
where I could.
> Having said that; would it be easier to pass the get/put functions
> rather than the info ?
Sure, function pointer will be even better, but since VMStateField
takes "const VMStateInfo *", I added this way.
Regards,
Roman.