Commit 05fcc848 authored by Kevin Wolf's avatar Kevin Wolf Committed by Stefan Hajnoczi
Browse files

savevm: Implement block_writev_buffer()



Instead of breaking up RAM state into many small chunks, pass the iovec
to the block layer for better performance.
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent cf8074b3
...@@ -55,7 +55,7 @@ typedef int (QEMUFileGetFD)(void *opaque); ...@@ -55,7 +55,7 @@ typedef int (QEMUFileGetFD)(void *opaque);
* This function writes an iovec to file. * This function writes an iovec to file.
*/ */
typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov, typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov,
int iovcnt); int iovcnt, int64_t pos);
typedef struct QEMUFileOps { typedef struct QEMUFileOps {
QEMUFilePutBufferFunc *put_buffer; QEMUFilePutBufferFunc *put_buffer;
......
...@@ -176,7 +176,8 @@ static void coroutine_fn yield_until_fd_readable(int fd) ...@@ -176,7 +176,8 @@ static void coroutine_fn yield_until_fd_readable(int fd)
qemu_coroutine_yield(); qemu_coroutine_yield();
} }
static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt) static ssize_t socket_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
int64_t pos)
{ {
QEMUFileSocket *s = opaque; QEMUFileSocket *s = opaque;
ssize_t len; ssize_t len;
...@@ -458,6 +459,21 @@ fail: ...@@ -458,6 +459,21 @@ fail:
return NULL; return NULL;
} }
static ssize_t block_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
int64_t pos)
{
int ret;
QEMUIOVector qiov;
qemu_iovec_init_external(&qiov, iov, iovcnt);
ret = bdrv_writev_vmstate(opaque, &qiov, pos);
if (ret < 0) {
return ret;
}
return qiov.size;
}
static int block_put_buffer(void *opaque, const uint8_t *buf, static int block_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size) int64_t pos, int size)
{ {
...@@ -481,8 +497,9 @@ static const QEMUFileOps bdrv_read_ops = { ...@@ -481,8 +497,9 @@ static const QEMUFileOps bdrv_read_ops = {
}; };
static const QEMUFileOps bdrv_write_ops = { static const QEMUFileOps bdrv_write_ops = {
.put_buffer = block_put_buffer, .put_buffer = block_put_buffer,
.close = bdrv_fclose .writev_buffer = block_writev_buffer,
.close = bdrv_fclose
}; };
static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable) static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
...@@ -533,7 +550,7 @@ static void qemu_fflush(QEMUFile *f) ...@@ -533,7 +550,7 @@ static void qemu_fflush(QEMUFile *f)
if (f->is_write && f->iovcnt > 0) { if (f->is_write && f->iovcnt > 0) {
if (f->ops->writev_buffer) { if (f->ops->writev_buffer) {
ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt); ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos);
if (ret >= 0) { if (ret >= 0) {
f->pos += ret; f->pos += ret;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment