From: Scott Tsai <scottt.tw@gmail.com> To: Dustin Kirkland <kirkland@canonical.com> Cc: qemu-devel <qemu-devel@nongnu.org>, kvm <kvm@vger.kernel.org>, Anthony Liguori <anthony@codemonkey.ws> Subject: Re: [Qemu-devel] qemu-kvm-0.11 regression, crashes on older guests with virtio network Date: Thu, 29 Oct 2009 11:12:27 +0800 [thread overview] Message-ID: <1256785636-sup-215@xpc65.scottt> (raw) In-Reply-To: <d9c105ea0910281222u76a61a2by3cc924e85d40a865@mail.gmail.com> Excerpts from Dustin Kirkland's message of Thu Oct 29 03:22:43 +0800 2009: > We're tracking this issue at: > * https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/458521 > > I'll gladly review and test patches, or take pointers on where I might > look to solve this issue. Try the following patch against the stable-0.11 branch. I've only just started learning about the virtio-net code but hopefully this patch points you to the right direction. Note that this patch just drops the packets that would have caused virtio-net to call exit(1). >From d48af0377f359983bff67eb9296ba040def401ec Mon Sep 17 00:00:00 2001 From: Scott Tsai <scottt.tw@gmail.com> Date: Thu, 29 Oct 2009 10:56:12 +0800 Subject: [PATCH] virtio-net: drop large packets when no mergable_rx_bufs see: https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/458521 --- hw/virtio-net.c | 8 +++++++- hw/virtio.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index ce8e6cb..2e6725b 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -502,6 +502,8 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) return 0; } +int buffer_fits_in_virtqueue_top(VirtQueue *vq, int size); + static ssize_t virtio_net_receive2(VLANClientState *vc, const uint8_t *buf, size_t size, int raw) { VirtIONet *n = vc->opaque; @@ -518,6 +520,10 @@ static ssize_t virtio_net_receive2(VLANClientState *vc, const uint8_t *buf, size hdr_len = n->mergeable_rx_bufs ? sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr); + /* drop packet instead of truncating it */ + if (!n->mergeable_rx_bufs && !buffer_fits_in_virtqueue_top(n->rx_vq, hdr_len + size)) + return; + offset = i = 0; while (offset < size) { @@ -531,7 +537,7 @@ static ssize_t virtio_net_receive2(VLANClientState *vc, const uint8_t *buf, size virtqueue_pop(n->rx_vq, &elem) == 0) { if (i == 0) return -1; - fprintf(stderr, "virtio-net truncating packet\n"); + fprintf(stderr, "virtio-net truncating packet: mergable_rx_bufs: %d\n", n->mergeable_rx_bufs); exit(1); } diff --git a/hw/virtio.c b/hw/virtio.c index 41e7ca2..d6f5a12 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -356,6 +356,28 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes) return 0; } +/* buffer_fits_in_virtqueue_top: returns true if a 'size' byte buffer could fit in the + * input descriptors that virtqueue_pop() would have returned + */ +int buffer_fits_in_virtqueue_top(VirtQueue *vq, int size); + +int buffer_fits_in_virtqueue_top(VirtQueue *vq, int size) +{ + unsigned int i; + int input_iov_len_sum; + + if (!virtqueue_num_heads(vq, vq->last_avail_idx)) + return 0; + + input_iov_len_sum = 0; + i = virtqueue_get_head(vq, vq->last_avail_idx); + do { + if (vring_desc_flags(vq, i) & VRING_DESC_F_WRITE) + input_iov_len_sum += vring_desc_len(vq, i); + } while ((i = virtqueue_next_desc(vq, i)) != vq->vring.num); + return input_iov_len_sum >= size; +} + int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) { unsigned int i, head, max; -- 1.6.2.5
WARNING: multiple messages have this Message-ID (diff)
From: Scott Tsai <scottt.tw@gmail.com> To: Dustin Kirkland <kirkland@canonical.com> Cc: qemu-devel <qemu-devel@nongnu.org>, kvm <kvm@vger.kernel.org> Subject: Re: [Qemu-devel] qemu-kvm-0.11 regression, crashes on older guests with virtio network Date: Thu, 29 Oct 2009 11:12:27 +0800 [thread overview] Message-ID: <1256785636-sup-215@xpc65.scottt> (raw) In-Reply-To: <d9c105ea0910281222u76a61a2by3cc924e85d40a865@mail.gmail.com> Excerpts from Dustin Kirkland's message of Thu Oct 29 03:22:43 +0800 2009: > We're tracking this issue at: > * https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/458521 > > I'll gladly review and test patches, or take pointers on where I might > look to solve this issue. Try the following patch against the stable-0.11 branch. I've only just started learning about the virtio-net code but hopefully this patch points you to the right direction. Note that this patch just drops the packets that would have caused virtio-net to call exit(1). >From d48af0377f359983bff67eb9296ba040def401ec Mon Sep 17 00:00:00 2001 From: Scott Tsai <scottt.tw@gmail.com> Date: Thu, 29 Oct 2009 10:56:12 +0800 Subject: [PATCH] virtio-net: drop large packets when no mergable_rx_bufs see: https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/458521 --- hw/virtio-net.c | 8 +++++++- hw/virtio.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index ce8e6cb..2e6725b 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -502,6 +502,8 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) return 0; } +int buffer_fits_in_virtqueue_top(VirtQueue *vq, int size); + static ssize_t virtio_net_receive2(VLANClientState *vc, const uint8_t *buf, size_t size, int raw) { VirtIONet *n = vc->opaque; @@ -518,6 +520,10 @@ static ssize_t virtio_net_receive2(VLANClientState *vc, const uint8_t *buf, size hdr_len = n->mergeable_rx_bufs ? sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr); + /* drop packet instead of truncating it */ + if (!n->mergeable_rx_bufs && !buffer_fits_in_virtqueue_top(n->rx_vq, hdr_len + size)) + return; + offset = i = 0; while (offset < size) { @@ -531,7 +537,7 @@ static ssize_t virtio_net_receive2(VLANClientState *vc, const uint8_t *buf, size virtqueue_pop(n->rx_vq, &elem) == 0) { if (i == 0) return -1; - fprintf(stderr, "virtio-net truncating packet\n"); + fprintf(stderr, "virtio-net truncating packet: mergable_rx_bufs: %d\n", n->mergeable_rx_bufs); exit(1); } diff --git a/hw/virtio.c b/hw/virtio.c index 41e7ca2..d6f5a12 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -356,6 +356,28 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes) return 0; } +/* buffer_fits_in_virtqueue_top: returns true if a 'size' byte buffer could fit in the + * input descriptors that virtqueue_pop() would have returned + */ +int buffer_fits_in_virtqueue_top(VirtQueue *vq, int size); + +int buffer_fits_in_virtqueue_top(VirtQueue *vq, int size) +{ + unsigned int i; + int input_iov_len_sum; + + if (!virtqueue_num_heads(vq, vq->last_avail_idx)) + return 0; + + input_iov_len_sum = 0; + i = virtqueue_get_head(vq, vq->last_avail_idx); + do { + if (vring_desc_flags(vq, i) & VRING_DESC_F_WRITE) + input_iov_len_sum += vring_desc_len(vq, i); + } while ((i = virtqueue_next_desc(vq, i)) != vq->vring.num); + return input_iov_len_sum >= size; +} + int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) { unsigned int i, head, max; -- 1.6.2.5
next prev parent reply other threads:[~2009-10-29 3:12 UTC|newest] Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-10-28 19:22 qemu-kvm-0.11 regression, crashes on older guests with virtio network Dustin Kirkland 2009-10-28 19:22 ` [Qemu-devel] " Dustin Kirkland 2009-10-28 19:29 ` Dustin Kirkland 2009-10-28 19:29 ` [Qemu-devel] " Dustin Kirkland 2009-10-29 3:12 ` Scott Tsai [this message] 2009-10-29 3:12 ` [Qemu-devel] " Scott Tsai 2009-10-29 9:16 ` Mark McLoughlin 2009-10-29 9:16 ` Mark McLoughlin 2009-10-29 12:00 ` Scott Tsai 2009-10-29 12:00 ` Scott Tsai 2009-10-29 12:16 ` Mark McLoughlin 2009-10-29 12:16 ` Mark McLoughlin 2009-10-29 12:21 ` Scott Tsai 2009-10-29 12:21 ` Scott Tsai 2009-10-29 14:11 ` Anthony Liguori 2009-10-29 14:11 ` Anthony Liguori 2009-10-29 14:25 ` Mark McLoughlin 2009-10-29 14:25 ` Mark McLoughlin 2009-10-29 14:34 ` Dustin Kirkland 2009-10-29 14:34 ` Dustin Kirkland 2009-10-29 14:46 ` Dustin Kirkland 2009-10-29 14:46 ` Dustin Kirkland 2009-10-29 14:50 ` Mark McLoughlin 2009-10-29 14:50 ` Mark McLoughlin 2009-10-29 14:39 ` Anthony Liguori 2009-10-29 14:39 ` Anthony Liguori 2009-10-29 14:48 ` Mark McLoughlin 2009-10-29 14:48 ` Mark McLoughlin 2009-10-29 15:01 ` Dustin Kirkland 2009-10-29 15:01 ` Dustin Kirkland 2009-10-29 15:01 ` Mark McLoughlin 2009-10-29 15:01 ` Mark McLoughlin 2009-10-29 15:13 ` Dustin Kirkland 2009-10-29 15:13 ` Dustin Kirkland 2009-10-29 15:15 ` Mark McLoughlin 2009-10-29 15:15 ` Mark McLoughlin 2009-10-29 15:34 ` [PATCH] whitelist host virtio networking features [was Re: qemu-kvm-0.11 regression, crashes on older ...] Dustin Kirkland 2009-10-29 15:34 ` [Qemu-devel] " Dustin Kirkland 2009-10-30 21:15 ` Dustin Kirkland 2009-10-30 21:15 ` [Qemu-devel] " Dustin Kirkland 2009-11-02 14:38 ` Mark McLoughlin 2009-11-02 14:38 ` [Qemu-devel] " Mark McLoughlin 2009-11-02 15:42 ` Anthony Liguori 2009-11-02 15:42 ` [Qemu-devel] " Anthony Liguori 2009-11-02 15:52 ` Jamie Lokier 2009-11-02 18:20 ` Michael Tokarev 2009-11-02 18:20 ` Michael Tokarev 2009-11-02 19:39 ` Jamie Lokier 2009-11-02 19:39 ` Jamie Lokier 2009-11-02 18:55 ` Anthony Liguori 2009-11-02 19:25 ` Dustin Kirkland 2009-11-02 19:25 ` Dustin Kirkland 2009-11-02 20:50 ` Anthony Liguori 2009-11-02 20:50 ` Anthony Liguori 2009-11-05 5:06 ` Jamie Lokier 2009-11-05 5:06 ` Jamie Lokier 2009-11-02 16:58 ` Dustin Kirkland 2009-11-02 16:58 ` [Qemu-devel] " Dustin Kirkland 2009-10-29 14:39 ` [Qemu-devel] qemu-kvm-0.11 regression, crashes on older guests with virtio network Dustin Kirkland 2009-10-29 14:39 ` Dustin Kirkland 2009-10-29 23:22 ` Scott Tsai 2009-10-29 23:22 ` Scott Tsai 2009-10-29 12:23 ` Michael S. Tsirkin 2009-10-29 12:23 ` [Qemu-devel] " Michael S. Tsirkin 2009-10-29 14:38 ` Avi Kivity 2009-10-29 14:38 ` [Qemu-devel] " Avi Kivity 2009-10-29 15:03 ` Michael S. Tsirkin 2009-10-29 15:03 ` [Qemu-devel] " Michael S. Tsirkin 2009-10-29 14:43 ` [Qemu-devel] " Dustin Kirkland 2009-10-29 14:43 ` Dustin Kirkland
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1256785636-sup-215@xpc65.scottt \ --to=scottt.tw@gmail.com \ --cc=anthony@codemonkey.ws \ --cc=kirkland@canonical.com \ --cc=kvm@vger.kernel.org \ --cc=qemu-devel@nongnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.