From d0c222d085410a0ab790f24a1a819ad74982e8b4 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Gerd Hoffmann Date: Thu, 16 Aug 2012 11:39:16 +0200 Subject: [PATCH 14/18] usb-storage: migration support RH-Author: Gerd Hoffmann Message-id: <1345117160-21046-15-git-send-email-kraxel@redhat.com> Patchwork-id: 40927 O-Subject: [RHEL-6.4 qemu-kvm PATCH 14/18] usb-storage: migration support Bugzilla: 805172 RH-Acked-by: Paolo Bonzini RH-Acked-by: Hans de Goede RH-Acked-by: Laszlo Ersek With all scsi migration support bits in place the final step is pretty simple ;) Signed-off-by: Gerd Hoffmann (cherry picked from commit 5de88b1d4679b560f1350aa4559342ba6a8d69ef) --- hw/usb-msd.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) Signed-off-by: Michal Novotny --- hw/usb-msd.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 57afe14..7c5e87c 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -525,6 +525,17 @@ static void usb_msd_password_cb(void *opaque, int err) qdev_unplug(&s->dev.qdev); } +static void *usb_msd_load_request(QEMUFile *f, SCSIRequest *req) +{ + MSDState *s = DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); + + /* nothing to load, just store req in our state struct */ + assert(s->req == NULL); + scsi_req_ref(req); + s->req = req; + return NULL; +} + static const struct SCSIBusInfo usb_msd_scsi_info = { .tcq = false, .max_target = 0, @@ -532,7 +543,8 @@ static const struct SCSIBusInfo usb_msd_scsi_info = { .transfer_data = usb_msd_transfer_data, .complete = usb_msd_command_complete, - .cancel = usb_msd_request_cancelled + .cancel = usb_msd_request_cancelled, + .load_request = usb_msd_load_request, }; static int usb_msd_initfn(USBDevice *dev) @@ -652,11 +664,18 @@ static USBDevice *usb_msd_init(const char *filename) static const VMStateDescription vmstate_usb_msd = { .name = "usb-storage", - .unmigratable = 1, /* FIXME: handle transactions which are in flight */ .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { VMSTATE_USB_DEVICE(dev, MSDState), + VMSTATE_UINT32(mode, MSDState), + VMSTATE_UINT32(scsi_len, MSDState), + VMSTATE_UINT32(scsi_off, MSDState), + VMSTATE_UINT32(data_len, MSDState), + VMSTATE_UINT32(csw.sig, MSDState), + VMSTATE_UINT32(csw.tag, MSDState), + VMSTATE_UINT32(csw.residue, MSDState), + VMSTATE_UINT8(csw.status, MSDState), VMSTATE_END_OF_LIST() } }; -- 1.7.11.4