diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2012-06-08 12:58:46 +0200 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2012-08-21 15:36:35 -0500 |
commit | a1a17b1d5a7fe618e42a94fc171712aeb31561ec (patch) | |
tree | 2cc07cd61a161638aeee4291567423117e2f231b | |
parent | f49853a4bd5113cdb847579b8fb171a06d68af10 (diff) |
usb: restore USBDevice->attached on vmload
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 495d544798151206bafca65ec588c0388637eb40)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r-- | hw/usb/bus.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 2068640a5..77b2b99e5 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -27,10 +27,23 @@ static struct BusInfo 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), |