From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40837 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJQLQ-000511-AM for qemu-devel@nongnu.org; Fri, 19 Nov 2010 07:45:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJQLP-0003Uy-1N for qemu-devel@nongnu.org; Fri, 19 Nov 2010 07:45:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJQLO-0003Uj-Qd for qemu-devel@nongnu.org; Fri, 19 Nov 2010 07:45:35 -0500 Message-ID: <4CE671A1.2080000@redhat.com> Date: Fri, 19 Nov 2010 13:46:25 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 09/16] scsi-disk: Allocate iovec dynamically References: <20101118144723.61032F90AB@ochil.suse.de> <4CE54755.8010205@redhat.com> <4CE5543C.2080701@suse.de> <4CE662D8.7020709@redhat.com> <4CE66DF1.4000907@suse.de> In-Reply-To: <4CE66DF1.4000907@suse.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hannes Reinecke Cc: stefanha@gmail.com, Gerd Hoffmann , nab@linux-iscsi.org, qemu-devel@nongnu.org Am 19.11.2010 13:30, schrieb Hannes Reinecke: > On 11/19/2010 12:43 PM, Kevin Wolf wrote: >> Am 18.11.2010 17:28, schrieb Hannes Reinecke: >>> On 11/18/2010 04:33 PM, Gerd Hoffmann wrote: >>>> Hi, >>>> >>>>> +static size_t scsi_req_iov_len(SCSIDiskReq *r) >>>>> +{ >>>>> + size_t iov_len = 0; >>>>> + int i; >>>>> + >>>>> + for (i = 0; i< r->iov_num; i++) >>>>> + iov_len += r->iov[i].iov_len; >>>>> + >>>>> + return iov_len; >>>>> +} >>>> >>>> You are aware that there is a QEMUIOVector type with helper functions >>>> which keeps track of both number of elements and total size? >>>> >>> Yes. But I'm passing passing in an entire iovec to the request. >>> However, the QEMUIOVector routines allow you to add only _one_ >>> element at a time, which is pretty wasteful here. >> >> Does the iov need to be changed afterwards, or why doesn't >> qemu_iovec_init_external work here? >> > Oh, but I _do_ use qemu_iovec_init_external(); cf > > hw/scsi_disk.c:scsi_read_data() > > and yes, the iovec might be modified by the read/write operation; > see below. > >>> And I'm counting the resulting length of the iovec, which might have >>> been changed by read/write operations. For which there is no generic >>> function either. >> >> Can you explain which kind of read/write operations would change the >> iov? This is not completely clear to me. >> > It is perfectly valid to send down an iovec larger than the command > would fill out; eg for a SCSI Inquiry you could easily request 255 > bytes, but the command itself would only provide you with say 36 bytes. Okay, so at the point where you create the iovec you don't have this information yet but rather let the command emulation update the iovec later. Makes sense. That's probably something that QEMUIOVectors isn't really designed for, so just forget what I said. :-) Kevin