[Virtio-fs] [PATCH v2 3/4] vhost: Add high-level state save/load functions
Hanna Czenczek
hreitz at redhat.com
Fri Jul 21 16:09:13 UTC 2023
On 21.07.23 17:18, Eugenio Perez Martin wrote:
> On Wed, Jul 12, 2023 at 1:17 PM Hanna Czenczek <hreitz at redhat.com> wrote:
>> vhost_save_backend_state() and vhost_load_backend_state() can be used by
>> vhost front-ends to easily save and load the back-end's state to/from
>> the migration stream.
>>
>> Because we do not know the full state size ahead of time,
>> vhost_save_backend_state() simply reads the data in 1 MB chunks, and
>> writes each chunk consecutively into the migration stream, prefixed by
>> its length. EOF is indicated by a 0-length chunk.
>>
>> Signed-off-by: Hanna Czenczek <hreitz at redhat.com>
>> ---
>> include/hw/virtio/vhost.h | 35 +++++++
>> hw/virtio/vhost.c | 204 ++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 239 insertions(+)
[...]
>> +int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **errp)
>> +{
>> + size_t transfer_buf_size = 0;
>> + void *transfer_buf = NULL;
>> + g_autoptr(GError) g_err = NULL;
>> + int pipe_fds[2], read_fd = -1, write_fd = -1, reply_fd = -1;
>> + int ret;
[...]
>> + ret = 0;
>> +fail:
>> + g_free(transfer_buf);
> Nitpick, but transfer_buf could have the g_autofree parameter.
Ah, sure, thanks!
Hanna
More information about the Virtio-fs
mailing list