qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] vdpa: fix vhost-vdpa suspended state not be shared
@ 2025-11-07  7:07 Wafer Xie
  2025-11-07  7:12 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Wafer Xie @ 2025-11-07  7:07 UTC (permalink / raw)
  To: eperezma, mst, qemu-devel; +Cc: jasowang, angus.chen, wafer

When stopping a vhost-vdpa device, only the first queue pair is marked as suspended,
while the remaining queues are not updated to the suspended state.
As a result, when stopping a multi-queue vhost-vdpa device,
the following error message will be printed.

qemu-system-x86_64:vhost VQ 2 ring restore failed: -1: Operation not permitted (1)

qemu-system-x86_64:vhost VQ 3 ring restore failed: -1: Operation not permitted (1)

So move v->suspended to v->shared, and then all the vhost_vdpa devices cannot
have different suspended states.

Fixes: 0bb302a9960a ("vdpa: add vhost_vdpa_suspend")

Suggested-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>

--
Changes in v3:
 -Update comments and add Acked-by

Changes in v2:
 -Move v->suspended to v->shared
--
---
 hw/virtio/vhost-vdpa.c         | 6 +++---
 include/hw/virtio/vhost-vdpa.h | 8 ++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7061b6e1a3..2f8f11df86 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -905,7 +905,7 @@ static int vhost_vdpa_reset_device(struct vhost_dev *dev)
 
     memory_listener_unregister(&v->shared->listener);
     v->shared->listener_registered = false;
-    v->suspended = false;
+    v->shared->suspended = false;
     return 0;
 }
 
@@ -1354,7 +1354,7 @@ static void vhost_vdpa_suspend(struct vhost_dev *dev)
         if (unlikely(r)) {
             error_report("Cannot suspend: %s(%d)", g_strerror(errno), errno);
         } else {
-            v->suspended = true;
+            v->shared->suspended = true;
             return;
         }
     }
@@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
         return 0;
     }
 
-    if (!v->suspended) {
+    if (!v->shared->suspended) {
         /*
          * Cannot trust in value returned by device, let vhost recover used
          * idx from guest.
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 449bf5c840..80ff670e23 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -76,6 +76,12 @@ typedef struct vhost_vdpa_shared {
 
     /* SVQ switching is in progress, or already completed? */
     SVQTransitionState svq_switching;
+
+    /*
+     * Device suspended successfully.
+     * The vhost_vdpa devices cannot have different suspended states.
+     */
+    bool suspended;
 } VhostVDPAShared;
 
 typedef struct vhost_vdpa {
@@ -83,8 +89,6 @@ typedef struct vhost_vdpa {
     uint32_t address_space_id;
     uint64_t acked_features;
     bool shadow_vqs_enabled;
-    /* Device suspended successfully */
-    bool suspended;
     VhostVDPAShared *shared;
     GPtrArray *shadow_vqs;
     const VhostShadowVirtqueueOps *shadow_vq_ops;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] vdpa: fix vhost-vdpa suspended state not be shared
  2025-11-07  7:07 [PATCH v3] vdpa: fix vhost-vdpa suspended state not be shared Wafer Xie
@ 2025-11-07  7:12 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2025-11-07  7:12 UTC (permalink / raw)
  To: Wafer Xie; +Cc: eperezma, mst, qemu-devel, angus.chen

On Fri, Nov 7, 2025 at 3:08 PM Wafer Xie <wafer@jaguarmicro.com> wrote:
>
> When stopping a vhost-vdpa device, only the first queue pair is marked as suspended,
> while the remaining queues are not updated to the suspended state.
> As a result, when stopping a multi-queue vhost-vdpa device,
> the following error message will be printed.
>
> qemu-system-x86_64:vhost VQ 2 ring restore failed: -1: Operation not permitted (1)
>
> qemu-system-x86_64:vhost VQ 3 ring restore failed: -1: Operation not permitted (1)
>
> So move v->suspended to v->shared, and then all the vhost_vdpa devices cannot
> have different suspended states.
>
> Fixes: 0bb302a9960a ("vdpa: add vhost_vdpa_suspend")
>
> Suggested-by: Eugenio Pérez <eperezma@redhat.com>
> Acked-by: Eugenio Pérez <eperezma@redhat.com>
> Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
>

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-07  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07  7:07 [PATCH v3] vdpa: fix vhost-vdpa suspended state not be shared Wafer Xie
2025-11-07  7:12 ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).