aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/bus.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-06-08 12:58:46 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-06-20 14:46:02 +0200
commit495d544798151206bafca65ec588c0388637eb40 (patch)
treebe71faf903e8fd98adf15d316d96837f2fe89d63 /hw/usb/bus.c
parent9a77340827cd48c5c9b6daab614009a0594abf38 (diff)
usb: restore USBDevice->attached on vmload
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/bus.c')
-rw-r--r--hw/usb/bus.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index f87cc5f443..b649360dd3 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -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),