summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlex Bennée2022-08-02 11:49:58 +0200
committerMichael S. Tsirkin2022-10-07 15:41:51 +0200
commit9f6bcfd99f46377888059d8539befec9505f57fb (patch)
tree7ebee167ba59b63f6c9058217b0f86c1336cd547 /include
parenthw/virtio: add some vhost-user trace events (diff)
downloadqemu-9f6bcfd99f46377888059d8539befec9505f57fb.tar.gz
qemu-9f6bcfd99f46377888059d8539befec9505f57fb.tar.xz
qemu-9f6bcfd99f46377888059d8539befec9505f57fb.zip
hw/virtio: move vm_running check to virtio_device_started
All the boilerplate virtio code does the same thing (or should at least) of checking to see if the VM is running before attempting to start VirtIO. Push the logic up to the common function to avoid getting a copy and paste wrong. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220802095010.3330793-11-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/hw/virtio/virtio.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 9bb2485415..74e7ad5a92 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -100,6 +100,7 @@ struct VirtIODevice
VirtQueue *vq;
MemoryListener listener;
uint16_t device_id;
+ /* @vm_running: current VM running state via virtio_vmstate_change() */
bool vm_running;
bool broken; /* device in invalid state, needs reset */
bool use_disabled_flag; /* allow use of 'disable' flag when needed */
@@ -376,6 +377,10 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status)
return vdev->started;
}
+ if (!vdev->vm_running) {
+ return false;
+ }
+
return status & VIRTIO_CONFIG_S_DRIVER_OK;
}