]> git.proxmox.com Git - qemu.git/commitdiff
usb: restore USBDevice->attached on vmload
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 8 Jun 2012 10:58:46 +0000 (12:58 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 20 Jun 2012 12:46:02 +0000 (14:46 +0200)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/bus.c

index f87cc5f443901677b8ce56520c98d85c9affe8ff..b649360dd383d6dd406997ee7efd4e87b895f5cf 100644 (file)
@@ -37,10 +37,23 @@ static const TypeInfo usb_bus_info = {
 static int next_usb_bus = 0;
 static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
 
+static int usb_device_post_load(void *opaque, int version_id)
+{
+    USBDevice *dev = opaque;
+
+    if (dev->state == USB_STATE_NOTATTACHED) {
+        dev->attached = 0;
+    } else {
+        dev->attached = 1;
+    }
+    return 0;
+}
+
 const VMStateDescription vmstate_usb_device = {
     .name = "USBDevice",
     .version_id = 1,
     .minimum_version_id = 1,
+    .post_load = usb_device_post_load,
     .fields = (VMStateField []) {
         VMSTATE_UINT8(addr, USBDevice),
         VMSTATE_INT32(state, USBDevice),