From 435f97ada1ec974e56658d6df179cca3599052cc Mon Sep 17 00:00:00 2001
Message-Id: <435f97ada1ec974e56658d6df179cca3599052cc.1349175436.git.minovotn@redhat.com>
In-Reply-To: <94968b7fa9b14e71f004474d7ce77e189e6a2bf3.1349175436.git.minovotn@redhat.com>
References: <94968b7fa9b14e71f004474d7ce77e189e6a2bf3.1349175436.git.minovotn@redhat.com>
From: Amos Kong <akong@redhat.com>
Date: Mon, 1 Oct 2012 14:12:47 +0200
Subject: [PATCH 34/34] Clear handler only for valid fd

RH-Author: Amos Kong <akong@redhat.com>
Message-id: <1349100767-9066-15-git-send-email-akong@redhat.com>
Patchwork-id: 42573
O-Subject: [RHEL-6.4 qemu-kvm PATCH v7 14/14] Clear handler only for valid fd
Bugzilla: 680356
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>

From: Orit Wasserman <owasserm@redhat.com>

(Cherry-picked from commit 3202becaa2b805497ce9e6faa6edfb83665f91b1)

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 migration.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 migration.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/migration.c b/migration.c
index d09ad71..054b418 100644
--- a/migration.c
+++ b/migration.c
@@ -306,7 +306,9 @@ int migrate_fd_cleanup(FdMigrationState *s)
 {
     int ret = 0;
 
-    qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+    if (s->fd != -1) {
+        qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+    }
 
     if (s->file) {
         DPRINTF("closing file\n");
-- 
1.7.11.4

