Skip to contentSkip to conversation

fix segfault in setting migration speed

PATCH New Glauber Costa 1 participant 1 message Jul 14, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 savevm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
savevm.c +3 -1
index 17da35a..e577109 100644
@@ -574,7 +574,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;
Signature · 1 line
1.6.2.2