qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 7/8] virtio-blk: Convert VirtIOBlockReq.out t


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 7/8] virtio-blk: Convert VirtIOBlockReq.out to structrue
Date: Thu, 05 Jun 2014 04:54:19 +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:

-    if (req->elem->out_sg[0].iov_len < sizeof(*req->out) ||
+    if (req->elem->out_sg[0].iov_len < sizeof(req->out) ||

This is not needed anymore.

         req->elem->in_sg[req->elem->in_num - 1].iov_len < sizeof(*req->in)) {
         error_report("virtio-blk header not in correct element");
         exit(1);
     }

-    req->out = (void *)req->elem->out_sg[0].iov_base;
+    if (unlikely(iov_to_buf(iov, out_num, 0, &req->out,
+                            sizeof(req->out)) != sizeof(req->out))) {
+        error_report("virtio-blk request outhdr too short");
+        exit(1);
+    }
+    iov_discard_front(&iov, &out_num, sizeof(req->out));
     req->in = (void *)req->elem->in_sg[req->elem->in_num - 1].iov_base;

Here, in a separate patch, you can add iov_len-1 as suggested in the previous review, and then use iov_discard_back on in_num. You can then drop the other part of the "virtio-blk header not in correct element" check.

Paolo



reply via email to

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