Blame SOURCES/kvm-virtio-net-don-t-touch-virtqueue-if-vm-is-stopped.patch

4a2fec
From d7c69df61c216de014aca9d1eafc94ddb81ce5bb Mon Sep 17 00:00:00 2001
4a2fec
From: Xiao Wang <jasowang@redhat.com>
4a2fec
Date: Wed, 29 Nov 2017 07:39:51 +0100
4a2fec
Subject: [PATCH 17/21] virtio-net: don't touch virtqueue if vm is stopped
4a2fec
4a2fec
RH-Author: Xiao Wang <jasowang@redhat.com>
4a2fec
Message-id: <1511941191-30204-1-git-send-email-jasowang@redhat.com>
4a2fec
Patchwork-id: 77949
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH] virtio-net: don't touch virtqueue if vm is stopped
4a2fec
Bugzilla: 1506151
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
4a2fec
RH-Acked-by: wexu@redhat.com
4a2fec
4a2fec
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1506151
4a2fec
Brew Build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=14645237
4a2fec
Test status: Tested by myself
4a2fec
4a2fec
Guest state should not be touched if VM is stopped, unfortunately we
4a2fec
didn't check running state and tried to drain tx queue unconditionally
4a2fec
in virtio_net_set_status(). A crash was then noticed as a migration
4a2fec
destination when user type quit after virtqueue state is loaded but
4a2fec
before region cache is initialized. In this case,
4a2fec
virtio_net_drop_tx_queue_data() tries to access the uninitialized
4a2fec
region cache.
4a2fec
4a2fec
Fix this by only dropping tx queue data when vm is running.
4a2fec
4a2fec
Fixes: 283e2c2adcb80 ("net: virtio-net discards TX data after link down")
4a2fec
Cc: Yuri Benditovich <yuri.benditovich@daynix.com>
4a2fec
Cc: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
Cc: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Cc: Michael S. Tsirkin <mst@redhat.com>
4a2fec
Cc: qemu-stable@nongnu.org
4a2fec
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Jason Wang <jasowang@redhat.com>
4a2fec
(cherry picked from commit 70e53e6e4da3db4b2c31981191753a7e974936d0)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/net/virtio-net.c | 3 ++-
4a2fec
 1 file changed, 2 insertions(+), 1 deletion(-)
4a2fec
4a2fec
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
4a2fec
index 148071a..fbc5e1b 100644
4a2fec
--- a/hw/net/virtio-net.c
4a2fec
+++ b/hw/net/virtio-net.c
4a2fec
@@ -288,7 +288,8 @@ static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status)
4a2fec
                 qemu_bh_cancel(q->tx_bh);
4a2fec
             }
4a2fec
             if ((n->status & VIRTIO_NET_S_LINK_UP) == 0 &&
4a2fec
-                (queue_status & VIRTIO_CONFIG_S_DRIVER_OK)) {
4a2fec
+                (queue_status & VIRTIO_CONFIG_S_DRIVER_OK) &&
4a2fec
+                vdev->vm_running) {
4a2fec
                 /* if tx is waiting we are likely have some packets in tx queue
4a2fec
                  * and disabled notification */
4a2fec
                 q->tx_waiting = 0;
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec