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

Reply via email to