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>
return;
}
- if (s->dev.started == should_start) {
+ if (vhost_dev_is_started(&s->dev) == should_start) {
return;
}
return;
}
- if (s->dev.started) {
+ if (vhost_dev_is_started(&s->dev)) {
return;
}
* the vhost migration code. If disconnect was caught there is an
* option for the general vhost code to get the dev state without
* knowing its type (in this case vhost-user).
+ *
+ * FIXME: this is sketchy to be reaching into vhost_dev
+ * now because we are forcing something that implies we
+ * have executed vhost_dev_stop() but that won't happen
+ * until vhost_user_blk_stop() gets called from the bh.
+ * Really this state check should be tracked locally.
*/
s->dev.started = false;
}
start = false;
}
- if (vsc->dev.started == start) {
+ if (vhost_dev_is_started(&vsc->dev) == start) {
return;
}
/* At this point, backend must be stopped, otherwise
* it might keep writing to memory. */
- assert(!vsc->dev.started);
+ assert(!vhost_dev_is_started(&vsc->dev));
return 0;
}
VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
bool start = (status & VIRTIO_CONFIG_S_DRIVER_OK) && vdev->vm_running;
- if (vsc->dev.started == start) {
+ if (vhost_dev_is_started(&vsc->dev) == start) {
return;
}
#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"
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;
}
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;
}
}
i2c->connected = false;
- if (i2c->vhost_dev.started) {
+ if (vhost_dev_is_started(&i2c->vhost_dev)) {
vu_i2c_stop(vdev);
}
}
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;
}
rng->connected = false;
- if (rng->vhost_dev.started) {
+ if (vhost_dev_is_started(&rng->vhost_dev)) {
vu_rng_stop(vdev);
}
}
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;
}
#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"
* 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;
}
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;
}
uint64_t protocol_features;
uint64_t max_queues;
uint64_t backend_cap;
+ /* @started: is the vhost device started? */
bool started;
bool log_enabled;
uint64_t log_size;
*/
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
+/**
+ * vhost_dev_is_started() - report status of vhost device
+ * @hdev: common vhost_dev structure
+ *
+ * Return the started status of the vhost device
+ */
+static inline bool vhost_dev_is_started(struct vhost_dev *hdev)
+{
+ return hdev->started;
+}
+
/**
* vhost_dev_start() - start the vhost device
* @hdev: common vhost_dev structure