Skip to contentSkip to conversation

virtio-net: stop vhost backend on vmstop

PATCH Superseded Michael S. Tsirkin 1 participant 1 message Jun 2, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-net: stop vhost backend on vmstop

vhost net currently keep running after vmstop, which causes trouble as qemy does not check for dirty pages anymore.
The fix is to simply keep vm and vhost running/stopped status in sync.

---
 hw/virtio-net.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
hw/virtio-net.c +5 -6
index cb664e6..6a9d560 100644
@@ -877,12 +877,11 @@ static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status)
 static void virtio_net_vmstate_change(void *opaque, int running, int reason)
 {
     VirtIONet *n = opaque;
-    if (!running) {
-        return;
-    }
-    /* This is called when vm is started, it will start vhost backend if
-     * appropriate e.g. after migration. */
-    virtio_net_set_status(&n->vdev, n->vdev.status);
+    uint8_t status = running ? VIRTIO_CONFIG_S_DRIVER_OK : 0;
+    /* This is called when vm is started/stopped,
+     * it will start/stop vhost backend if appropriate
+     * e.g. after migration. */
+    virtio_net_set_status(&n->vdev, n->vdev.status & status);
 }
 
 VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
Signature · 1 line
1.7.1.12.g42b7f