From 13a1bbe84635293b7515e09e63e3d2c40c5d8243 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 3 Aug 2015 14:38:21 +0200 Subject: [PATCH 1/4] virtio-scsi: use virtqueue_map_sg() when loading requests Message-id: <1438612702-9236-2-git-send-email-stefanha@redhat.com> Patchwork-id: 67252 O-Subject: [RHEV-7.2 qemu-kvm-rhev PATCH 1/2] virtio-scsi: use virtqueue_map_sg() when loading requests Bugzilla: 1160169 RH-Acked-by: Thomas Huth RH-Acked-by: Fam Zheng RH-Acked-by: Miroslav Rezanina The VirtQueueElement struct is serialized during migration but the in_sg[]/out_sg[] iovec arrays are not usable on the destination host because the pointers are meaningless. Use virtqueue_map_sg() to refresh in_sg[]/out_sg[] to valid pointers based on in_addr[]/out_addr[] hwaddrs. Cc: Paolo Bonzini Signed-off-by: Stefan Hajnoczi Message-Id: <1438262173-11546-2-git-send-email-stefanha@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 1cc933453bf2baae1feb7c8e757bdfd0ef639002) Signed-off-by: Stefan Hajnoczi Signed-off-by: Miroslav Rezanina --- hw/scsi/virtio-scsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index f7d3c7c..3d71e04 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -217,6 +217,11 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq) assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg)); assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg)); + virtqueue_map_sg(req->elem.in_sg, req->elem.in_addr, + req->elem.in_num, 1); + virtqueue_map_sg(req->elem.out_sg, req->elem.out_addr, + req->elem.out_num, 0); + if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size, sizeof(VirtIOSCSICmdResp) + vs->sense_size) < 0) { error_report("invalid SCSI request migration data"); -- 1.8.3.1