summaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@redhat.com>2009-07-14 18:26:51 -0400
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-16 17:28:51 -0500
commit02d5dab3bd38d83a4dae8ba3d03a3f6a8a2d9aab (patch)
tree114859324a6725453f0cf49aef7c74814377e09a /savevm.c
parenteaea313f3acb7c1aa3fb5ad27289a970209290d8 (diff)
downloadqemu-02d5dab3bd38d83a4dae8ba3d03a3f6a8a2d9aab.tar.gz
qemu-02d5dab3bd38d83a4dae8ba3d03a3f6a8a2d9aab.tar.bz2
qemu-02d5dab3bd38d83a4dae8ba3d03a3f6a8a2d9aab.zip
fix segfault in setting migration speed
Hi, Whoever wrote this migrate_set_speed function is totally stupid. Any failed or completed migration keeps its state to allow probing of migration data, but has no associated file anymore. It is, thus, possible to crash qemu by calling migrate_set_speed after a migration is finished (or failed, or cancelled), but before another one starts. This patch fixes it. 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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/savevm.c b/savevm.c
index 113f2207c7..181c088494 100644
--- a/savevm.c
+++ b/savevm.c
@@ -556,7 +556,9 @@ int qemu_file_rate_limit(QEMUFile *f)
size_t qemu_file_set_rate_limit(QEMUFile *f, size_t new_rate)
{
- if (f->set_rate_limit)
+ /* any failed or completed migration keeps its state to allow probing of
+ * migration data, but has no associated file anymore */
+ if (f && f->set_rate_limit)
return f->set_rate_limit(f->opaque, new_rate);
return 0;