[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/13] virtio-scsi: work around bug in old BIOSes
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 02/13] virtio-scsi: work around bug in old BIOSes |
Date: |
Thu, 13 Nov 2014 16:40:17 +0100 |
Old BIOSes left some padding by mistake after the req_size/resp_size.
New QEMU does not like it, thinking it is a bidirectional command.
As a workaround, we can check if the ANY_LAYOUT bit is set; if not, we
always consider the first buffer as the virtio-scsi request/response,
because, back when QEMU did not support ANY_LAYOUT, it expected the
payload to start at the second element of the iovec.
This can show up during migration.
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/virtio-scsi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index fdcacfd..ef48550 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -118,6 +118,7 @@ static size_t qemu_sgl_concat(VirtIOSCSIReq *req, struct
iovec *iov,
static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
unsigned req_size, unsigned resp_size)
{
+ VirtIODevice *vdev = (VirtIODevice *) req->dev;
size_t in_size, out_size;
if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,
@@ -130,8 +131,24 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
resp_size) < resp_size) {
return -EINVAL;
}
+
req->resp_size = resp_size;
+ /* Old BIOSes left some padding by mistake after the req_size/resp_size.
+ * As a workaround, always consider the first buffer as the virtio-scsi
+ * request/response, making the payload start at the second element
+ * of the iovec.
+ *
+ * The actual length of the response header, stored in req->resp_size,
+ * does not change.
+ *
+ * TODO: always disable this workaround for virtio 1.0 devices.
+ */
+ if ((vdev->guest_features & VIRTIO_F_ANY_LAYOUT) == 0) {
+ req_size = req->elem.out_sg[0].iov_len;
+ resp_size = req->elem.in_sg[0].iov_len;
+ }
+
out_size = qemu_sgl_concat(req, req->elem.out_sg,
&req->elem.out_addr[0], req->elem.out_num,
req_size);
--
1.8.3.1
- [Qemu-devel] [PULL 00/13] x86 and SCSI patches for QEMU 2.2.0-rc2, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 01/13] esp-pci: fixup deadlock with linux, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 02/13] virtio-scsi: work around bug in old BIOSes,
Paolo Bonzini <=
- [Qemu-devel] [PULL 03/13] esp: fix coding standards, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 04/13] virtio-scsi: dataplane: fix allocation for 'cmd_vrings', Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 05/13] esp: Do not overwrite ESP_TCHI after reset, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 06/13] virtio-scsi: dataplane: suppress guest notification, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 09/13] apic_common: migrate missing fields, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 11/13] kvmclock: Add comment explaining why we need cpu_clean_all_dirty(), Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 07/13] virtio-scsi: Fix comment for VirtIOSCSIReq, Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 08/13] target-i386: eliminate dead code and hoist common code out of "if", Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 12/13] smbios: change 'ram_addr_t' variables to 'uint64_t', Paolo Bonzini, 2014/11/13
- [Qemu-devel] [PULL 10/13] target-i386: fix Coverity complaints about overflows, Paolo Bonzini, 2014/11/13