5544c1b
From b7b94b6016b89bf698d661ce4fd22139e771a835 Mon Sep 17 00:00:00 2001
5544c1b
From: Orit Wasserman <owasserm@redhat.com>
5544c1b
Date: Mon, 24 Sep 2012 13:11:10 +0200
5544c1b
Subject: [PATCH] Clear handler only for valid fd
5544c1b
5544c1b
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
5544c1b
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
5544c1b
(cherry picked from commit 3202becaa2b805497ce9e6faa6edfb83665f91b1)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 migration.c | 4 +++-
5544c1b
 1 file changed, 3 insertions(+), 1 deletion(-)
5544c1b
5544c1b
diff --git a/migration.c b/migration.c
5544c1b
index 1edeec5..22a05c4 100644
5544c1b
--- a/migration.c
5544c1b
+++ b/migration.c
5544c1b
@@ -240,7 +240,9 @@ static int migrate_fd_cleanup(MigrationState *s)
5544c1b
 {
5544c1b
     int ret = 0;
5544c1b
 
5544c1b
-    qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
5544c1b
+    if (s->fd != -1) {
5544c1b
+        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
5544c1b
+    }
5544c1b
 
5544c1b
     if (s->file) {
5544c1b
         DPRINTF("closing file\n");