From: "Michael S. Tsirkin" <mst@redhat.com>
To: Weimin Xiong <xiongwm2026@163.com>
Cc: qemu-devel@nongnu.org, jasowang@redhat.com,
virtualization@lists.linux.dev,
Xiong Weimin <xiongweimin@kylinos.cn>
Subject: Re: [PATCH 2/3] hw/virtio: Implement vhost_log_start and vhost_log_stop
Date: Fri, 24 Jul 2026 05:48:26 -0400 [thread overview]
Message-ID: <20260724054712-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20260724093759.810108-1-xiongwm2026@163.com>
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
prev parent reply other threads:[~2026-07-24 9:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Michael S. Tsirkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724054712-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtualization@lists.linux.dev \
--cc=xiongweimin@kylinos.cn \
--cc=xiongwm2026@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox