From 0bb05eaff04d30609a98c0dae80bb5dba3e4e799 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Tue, 14 Jul 2009 18:26:51 -0400 Subject: 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 Signed-off-by: Anthony Liguori --- savevm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.1