From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsNmd-0004Zb-Bk for qemu-devel@nongnu.org; Wed, 04 Jun 2014 22:52:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsNmX-00081R-HE for qemu-devel@nongnu.org; Wed, 04 Jun 2014 22:52:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsNmX-00081D-9J for qemu-devel@nongnu.org; Wed, 04 Jun 2014 22:51:57 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s552pugY005842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 4 Jun 2014 22:51:56 -0400 Message-ID: <538FDB48.6080200@redhat.com> Date: Thu, 05 Jun 2014 04:51:52 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1401933526-22436-1-git-send-email-famz@redhat.com> <1401933526-22436-7-git-send-email-famz@redhat.com> In-Reply-To: <1401933526-22436-7-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 6/8] virtio-blk: Use VirtIOBlockReq.in to drop VirtIOBlockReq.inhdr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi Il 05/06/2014 03:58, Fam Zheng ha scritto: > /* Grab inhdr for later */ > - in_size = iov_size(in_iov, in_num); > - if (in_size < sizeof(struct virtio_blk_inhdr)) { > - error_report("virtio_blk request inhdr too short"); > - return -EFAULT; > - } > - inhdr = g_slice_new(QEMUIOVector); > - qemu_iovec_init(inhdr, 1); > - qemu_iovec_concat_iov(inhdr, in_iov, in_num, > - in_size - sizeof(struct virtio_blk_inhdr), > - sizeof(struct virtio_blk_inhdr)); > - iov_discard_back(in_iov, &in_num, sizeof(struct virtio_blk_inhdr)); > + inhdr = (void *)in_iov[in_num - 1].iov_base; This would assume a particular layout for the virtio buffers. You need to add in_iov[in_num - 1].iov_len - sizeof(struct virtio_blk_header). It's probably also good to ahve an assertion that in_iov[in_num - 1].iov_len > sizeof(struct virtio_blk_header), and a comment saying that the assertion is always true because the struct is only 1-byte long. Paolo