Patchwork virtio-blk: Return UNSUPP for unknown request types

login
register
mail settings
Submitter Alexey Zaytsev
Date Dec. 13, 2012, 7:03 a.m.
Message ID <1355382223-26222-1-git-send-email-alexey.zaytsev@gmail.com>
Download mbox | patch
Permalink /patch/205783/
State New
Headers show

Comments

Alexey Zaytsev - Dec. 13, 2012, 7:03 a.m.
Currently, all unknown requests are treated as VIRTIO_BLK_T_IN

Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
---
Sorry, made a typo when formatting the patch, please consider this one.

 hw/virtio-blk.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Stefan Hajnoczi - Dec. 18, 2012, 1:58 p.m.
On Thu, Dec 13, 2012 at 09:03:43AM +0200, Alexey Zaytsev wrote:
> Currently, all unknown requests are treated as VIRTIO_BLK_T_IN
> 
> Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
> ---
> Sorry, made a typo when formatting the patch, please consider this one.
> 
>  hw/virtio-blk.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

Patch

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index e25cc96..c47951a 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -392,10 +392,14 @@  static void virtio_blk_handle_request(VirtIOBlockReq *req,
         qemu_iovec_init_external(&req->qiov, &req->elem.out_sg[1],
                                  req->elem.out_num - 1);
         virtio_blk_handle_write(req, mrb);
-    } else {
+    } else if (type == VIRTIO_BLK_T_IN || type == VIRTIO_BLK_T_BARRIER) {
+        /* VIRTIO_BLK_T_IN is 0, so we can't just & it. */
         qemu_iovec_init_external(&req->qiov, &req->elem.in_sg[0],
                                  req->elem.in_num - 1);
         virtio_blk_handle_read(req);
+    } else {
+        virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP);
+        g_free(req);
     }
 }