From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-547566-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B84A1138555 for <garchives@archives.gentoo.org>; Sat, 19 Jan 2013 02:27:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D32A821C072; Sat, 19 Jan 2013 02:27:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5370D21C072 for <gentoo-commits@lists.gentoo.org>; Sat, 19 Jan 2013 02:27:53 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6D64733DABC for <gentoo-commits@lists.gentoo.org>; Sat, 19 Jan 2013 02:27:52 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 706B1E4093 for <gentoo-commits@lists.gentoo.org>; Sat, 19 Jan 2013 02:27:50 +0000 (UTC) From: "Doug Goldstein" <cardoe@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Doug Goldstein" <cardoe@gentoo.org> Message-ID: <1355434319.5e5cbe13a73bb99bc69de3e0925bd4964e56a2bb.cardoe@gentoo> Subject: [gentoo-commits] proj/qemu-kvm:qemu-kvm-1.2.0-gentoo commit in: hw/ X-VCS-Repository: proj/qemu-kvm X-VCS-Files: hw/virtio-scsi.c X-VCS-Directories: hw/ X-VCS-Committer: cardoe X-VCS-Committer-Name: Doug Goldstein X-VCS-Revision: 5e5cbe13a73bb99bc69de3e0925bd4964e56a2bb X-VCS-Branch: qemu-kvm-1.2.0-gentoo Date: Sat, 19 Jan 2013 02:27:50 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b11966e7-8baa-47e7-9114-f00778185c8a X-Archives-Hash: d706c5c91c2dd8283072f5545ffe9daf commit: 5e5cbe13a73bb99bc69de3e0925bd4964e56a2bb Author: David Gibson <david <AT> gibson <DOT> dropbear <DOT> id <DOT> au> AuthorDate: Fri Nov 23 05:08:44 2012 +0000 Commit: Doug Goldstein <cardoe <AT> gentoo <DOT> org> CommitDate: Thu Dec 13 21:31:59 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qemu-kvm.git;a=commit;h=5e5cbe13 virtio-scsi: Fix some endian bugs with virtio-scsi The virtio-scsi specification does not specify the correct endianness for fields in the request structure. It's therefore best to assume that it is "guest native" endian since that's the (stupid and poorly defined) norm in virtio. However, the qemu device for virtio-scsi has no byteswaps at all, and so will break if the guest has different endianness from the host. This patch fixes it by adding tswap() calls for the sense_len and resid fields in the request structure. In theory status_qualifier needs swaps as well, but that field is never actually touched. The tag field is a uint64_t, but since its value is completely arbitrary, it might as well be uint8_t[8] and so it does not need swapping. Cc: Paolo Bonzini <pbonzini <AT> redhat.com> Cc: Paul 'Rusty' Russell <rusty <AT> rustcorp.com.au> Signed-off-by: David Gibson <david <AT> gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini <pbonzini <AT> redhat.com> (cherry picked from commit 474ee55a18765e7de8f0b2cc00db5d26286bb24d) Signed-off-by: Michael Roth <mdroth <AT> linux.vnet.ibm.com> (cherry picked from commit ea08f3a4e25fe76d42a186152949516c2a63a46b) --- hw/virtio-scsi.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index c1b47a8..c6d5290 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -424,15 +424,17 @@ static void virtio_scsi_command_complete(SCSIRequest *r, uint32_t status, size_t resid) { VirtIOSCSIReq *req = r->hba_private; + uint32_t sense_len; req->resp.cmd->response = VIRTIO_SCSI_S_OK; req->resp.cmd->status = status; if (req->resp.cmd->status == GOOD) { - req->resp.cmd->resid = resid; + req->resp.cmd->resid = tswap32(resid); } else { req->resp.cmd->resid = 0; - req->resp.cmd->sense_len = - scsi_req_get_sense(r, req->resp.cmd->sense, VIRTIO_SCSI_SENSE_SIZE); + sense_len = scsi_req_get_sense(r, req->resp.cmd->sense, + VIRTIO_SCSI_SENSE_SIZE); + req->resp.cmd->sense_len = tswap32(sense_len); } virtio_scsi_complete_req(req); }