[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout |
Date: |
Tue, 28 Jul 2015 12:57:40 +0300 |
virtio pci allows any device to have a modern interface,
this in turn requires ANY_LAYOUT support.
Fix up ANY_LAYOUT for virtio-9p.
Reported-by: Jason Wang <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Jason Wang <address@hidden>
---
hw/9pfs/virtio-9p.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 6ef8af3..f972731 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -14,6 +14,7 @@
#include "hw/virtio/virtio.h"
#include "hw/i386/pc.h"
#include "qemu/error-report.h"
+#include "qemu/iov.h"
#include "qemu/sockets.h"
#include "virtio-9p.h"
#include "fsdev/qemu-fsdev.h"
@@ -3261,16 +3262,26 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
while ((pdu = alloc_pdu(s)) &&
(len = virtqueue_pop(vq, &pdu->elem)) != 0) {
- uint8_t *ptr;
+ struct {
+ uint32_t size_le;
+ uint8_t id;
+ uint16_t tag_le;
+ } QEMU_PACKED out;
+ int len;
+
pdu->s = s;
BUG_ON(pdu->elem.out_num == 0 || pdu->elem.in_num == 0);
- BUG_ON(pdu->elem.out_sg[0].iov_len < 7);
+ QEMU_BUILD_BUG_ON(sizeof out != 7);
+
+ len = iov_to_buf(pdu->elem.out_sg, pdu->elem.out_num, 0,
+ &out, sizeof out);
+ BUG_ON(len != sizeof out);
+
+ pdu->size = le32_to_cpu(out.size_le);
- ptr = pdu->elem.out_sg[0].iov_base;
+ pdu->id = out.id;
+ pdu->tag = le16_to_cpu(out.tag_le);
- pdu->size = le32_to_cpu(*(uint32_t *)ptr);
- pdu->id = ptr[4];
- pdu->tag = le16_to_cpu(*(uint16_t *)(ptr + 5));
qemu_co_queue_init(&pdu->complete);
submit_pdu(s, pdu);
}
--
MST
- [Qemu-devel] [PULL 00/10] virtio fixes for 2.4, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 02/10] virtio-serial: fix ANY_LAYOUT, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 01/10] virtio: hide legacy features from modern guests, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 05/10] virtio-pci: fix memory MR cleanup for modern, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 04/10] virtio: set any_layout in virtio core, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 07/10] virtio-blk: fail get_features when both scsi and 1.0 were set, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 06/10] virtio: get_features() can fail, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 08/10] virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 09/10] acpi: fix pvpanic device is not shown in ui, Michael S. Tsirkin, 2015/07/28
- [Qemu-devel] [PULL 10/10] virtio: minor cleanup, Michael S. Tsirkin, 2015/07/28
- Re: [Qemu-devel] [PULL 00/10] virtio fixes for 2.4, Cornelia Huck, 2015/07/28
- Re: [Qemu-devel] [PULL 00/10] virtio fixes for 2.4, Peter Maydell, 2015/07/28