From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaoHG-00083d-3J for qemu-devel@nongnu.org; Tue, 20 Nov 2012 08:54:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TaoHA-0007gl-9P for qemu-devel@nongnu.org; Tue, 20 Nov 2012 08:54:14 -0500 Received: from mail-bk0-f45.google.com ([209.85.214.45]:33483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaoHA-0007gd-2a for qemu-devel@nongnu.org; Tue, 20 Nov 2012 08:54:08 -0500 Received: by mail-bk0-f45.google.com with SMTP id jk13so1407383bkc.4 for ; Tue, 20 Nov 2012 05:54:07 -0800 (PST) Date: Tue, 20 Nov 2012 14:54:05 +0100 From: Stefan Hajnoczi Message-ID: <20121120135404.GB28489@stefanha-thinkpad.redhat.com> References: <1353414712-27072-1-git-send-email-stefanha@redhat.com> <1353414712-27072-8-git-send-email-stefanha@redhat.com> <20121120130453.GA3448@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121120130453.GA3448@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 7/8] dataplane: add virtio-blk data plane code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Kevin Wolf , Anthony Liguori , rusty@rustcorp.com.au, qemu-devel@nongnu.org, khoa@us.ibm.com, Stefan Hajnoczi , Paolo Bonzini , asias@redhat.com On Tue, Nov 20, 2012 at 03:04:53PM +0200, Michael S. Tsirkin wrote: > On Tue, Nov 20, 2012 at 01:31:51PM +0100, Stefan Hajnoczi wrote: > > +static void process_request(IOQueue *ioq, struct iovec iov[], > > + unsigned int out_num, unsigned int in_num, > > + unsigned int head) > > +{ > > + /* Virtio block requests look like this: */ > > + struct virtio_blk_outhdr *outhdr; /* iov[0] */ > > + /* data[] ... */ > > + struct virtio_blk_inhdr *inhdr; /* iov[out_num + in_num - 1] */ > > + > > + if (unlikely(out_num == 0 || in_num == 0 || > > + iov[0].iov_len != sizeof *outhdr || > > + iov[out_num + in_num - 1].iov_len != sizeof *inhdr)) { > > + fprintf(stderr, "virtio-blk invalid request\n"); > > + exit(1); > > + } > > + > > + outhdr = iov[0].iov_base; > > + inhdr = iov[out_num + in_num - 1].iov_base; > > + > > Rusty is trying to get rid of hard-coded layout assumptions, > let's not add any more if we can help it. Will try to abstract the iov arrays in the next version. Still not a fan of doing this because it complicates the code for little gain. Stefan