From: Gerd Hoffmann Date: Fri, 8 Jun 2012 10:58:46 +0000 (+0200) Subject: usb: restore USBDevice->attached on vmload X-Git-Tag: v1.1.2~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a1a17b1d5a7fe618e42a94fc171712aeb31561ec;p=thirdparty%2Fqemu.git usb: restore USBDevice->attached on vmload Signed-off-by: Gerd Hoffmann (cherry picked from commit 495d544798151206bafca65ec588c0388637eb40) Signed-off-by: Michael Roth --- diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 2068640a58b..77b2b99e51a 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),