[PATCH] vhost: Do not actively send a config interrupt

Li Zhaoxin via posted 1 patch 4 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/19ac5fa24777515f9f0878e6874dc9f6edec45a3.1758552835.git.lizhaoxin04@baidu.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>
hw/virtio/vhost.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
[PATCH] vhost: Do not actively send a config interrupt
Posted by Li Zhaoxin via 4 months, 2 weeks ago
From: lizhaoxin <lizhaoxin04@baidu.com>

After the VM is suspended/resumed or live-migrated,
we do not want the guest to output information such as
the capacity of the block device, as this is noticeable to the tenant.
Also, there is no need to immediately send a config notifier
for the virtio device after vhost_dev_start.

Co-developed-by: Gao Shiyuan <gaoshiyuan@baidu.com>
Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
Signed-off-by: Li Zhaoxin <lizhaoxin04@baidu.com>
---
 hw/virtio/vhost.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6557c58d12..1f8a495ef8 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1847,15 +1847,10 @@ static void vhost_stop_config_intr(struct vhost_dev *dev)
 
 static void vhost_start_config_intr(struct vhost_dev *dev)
 {
-    int r;
-
     assert(dev->vhost_ops);
     int fd = event_notifier_get_fd(&dev->vdev->config_notifier);
     if (dev->vhost_ops->vhost_set_config_call) {
-        r = dev->vhost_ops->vhost_set_config_call(dev, fd);
-        if (!r) {
-            event_notifier_set(&dev->vdev->config_notifier);
-        }
+        dev->vhost_ops->vhost_set_config_call(dev, fd);
     }
 }
 
-- 
2.34.1
Re: [PATCH] vhost: Do not actively send a config interrupt
Posted by Michael S. Tsirkin 5 days, 18 hours ago
On Mon, Sep 22, 2025 at 11:19:32PM +0800, Li Zhaoxin wrote:
> From: lizhaoxin <lizhaoxin04@baidu.com>
> 
> After the VM is suspended/resumed or live-migrated,
> we do not want the guest to output information such as
> the capacity of the block device, as this is noticeable to the tenant.
> Also, there is no need to immediately send a config notifier
> for the virtio device after vhost_dev_start.
> 
> Co-developed-by: Gao Shiyuan <gaoshiyuan@baidu.com>
> Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
> Signed-off-by: Li Zhaoxin <lizhaoxin04@baidu.com>

Just to close the circle and complete the picture for you here, the reason we do it
is because with vhost
source could have queued an interrupt and the state is
not migrated.

if you want to optimize this, you need to check on source and
migrate the extra state.



> ---
>  hw/virtio/vhost.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 6557c58d12..1f8a495ef8 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1847,15 +1847,10 @@ static void vhost_stop_config_intr(struct vhost_dev *dev)
>  
>  static void vhost_start_config_intr(struct vhost_dev *dev)
>  {
> -    int r;
> -
>      assert(dev->vhost_ops);
>      int fd = event_notifier_get_fd(&dev->vdev->config_notifier);
>      if (dev->vhost_ops->vhost_set_config_call) {
> -        r = dev->vhost_ops->vhost_set_config_call(dev, fd);
> -        if (!r) {
> -            event_notifier_set(&dev->vdev->config_notifier);
> -        }
> +        dev->vhost_ops->vhost_set_config_call(dev, fd);
>      }
>  }
>  
> -- 
> 2.34.1
Re: [PATCH] vhost: Do not actively send a config interrupt
Posted by Stefano Garzarella 4 months, 2 weeks ago
CCing Cindy since she introduced this code with commit
f9a09ca3ea ("vhost: add support for configure interrupt"), so she can 
help to review this, since I don't really get this change.

On Mon, Sep 22, 2025 at 11:19:32PM +0800, Li Zhaoxin wrote:
>From: lizhaoxin <lizhaoxin04@baidu.com>
>
>After the VM is suspended/resumed or live-migrated,
>we do not want the guest to output information such as
>the capacity of the block device, as this is noticeable to the tenant.
>Also, there is no need to immediately send a config notifier
>for the virtio device after vhost_dev_start.

Can you explain more clearly what your problem is and why this patch 
solves it?

Thanks,
Stefano

>
>Co-developed-by: Gao Shiyuan <gaoshiyuan@baidu.com>
>Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
>Signed-off-by: Li Zhaoxin <lizhaoxin04@baidu.com>
>---
> hw/virtio/vhost.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
>diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>index 6557c58d12..1f8a495ef8 100644
>--- a/hw/virtio/vhost.c
>+++ b/hw/virtio/vhost.c
>@@ -1847,15 +1847,10 @@ static void vhost_stop_config_intr(struct vhost_dev *dev)
>
> static void vhost_start_config_intr(struct vhost_dev *dev)
> {
>-    int r;
>-
>     assert(dev->vhost_ops);
>     int fd = event_notifier_get_fd(&dev->vdev->config_notifier);
>     if (dev->vhost_ops->vhost_set_config_call) {
>-        r = dev->vhost_ops->vhost_set_config_call(dev, fd);
>-        if (!r) {
>-            event_notifier_set(&dev->vdev->config_notifier);
>-        }
>+        dev->vhost_ops->vhost_set_config_call(dev, fd);
>     }
> }
>
>-- 
>2.34.1
>