qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 6/8] virtio-blk: Use VirtIOBlockReq.in to dro


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 6/8] virtio-blk: Use VirtIOBlockReq.in to drop VirtIOBlockReq.inhdr
Date: Thu, 05 Jun 2014 04:51:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]