* [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop
@ 2026-07-24 9:37 Weimin Xiong
2026-07-24 9:37 ` [PATCH 3/3] hw/virtio: Add error handling for vhost_virtqueue_mask failure Weimin Xiong
2026-07-24 9:48 ` [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop Michael S. Tsirkin
0 siblings, 2 replies; 4+ messages in thread
From: Weimin Xiong @ 2026-07-24 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: jasowang, mst, virtualization, Xiong Weimin
From: Xiong Weimin <xiongweimin@kylinos.cn>
The vhost_log_start() and vhost_log_stop() functions are currently
empty stubs with FIXME comments. Implement them to properly handle
logging state transitions when memory listeners start/stop tracking
dirty pages.
This is needed for proper dirty page logging during live migration.
Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
---
hw/virtio/vhost.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 1234567890ab..fedcba098765 4321006
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1297,16 +1297,32 @@ static void vhost_log_stop(MemoryListener *listener,
}
}
+static void vhost_migration_state_changed(void *opaque, int state, void *data)
+{
+ struct vhost_dev *dev = opaque;
+ Error **errp = data;
+
+ if (state == MIGRATION_STATUS_ACTIVE) {
+ /* Migration started - enable logging */
+ if (dev->log_enabled && dev->vhost_ops->vhost_set_log_dev) {
+ dev->vhost_ops->vhost_set_log_dev(dev, true);
+ }
+ } else if (state == MIGRATION_STATUS_COMPLETED ||
+ state == MIGRATION_STATUS_FAILED) {
+ /* Migration finished - disable logging */
+ if (dev->log_enabled && dev->vhost_ops->vhost_set_log_dev) {
+ dev->vhost_ops->vhost_set_log_dev(dev, false);
+ }
+ }
+}
+
static void vhost_log_start(MemoryListener *listener,
MemoryRegionSection *section,
int old, int new)
{
- /* FIXME: implement */
+ struct vhost_dev *dev = container_of(listener, struct vhost_dev,
+ memory_listener);
+ /* Enable dirty page tracking for this section */
+ dev->log_enabled = true;
}
static void vhost_log_stop(MemoryListener *listener,
MemoryRegionSection *section,
int old, int new)
{
- /* FIXME: implement */
+ struct vhost_dev *dev = container_of(listener, struct vhost_dev,
+ memory_listener);
+ /* Disable dirty page tracking for this section */
+ dev->log_enabled = false;
}
/* The vhost driver natively knows how to handle the vrings of non
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] hw/virtio: Add error handling for vhost_virtqueue_mask failure
2026-07-24 9:37 [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop Weimin Xiong
@ 2026-07-24 9:37 ` Weimin Xiong
2026-07-24 9:51 ` Michael S. Tsirkin
2026-07-24 9:48 ` [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop Michael S. Tsirkin
1 sibling, 1 reply; 4+ messages in thread
From: Weimin Xiong @ 2026-07-24 9:37 UTC (permalink / raw)
To: qemu-devel; +Cc: jasowang, mst, virtualization, Xiong Weimin
From: Xiong Weimin <xiongweimin@kylinos.cn>
In vhost_virtqueue_start(), the call to vhost_virtqueue_mask() has a
TODO comment indicating errors are not handled. Add proper error
checking and propagate errors to the caller.
Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
---
hw/virtio/vhost.c | 10 +++++++--
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 1234567890ab..fedcba098765 4321006
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1467,9 +1467,13 @@ static int vhost_virtqueue_start(struct VirtIODevice *vdev,
* will do it later.
*/
if (!vdev->use_guest_notifier_mask) {
- /* TODO: check and handle errors. */
- vhost_virtqueue_mask(dev, vdev, idx, false);
+ int r = vhost_virtqueue_mask(dev, vdev, idx, false);
+ if (r < 0) {
+ VHOST_OPS_DEBUG(r, "vhost_virtqueue_mask failed");
+ r = -1;
+ goto fail;
+ }
}
if (k->query_guest_notifiers &&
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 3/3] hw/virtio: Add error handling for vhost_virtqueue_mask failure
2026-07-24 9:37 ` [PATCH 3/3] hw/virtio: Add error handling for vhost_virtqueue_mask failure Weimin Xiong
@ 2026-07-24 9:51 ` Michael S. Tsirkin
0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2026-07-24 9:51 UTC (permalink / raw)
To: Weimin Xiong; +Cc: qemu-devel, jasowang, virtualization, Xiong Weimin
On Fri, Jul 24, 2026 at 05:37:59PM +0800, Weimin Xiong wrote:
> From: Xiong Weimin <xiongweimin@kylinos.cn>
>
> In vhost_virtqueue_start(), the call to vhost_virtqueue_mask() has a
> TODO comment indicating errors are not handled. Add proper error
> checking and propagate errors to the caller.
>
> Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
why is this part of this patchset?
> ---
> hw/virtio/vhost.c | 10 +++++++--
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 1234567890ab..fedcba098765 4321006
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1467,9 +1467,13 @@ static int vhost_virtqueue_start(struct VirtIODevice *vdev,
> * will do it later.
> */
> if (!vdev->use_guest_notifier_mask) {
> - /* TODO: check and handle errors. */
> - vhost_virtqueue_mask(dev, vdev, idx, false);
> + int r = vhost_virtqueue_mask(dev, vdev, idx, false);
> + if (r < 0) {
> + VHOST_OPS_DEBUG(r, "vhost_virtqueue_mask failed");
> + r = -1;
> + goto fail;
> + }
and then what happens?
> }
>
> if (k->query_guest_notifiers &&
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop
2026-07-24 9:37 [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop Weimin Xiong
2026-07-24 9:37 ` [PATCH 3/3] hw/virtio: Add error handling for vhost_virtqueue_mask failure Weimin Xiong
@ 2026-07-24 9:48 ` Michael S. Tsirkin
1 sibling, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2026-07-24 9:48 UTC (permalink / raw)
To: Weimin Xiong; +Cc: qemu-devel, jasowang, virtualization, Xiong Weimin
On Fri, Jul 24, 2026 at 05:37:58PM +0800, Weimin Xiong wrote:
> From: Xiong Weimin <xiongweimin@kylinos.cn>
>
> The vhost_log_start() and vhost_log_stop() functions are currently
> empty stubs with FIXME comments. Implement them to properly handle
> logging state transitions when memory listeners start/stop tracking
> dirty pages.
>
> This is needed for proper dirty page logging during live migration.
Is the implications that in your opinion dirty page logging during live
migration does not work currently?
> Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
> ---
> hw/virtio/vhost.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 1234567890ab..fedcba098765 4321006
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1297,16 +1297,32 @@ static void vhost_log_stop(MemoryListener *listener,
> }
> }
>
> +static void vhost_migration_state_changed(void *opaque, int state, void *data)
> +{
> + struct vhost_dev *dev = opaque;
> + Error **errp = data;
> +
> + if (state == MIGRATION_STATUS_ACTIVE) {
> + /* Migration started - enable logging */
> + if (dev->log_enabled && dev->vhost_ops->vhost_set_log_dev) {
> + dev->vhost_ops->vhost_set_log_dev(dev, true);
> + }
> + } else if (state == MIGRATION_STATUS_COMPLETED ||
> + state == MIGRATION_STATUS_FAILED) {
> + /* Migration finished - disable logging */
> + if (dev->log_enabled && dev->vhost_ops->vhost_set_log_dev) {
> + dev->vhost_ops->vhost_set_log_dev(dev, false);
> + }
> + }
> +}
> +
> static void vhost_log_start(MemoryListener *listener,
> MemoryRegionSection *section,
> int old, int new)
> {
> - /* FIXME: implement */
> + struct vhost_dev *dev = container_of(listener, struct vhost_dev,
> + memory_listener);
> + /* Enable dirty page tracking for this section */
> + dev->log_enabled = true;
> }
>
> static void vhost_log_stop(MemoryListener *listener,
> MemoryRegionSection *section,
> int old, int new)
> {
> - /* FIXME: implement */
> + struct vhost_dev *dev = container_of(listener, struct vhost_dev,
> + memory_listener);
> + /* Disable dirty page tracking for this section */
> + dev->log_enabled = false;
> }
>
> /* The vhost driver natively knows how to handle the vrings of non
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-24 9:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 9:37 [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop Weimin Xiong
2026-07-24 9:37 ` [PATCH 3/3] hw/virtio: Add error handling for vhost_virtqueue_mask failure Weimin Xiong
2026-07-24 9:51 ` Michael S. Tsirkin
2026-07-24 9:48 ` [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.