9290838
From 11da0c283915f9e3d3da42451d218c26efef4671 Mon Sep 17 00:00:00 2001
ca70dc3
From: Hans de Goede <hdegoede@redhat.com>
ca70dc3
Date: Thu, 27 Sep 2012 16:57:41 +0200
5544c1b
Subject: [PATCH] usb-redir: Don't make migration fail in none seamless case
ca70dc3
ca70dc3
Instead simple disconnect the device like host redirection does on
ca70dc3
migration.
ca70dc3
ca70dc3
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
ca70dc3
---
ca70dc3
 hw/usb/redirect.c | 13 +++++++++----
ca70dc3
 1 file changed, 9 insertions(+), 4 deletions(-)
ca70dc3
ca70dc3
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
ca70dc3
index 5d16aff..022ba42 100644
ca70dc3
--- a/hw/usb/redirect.c
ca70dc3
+++ b/hw/usb/redirect.c
ca70dc3
@@ -1637,12 +1637,17 @@ static int usbredir_get_parser(QEMUFile *f, void *priv, size_t unused)
ca70dc3
     }
ca70dc3
 
ca70dc3
     /*
ca70dc3
-     * Our chardev should be open already at this point, otherwise
ca70dc3
-     * the usbredir channel will be broken (ie spice without seamless)
ca70dc3
+     * If our chardev is not open already at this point the usbredir connection
ca70dc3
+     * has been broken (non seamless migration, or restore from disk).
ca70dc3
+     *
ca70dc3
+     * In this case create a temporary parser to receive the migration data,
ca70dc3
+     * and schedule the close_bh to report the device as disconnected to the
ca70dc3
+     * guest and to destroy the parser again.
ca70dc3
      */
ca70dc3
     if (dev->parser == NULL) {
ca70dc3
-        ERROR("get_parser called with closed chardev, failing migration\n");
ca70dc3
-        return -1;
ca70dc3
+        WARNING("usb-redir connection broken during migration\n");
ca70dc3
+        usbredir_create_parser(dev);
ca70dc3
+        qemu_bh_schedule(dev->chardev_close_bh);
ca70dc3
     }
ca70dc3
 
ca70dc3
     data = g_malloc(len);