From a673e4c2bdc14ce3276258f4a9147b0f9c453c16 Mon Sep 17 00:00:00 2001
Message-Id: <a673e4c2bdc14ce3276258f4a9147b0f9c453c16.1350314947.git.minovotn@redhat.com>
In-Reply-To: <e1e38e4ef58357b226fe4823f6400ab99668e7a9.1350314947.git.minovotn@redhat.com>
References: <e1e38e4ef58357b226fe4823f6400ab99668e7a9.1350314947.git.minovotn@redhat.com>
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 15 Oct 2012 12:46:26 +0200
Subject: [PATCH 4/4] usb-redir: Don't make migration fail in none seamless
 case

Instead simple disconnect the device like host redirection does on
migration.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Upstream commit id: 5c16f767813602fbf57414e2a11057e252e0d422
Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 usb-redir.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/usb-redir.c b/usb-redir.c
index 933710d..72361ec 100644
--- a/usb-redir.c
+++ b/usb-redir.c
@@ -1660,12 +1660,17 @@ static int usbredir_get_parser(QEMUFile *f, void *priv, size_t unused)
     }
 
     /*
-     * Our chardev should be open already at this point, otherwise
-     * the usbredir channel will be broken (ie spice without seamless)
+     * If our chardev is not open already at this point the usbredir connection
+     * has been broken (non seamless migration, or restore from disk).
+     *
+     * In this case create a temporary parser to receive the migration data,
+     * and schedule the close_bh to report the device as disconnected to the
+     * guest and to destroy the parser again.
      */
     if (dev->parser == NULL) {
-        ERROR("get_parser called with closed chardev, failing migration\n");
-        return -1;
+        WARNING("usb-redir connection broken during migration\n");
+        usbredir_create_parser(dev);
+        qemu_bh_schedule(dev->chardev_close_bh);
     }
 
     data = qemu_malloc(len);
-- 
1.7.11.7