Skip to contentSkip to conversation

virtio: Change order of appling runstate to device and bus

RFC PATCH In review Anton Kuchin 2 participants 2 messages Dec 20, 2019 – Jan 6, 2020

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 virtio: Change order of appling runstate to device and bus

On transition to running first apply state to bus and then to device so device can access bus functions correctly. When going to stopped notify device first and then the bus.

---
 hw/virtio/virtio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio.c +2 -2
index 04716b5f6c..2ea2edba10 100644
@@ -3096,7 +3096,7 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
     bool backend_run = running && virtio_device_started(vdev, vdev->status);
     vdev->vm_running = running;
 
-    if (backend_run) {
+    if (!backend_run) {
         virtio_set_status(vdev, vdev->status);
     }
 
@@ -3104,7 +3104,7 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
         k->vmstate_change(qbus->parent, backend_run);
     }
 
-    if (!backend_run) {
+    if (backend_run) {
         virtio_set_status(vdev, vdev->status);
     }
 }
Signature · 1 line
2.20.1
#1 lore raw
Quoted 5 lines · Anton Kuchin

On transition to running first apply state to bus and then to device so device can access bus functions correctly. When going to stopped notify device first and then the bus.

I kind of like this but this has the potential to break lots of things. How was this tested?

Quoted 28 lines
---
 hw/virtio/virtio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio.c +2 -2
index 04716b5f6c..2ea2edba10 100644
@@ -3096,7 +3096,7 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
     bool backend_run = running && virtio_device_started(vdev, vdev->status);
     vdev->vm_running = running;
 
-    if (backend_run) {
+    if (!backend_run) {
         virtio_set_status(vdev, vdev->status);
     }
 
@@ -3104,7 +3104,7 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
         k->vmstate_change(qbus->parent, backend_run);
     }
 
-    if (!backend_run) {
+    if (backend_run) {
         virtio_set_status(vdev, vdev->status);
     }
 }
Signature · 1 line
2.20.1