summaryrefslogtreecommitdiff
path: root/buffered_file.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
commit19629537bd8d81fa7a32f2df5c39419afded04fa (patch)
treec07d954bd6c75d60ea5a036187f94c3b5d624679 /buffered_file.c
parent9f9e28cda74bc8cddd8ac4c0a9c007b31d42c6f6 (diff)
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 'buffered_file.c')
-rw-r--r--buffered_file.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/buffered_file.c b/buffered_file.c
index ec4f6641cc..364b912f2d 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -198,6 +198,19 @@ static int buffered_rate_limit(void *opaque)
return 0;
}
+static size_t buffered_set_rate_limit(void *opaque, size_t new_rate)
+{
+ QEMUFileBuffered *s = opaque;
+
+ if (s->has_error)
+ goto out;
+
+ s->xfer_limit = new_rate / 10;
+
+out:
+ return s->xfer_limit;
+}
+
static void buffered_rate_tick(void *opaque)
{
QEMUFileBuffered *s = opaque;
@@ -237,7 +250,8 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque,
s->close = close;
s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
- buffered_close, buffered_rate_limit);
+ buffered_close, buffered_rate_limit,
+ buffered_set_rate_limit);
s->timer = qemu_new_timer(rt_clock, buffered_rate_tick, s);