[5475] Introduce a buffered file wrapper for QEMUFile
Revision: 5475
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5475 Author: aliguori Date: 2008-10-13 03:10:22 +0000 (Mon, 13 Oct 2008)
Log Message:
-----------
Introduce a buffered file wrapper for QEMUFile
This patch introduces a buffered QEMUFile wrapper. This allows QEMUFile's to be rate limited. It also makes it easier to implement a QEMUFile that is asynchronous since the current QEMUFile API requires that all reads and writes be synchronous.
The only real non-obvious part of the API is the "frozen" concept. If the backend returns EAGAIN, the QEMUFile is said to be "frozen". This means no additional output will be sent to the backend until the file is unfrozen. qemu_file_put_notify can be used to unfreeze a frozen file.
A synchronous interface is also provided to wait for an unfreeze event. This is used during the final part of live migration when the VM is no longer running.
Modified Paths:
--------------
trunk/Makefile.target
Added Paths:
-----------
trunk/buffered_file.c
trunk/buffered_file.h
Modified: trunk/Makefile.target
===================================================================
Makefile.target +1 -1
@@ -474,7 +474,7 @@ ifndef CONFIG_USER_ONLY OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o net-checksum.o -OBJS+=fw_cfg.o aio.o +OBJS+=fw_cfg.o aio.o buffered_file.o ifdef CONFIG_WIN32 OBJS+=block-raw-win32.o else
Added: trunk/buffered_file.c
===================================================================
buffered_file.c +250 -0
250 lines not on this page · raw message
Added: trunk/buffered_file.h
===================================================================
buffered_file.h +30 -0
@@ -0,0 +1,30 @@ +/* +* QEMU buffered QEMUFile +* +* Copyright IBM, Corp. 2008 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +* +*/ + +#ifndef QEMU_BUFFERED_FILE_H +#define QEMU_BUFFERED_FILE_H + +#include "hw/hw.h" + +typedef ssize_t (BufferedPutFunc )(void *opaque,const void *data,size_t size); +typedef void (BufferedPutReadyFunc )(void *opaque); +typedef void (BufferedWaitForUnfreezeFunc )(void *opaque); +typedef int (BufferedCloseFunc )(void *opaque); + +QEMUFile *qemu_fopen_ops_buffered (void *opaque,size_t xfer_limit, +BufferedPutFunc *put_buffer, +BufferedPutReadyFunc *put_ready, +BufferedWaitForUnfreezeFunc *wait_for_unfreeze, +BufferedCloseFunc *close); + +#endif