diff mbox series

[kvmtool,03/24] virtio/vsock: Remove redundant state tracking

Message ID 20220607170239.120084-4-jean-philippe.brucker@arm.com (mailing list archive)
State New, archived
Headers show
Series Virtio v1 support | expand

Commit Message

Jean-Philippe Brucker June 7, 2022, 5:02 p.m. UTC
The core already tells us whether a device is being started or stopped.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 virtio/vsock.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/virtio/vsock.c b/virtio/vsock.c
index 64b4e95a..780169b1 100644
--- a/virtio/vsock.c
+++ b/virtio/vsock.c
@@ -31,7 +31,6 @@  struct vsock_dev {
 	struct virtio_device		vdev;
 	struct list_head		list;
 	struct kvm			*kvm;
-	bool				started;
 };
 
 static u8 *get_config(struct kvm *kvm, void *dev)
@@ -140,15 +139,16 @@  static void notify_status(struct kvm *kvm, void *dev, u32 status)
 	struct vsock_dev *vdev = dev;
 	int r, start;
 
-	start = !!(status & VIRTIO_CONFIG_S_DRIVER_OK);
-	if (vdev->started == start)
+	if (status & VIRTIO__STATUS_START)
+		start = 1;
+	else if (status & VIRTIO__STATUS_STOP)
+		start = 0;
+	else
 		return;
 
 	r = ioctl(vdev->vhost_fd, VHOST_VSOCK_SET_RUNNING, &start);
 	if (r != 0)
 		die("VHOST_VSOCK_SET_RUNNING failed %d", errno);
-
-	vdev->started = start;
 }
 
 static int notify_vq(struct kvm *kvm, void *dev, u32 vq)