summaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@redhat.com>2009-05-20 18:26:57 -0400
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-22 10:50:30 -0500
commitc908616148fab1c24a2a6b2f99b5b3ba160069f7 (patch)
treec07d954bd6c75d60ea5a036187f94c3b5d624679 /savevm.c
parent8279ceb16fdc336b025e496ccd6d64280775438e (diff)
downloadqemu-c908616148fab1c24a2a6b2f99b5b3ba160069f7.tar.gz
qemu-c908616148fab1c24a2a6b2f99b5b3ba160069f7.tar.bz2
qemu-c908616148fab1c24a2a6b2f99b5b3ba160069f7.zip
introduce set_rate_limit function for QEMUFile
This patch converts the current callers of qemu_fopen_ops(). Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/savevm.c b/savevm.c
index 774305d60f..68ffd03e6e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -159,6 +159,7 @@ struct QEMUFile {
QEMUFileGetBufferFunc *get_buffer;
QEMUFileCloseFunc *close;
QEMUFileRateLimit *rate_limit;
+ QEMUFileSetRateLimit *set_rate_limit;
void *opaque;
int is_write;
@@ -239,9 +240,9 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode)
s->popen_file = popen_file;
if(mode[0] == 'r') {
- s->file = qemu_fopen_ops(s, NULL, popen_get_buffer, popen_close, NULL);
+ s->file = qemu_fopen_ops(s, NULL, popen_get_buffer, popen_close, NULL, NULL);
} else {
- s->file = qemu_fopen_ops(s, popen_put_buffer, NULL, popen_close, NULL);
+ s->file = qemu_fopen_ops(s, popen_put_buffer, NULL, popen_close, NULL, NULL);
}
fprintf(stderr, "qemu_popen: returning result of qemu_fopen_ops\n");
return s->file;
@@ -264,7 +265,7 @@ QEMUFile *qemu_fopen_socket(int fd)
QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
s->fd = fd;
- s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close, NULL);
+ s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close, NULL, NULL);
return s->file;
}
@@ -308,9 +309,9 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
goto fail;
if (!strcmp(mode, "wb"))
- return qemu_fopen_ops(s, file_put_buffer, NULL, file_close, NULL);
+ return qemu_fopen_ops(s, file_put_buffer, NULL, file_close, NULL, NULL);
else if (!strcmp(mode, "rb"))
- return qemu_fopen_ops(s, NULL, file_get_buffer, file_close, NULL);
+ return qemu_fopen_ops(s, NULL, file_get_buffer, file_close, NULL, NULL);
fail:
if (s->outfile)
@@ -356,15 +357,16 @@ static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_wr
s->base_offset = offset;
if (is_writable)
- return qemu_fopen_ops(s, block_put_buffer, NULL, bdrv_fclose, NULL);
+ return qemu_fopen_ops(s, block_put_buffer, NULL, bdrv_fclose, NULL, NULL);
- return qemu_fopen_ops(s, NULL, block_get_buffer, bdrv_fclose, NULL);
+ return qemu_fopen_ops(s, NULL, block_get_buffer, bdrv_fclose, NULL, NULL);
}
QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
QEMUFileGetBufferFunc *get_buffer,
QEMUFileCloseFunc *close,
- QEMUFileRateLimit *rate_limit)
+ QEMUFileRateLimit *rate_limit,
+ QEMUFileSetRateLimit *set_rate_limit)
{
QEMUFile *f;
@@ -375,6 +377,7 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
f->get_buffer = get_buffer;
f->close = close;
f->rate_limit = rate_limit;
+ f->set_rate_limit = set_rate_limit;
f->is_write = 0;
return f;
@@ -552,6 +555,14 @@ int qemu_file_rate_limit(QEMUFile *f)
return 0;
}
+size_t qemu_file_set_rate_limit(QEMUFile *f, size_t new_rate)
+{
+ if (f->set_rate_limit)
+ return f->set_rate_limit(f->opaque, new_rate);
+
+ return 0;
+}
+
void qemu_put_be16(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 8);