summaryrefslogtreecommitdiffstats
path: root/hw/virtio
diff options
context:
space:
mode:
authorAlex Bennée2022-08-02 11:49:59 +0200
committerMichael S. Tsirkin2022-10-07 15:41:51 +0200
commitb8f3e6a18de6ad5cb668c5430b4933f1e40783cf (patch)
tree5dae60d01c48a72924737b17221176a1020be804 /hw/virtio
parenthw/virtio: move vm_running check to virtio_device_started (diff)
downloadqemu-b8f3e6a18de6ad5cb668c5430b4933f1e40783cf.tar.gz
qemu-b8f3e6a18de6ad5cb668c5430b4933f1e40783cf.tar.xz
qemu-b8f3e6a18de6ad5cb668c5430b4933f1e40783cf.zip
hw/virtio: move vhd->started check into helper and add FIXME
The `started` field is manipulated internally within the vhost code except for one place, vhost-user-blk via f5b22d06fb (vhost: recheck dev state in the vhost_migration_log routine). Mark that as a FIXME because it introduces a potential race. I think the referenced fix should be tracking its state locally. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220802095010.3330793-12-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Raphael Norwitz <raphael.norwittz@nutanix.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/vhost-user-fs.c3
-rw-r--r--hw/virtio/vhost-user-i2c.c4
-rw-r--r--hw/virtio/vhost-user-rng.c4
-rw-r--r--hw/virtio/vhost-user-vsock.c2
-rw-r--r--hw/virtio/vhost-vsock-common.c3
-rw-r--r--hw/virtio/vhost-vsock.c2
6 files changed, 10 insertions, 8 deletions
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index d2bebba785..ad0f91c607 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -20,6 +20,7 @@
#include "hw/virtio/virtio-bus.h"
#include "hw/virtio/virtio-access.h"
#include "qemu/error-report.h"
+#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-user-fs.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
@@ -124,7 +125,7 @@ static void vuf_set_status(VirtIODevice *vdev, uint8_t status)
VHostUserFS *fs = VHOST_USER_FS(vdev);
bool should_start = virtio_device_started(vdev, status);
- if (fs->vhost_dev.started == should_start) {
+ if (vhost_dev_is_started(&fs->vhost_dev) == should_start) {
return;
}
diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
index b930cf6d5e..bc58b6c0d1 100644
--- a/hw/virtio/vhost-user-i2c.c
+++ b/hw/virtio/vhost-user-i2c.c
@@ -95,7 +95,7 @@ static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status)
VHostUserI2C *i2c = VHOST_USER_I2C(vdev);
bool should_start = virtio_device_started(vdev, status);
- if (i2c->vhost_dev.started == should_start) {
+ if (vhost_dev_is_started(&i2c->vhost_dev) == should_start) {
return;
}
@@ -174,7 +174,7 @@ static void vu_i2c_disconnect(DeviceState *dev)
}
i2c->connected = false;
- if (i2c->vhost_dev.started) {
+ if (vhost_dev_is_started(&i2c->vhost_dev)) {
vu_i2c_stop(vdev);
}
}
diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index a9c1c4bc79..bc1f36c5ac 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -92,7 +92,7 @@ static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status)
VHostUserRNG *rng = VHOST_USER_RNG(vdev);
bool should_start = virtio_device_started(vdev, status);
- if (rng->vhost_dev.started == should_start) {
+ if (vhost_dev_is_started(&rng->vhost_dev) == should_start) {
return;
}
@@ -160,7 +160,7 @@ static void vu_rng_disconnect(DeviceState *dev)
rng->connected = false;
- if (rng->vhost_dev.started) {
+ if (vhost_dev_is_started(&rng->vhost_dev)) {
vu_rng_stop(vdev);
}
}
diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c
index 22c1616ebd..7b67e29d83 100644
--- a/hw/virtio/vhost-user-vsock.c
+++ b/hw/virtio/vhost-user-vsock.c
@@ -57,7 +57,7 @@ static void vuv_set_status(VirtIODevice *vdev, uint8_t status)
VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
bool should_start = virtio_device_started(vdev, status);
- if (vvc->vhost_dev.started == should_start) {
+ if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) {
return;
}
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
index 7394818e00..29b9ab4f72 100644
--- a/hw/virtio/vhost-vsock-common.c
+++ b/hw/virtio/vhost-vsock-common.c
@@ -14,6 +14,7 @@
#include "hw/virtio/virtio-access.h"
#include "qemu/error-report.h"
#include "hw/qdev-properties.h"
+#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-vsock.h"
#include "qemu/iov.h"
#include "monitor/monitor.h"
@@ -199,7 +200,7 @@ int vhost_vsock_common_pre_save(void *opaque)
* At this point, backend must be stopped, otherwise
* it might keep writing to memory.
*/
- assert(!vvc->vhost_dev.started);
+ assert(!vhost_dev_is_started(&vvc->vhost_dev));
return 0;
}
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index 8031c164a5..7dc3c73931 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -73,7 +73,7 @@ static void vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status)
bool should_start = virtio_device_started(vdev, status);
int ret;
- if (vvc->vhost_dev.started == should_start) {
+ if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) {
return;
}