[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 14/51] hw/virtio: add started_vu status field to vhost-user-gp
From: |
Juan Quintela |
Subject: |
[PATCH v2 14/51] hw/virtio: add started_vu status field to vhost-user-gpio |
Date: |
Mon, 5 Dec 2022 10:51:51 +0100 |
From: Alex Bennée <alex.bennee@linaro.org>
As per the fix to vhost-user-blk in f5b22d06fb (vhost: recheck dev
state in the vhost_migration_log routine) we really should track the
connection and starting separately.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20221130112439.2527228-4-alex.bennee@linaro.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/vhost-user-gpio.h | 10 ++++++++++
hw/virtio/vhost-user-gpio.c | 11 ++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/include/hw/virtio/vhost-user-gpio.h
b/include/hw/virtio/vhost-user-gpio.h
index 4fe9aeecc0..a9305c5e6c 100644
--- a/include/hw/virtio/vhost-user-gpio.h
+++ b/include/hw/virtio/vhost-user-gpio.h
@@ -28,7 +28,17 @@ struct VHostUserGPIO {
VhostUserState vhost_user;
VirtQueue *command_vq;
VirtQueue *interrupt_vq;
+ /**
+ * There are at least two steps of initialization of the
+ * vhost-user device. The first is a "connect" step and
+ * second is a "start" step. Make a separation between
+ * those initialization phases by using two fields.
+ *
+ * @connected: see vu_gpio_connect()/vu_gpio_disconnect()
+ * @started_vu: see vu_gpio_start()/vu_gpio_stop()
+ */
bool connected;
+ bool started_vu;
/*< public >*/
};
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index 0b40ebd15a..be9be08b4c 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -86,6 +86,7 @@ static int vu_gpio_start(VirtIODevice *vdev)
error_report("Error starting vhost-user-gpio: %d", ret);
goto err_guest_notifiers;
}
+ gpio->started_vu = true;
/*
* guest_notifier_mask/pending not used yet, so just unmask
@@ -126,16 +127,12 @@ static void vu_gpio_stop(VirtIODevice *vdev)
struct vhost_dev *vhost_dev = &gpio->vhost_dev;
int ret;
- if (!k->set_guest_notifiers) {
+ if (!gpio->started_vu) {
return;
}
+ gpio->started_vu = false;
- /*
- * We can call vu_gpio_stop multiple times, for example from
- * vm_state_notify and the final object finalisation. Check we
- * aren't already stopped before doing so.
- */
- if (!vhost_dev_is_started(vhost_dev)) {
+ if (!k->set_guest_notifiers) {
return;
}
--
2.38.1
- [PATCH v2 05/51] hw/display/qxl: Document qxl_phys2virt(), (continued)
- [PATCH v2 05/51] hw/display/qxl: Document qxl_phys2virt(), Juan Quintela, 2022/12/05
- [PATCH v2 06/51] hw/display/qxl: Pass requested buffer size to qxl_phys2virt(), Juan Quintela, 2022/12/05
- [PATCH v2 07/51] hw/display/qxl: Avoid buffer overrun in qxl_phys2virt (CVE-2022-4144), Juan Quintela, 2022/12/05
- [PATCH v2 08/51] hw/display/qxl: Assert memory slot fits in preallocated MemoryRegion, Juan Quintela, 2022/12/05
- [PATCH v2 09/51] block-backend: avoid bdrv_unregister_buf() NULL pointer deref, Juan Quintela, 2022/12/05
- [PATCH v2 10/51] target/arm: Set TCGCPUOps.restore_state_to_opc for v7m, Juan Quintela, 2022/12/05
- [PATCH v2 11/51] Update VERSION for v7.2.0-rc3, Juan Quintela, 2022/12/05
- [PATCH v2 12/51] tests/qtests: override "force-legacy" for gpio virtio-mmio tests, Juan Quintela, 2022/12/05
- [PATCH v2 13/51] vhost: enable vrings in vhost_dev_start() for vhost-user devices, Juan Quintela, 2022/12/05
- [PATCH v2 15/51] hw/virtio: generalise CHR_EVENT_CLOSED handling, Juan Quintela, 2022/12/05
- [PATCH v2 14/51] hw/virtio: add started_vu status field to vhost-user-gpio,
Juan Quintela <=
- [PATCH v2 16/51] include/hw: VM state takes precedence in virtio_device_should_start, Juan Quintela, 2022/12/05
- [PATCH v2 17/51] hw/nvme: fix aio cancel in format, Juan Quintela, 2022/12/05
- [PATCH v2 18/51] hw/nvme: fix aio cancel in flush, Juan Quintela, 2022/12/05
- [PATCH v2 19/51] hw/nvme: fix aio cancel in zone reset, Juan Quintela, 2022/12/05
- [PATCH v2 20/51] hw/nvme: fix aio cancel in dsm, Juan Quintela, 2022/12/05
- [PATCH v2 21/51] hw/nvme: remove copy bh scheduling, Juan Quintela, 2022/12/05
- [PATCH v2 23/51] target/i386: Always completely initialize TranslateFault, Juan Quintela, 2022/12/05
- [PATCH v2 22/51] target/i386: allow MMX instructions with CR4.OSFXSR=0, Juan Quintela, 2022/12/05
- [PATCH v2 24/51] hw/loongarch/virt: Add cfi01 pflash device, Juan Quintela, 2022/12/05
- [PATCH v2 25/51] tests/qtest/migration-test: Fix unlink error and memory leaks, Juan Quintela, 2022/12/05