virtio-net: don't run bh on vm stopped
PATCH 1/1 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.
--- hw/net/virtio-net.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
hw/net/virtio-net.c +12 -2
@@ -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 ;
Signature · 1 line
MST
Stefan Hajnoczi
AppliedQuoted 8 lines · Michael S. Tsirkin
commit
783e7706937fe15523b609b545587a028a2bdd03
virtio-net: stop/start bh when appropriateis 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.
Quoted 6 lines
Reported-by Stefan Hajnoczi <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/net/virtio-net.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Stefan
Quoted 16 lines · Stefan Hajnoczi
Quoted 8 lines · Michael S. Tsirkin
commit
783e7706937fe15523b609b545587a028a2bdd03
virtio-net: stop/start bh when appropriateis 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.Quoted 6 lines
Reported-by Stefan Hajnoczi <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/net/virtio-net.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Quoted 4 lines
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/netStefan
It was actually on my tree already but since I recalled my last pull request, no problem. Can you send pull request with this today please, so it can go into 2.1.1?