diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-09-02 17:26:12 +0300 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-09-04 17:19:09 +0100 |
commit | e8bcf842001739765b8dcc1996d86a0ffd2054d5 (patch) | |
tree | 3a1806f01f96a7111c91eb3ff0228eeac423ef0d /hw/net/virtio-net.c | |
parent | e1d64c084b2cc7e907b4e64026d8c8dba59116f8 (diff) | |
download | qemu-e8bcf842001739765b8dcc1996d86a0ffd2054d5.zip qemu-e8bcf842001739765b8dcc1996d86a0ffd2054d5.tar.gz qemu-e8bcf842001739765b8dcc1996d86a0ffd2054d5.tar.bz2 |
virtio-net: don't run bh on vm stopped
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>
Diffstat (limited to 'hw/net/virtio-net.c')
-rw-r--r-- | hw/net/virtio-net.c | 14 |
1 files 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; |