qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-stable@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PULL 3/7] virtio-net: don't run bh on vm stopped
Date: Thu,  4 Sep 2014 16:50:07 +0100	[thread overview]
Message-ID: <1409845811-27943-4-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1409845811-27943-1-git-send-email-stefanha@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>

commit 783e7706937fe15523b609b545587a028a2bdd03
    virtio-net: stop/start bh when appropriate

is incomplete: BH might execute within the same main loop iteration but
after vmstop, so in theory, we might trigger an assertion.
I was unable to reproduce this in practice,
but it seems clear enough that the potential is there, so worth fixing.

Cc: qemu-stable@nongnu.org
Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/net/virtio-net.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 268eff9..365e266 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1224,7 +1224,12 @@ static void virtio_net_tx_timer(void *opaque)
     VirtIONetQueue *q = opaque;
     VirtIONet *n = q->n;
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
-    assert(vdev->vm_running);
+    /* This happens when device was stopped but BH wasn't. */
+    if (!vdev->vm_running) {
+        /* Make sure tx waiting is set, so we'll run when restarted. */
+        assert(q->tx_waiting);
+        return;
+    }
 
     q->tx_waiting = 0;
 
@@ -1244,7 +1249,12 @@ static void virtio_net_tx_bh(void *opaque)
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     int32_t ret;
 
-    assert(vdev->vm_running);
+    /* This happens when device was stopped but BH wasn't. */
+    if (!vdev->vm_running) {
+        /* Make sure tx waiting is set, so we'll run when restarted. */
+        assert(q->tx_waiting);
+        return;
+    }
 
     q->tx_waiting = 0;
 
-- 
1.9.3

  parent reply	other threads:[~2014-09-04 15:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04 15:50 [Qemu-devel] [PULL 0/7] Net patches Stefan Hajnoczi
2014-09-04 15:50 ` [Qemu-devel] [PULL 1/7] net: Forbid dealing with packets when VM is not running Stefan Hajnoczi
2014-09-04 15:50 ` [Qemu-devel] [PULL 2/7] net: don't use set/get_pointer() in set/get_netdev() Stefan Hajnoczi
2014-09-04 15:50 ` Stefan Hajnoczi [this message]
2014-09-04 15:50 ` [Qemu-devel] [PULL 4/7] virtio: don't call device on !vm_running Stefan Hajnoczi
2014-09-04 15:50 ` [Qemu-devel] [PULL 5/7] net: invoke callback when purging queue Stefan Hajnoczi
2014-09-04 15:50 ` [Qemu-devel] [PULL 6/7] net: complete all queued packets on VM stop Stefan Hajnoczi
2014-09-09  6:05   ` Jason Wang
2014-09-04 15:50 ` [Qemu-devel] [PULL 7/7] virtio-net: purge outstanding packets when starting vhost Stefan Hajnoczi

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=1409845811-27943-4-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).