diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2015-11-05 18:10:35 +0000 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2015-11-10 14:51:48 +0100 |
commit | 9504fb510c87c3dd6fe2e9a25e84c1426672f226 (patch) | |
tree | f6fa039d3c9411ccaadf729104e9e79a2d84756d /include/migration/qemu-file.h | |
parent | 42e2aa56372291d35345fcec85d5da2004c8b57c (diff) |
Add qemu_get_buffer_in_place to avoid copies some of the time
qemu_get_buffer always copies the data it reads to a users buffer,
however in many cases the file buffer inside qemu_file could be given
back to the caller, avoiding the copy. This isn't always possible
depending on the size and alignment of the data.
Thus 'qemu_get_buffer_in_place' either copies the data to a supplied
buffer or updates a pointer to the internal buffer if convenient.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'include/migration/qemu-file.h')
-rw-r--r-- | include/migration/qemu-file.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 29a338d0a9..86bb9729d8 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -163,9 +163,11 @@ void qemu_put_be32(QEMUFile *f, unsigned int v); void qemu_put_be64(QEMUFile *f, uint64_t v); size_t qemu_peek_buffer(QEMUFile *f, uint8_t **buf, size_t size, size_t offset); size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size); +size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size); ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size, int level); int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src); + /* * Note that you can only peek continuous bytes from where the current pointer * is; you aren't guaranteed to be able to peak to +n bytes unless you've |