diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-09-02 16:12:41 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-09-02 17:28:26 +0300 |
commit | 0187c7989a5cedd4f88bba76839cc9c44fb3fc81 (patch) | |
tree | 58cb5174a6b8ff47b8317b12f4e9938e1ea73bcf /hw/net | |
parent | fc8342f7589f0ef026cfebf8d6e5eab88323c7cf (diff) | |
download | hqemu-0187c7989a5cedd4f88bba76839cc9c44fb3fc81.zip hqemu-0187c7989a5cedd4f88bba76839cc9c44fb3fc81.tar.gz |
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>
Diffstat (limited to 'hw/net')
-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; |