diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2015-07-28 17:09:56 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-07-28 17:09:56 +0100 |
commit | 170f209d7848dc2f14b3f3dccc34a49558680d4d (patch) | |
tree | 174270b1aaaa14a3ea9efb21687535274d7bd829 /hw/9pfs | |
parent | 8b89b3a8df0a7d1ddbc9744f66a495986af667ca (diff) | |
parent | c147b5153e733a14fc65d2098e7036754c185ad1 (diff) |
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
virtio fixes for 2.4
Mostly virtio 1 spec compliance fixes.
We are unlikely to make it perfectly compliant in
the first release, but it seems worth it to try.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Mon Jul 27 21:55:48 2015 BST using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg: aka "Michael S. Tsirkin <mst@redhat.com>"
* remotes/mst/tags/for_upstream:
virtio: minor cleanup
acpi: fix pvpanic device is not shown in ui
virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device
virtio-blk: fail get_features when both scsi and 1.0 were set
virtio: get_features() can fail
virtio-pci: fix memory MR cleanup for modern
virtio: set any_layout in virtio core
virtio-9p: fix any_layout
virtio-serial: fix ANY_LAYOUT
virtio: hide legacy features from modern guests
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/9pfs')
-rw-r--r-- | hw/9pfs/virtio-9p-device.c | 3 | ||||
-rw-r--r-- | hw/9pfs/virtio-9p.c | 23 |
2 files changed, 19 insertions, 7 deletions
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 3f4c9e7a02..93a407c459 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -21,7 +21,8 @@ #include "virtio-9p-coth.h" #include "hw/virtio/virtio-access.h" -static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features) +static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) { virtio_add_feature(&features, VIRTIO_9P_MOUNT_TAG); return features; diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 6ef8af3f64..f972731f5a 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); } |