[PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues

Wafer Xie posted 1 patch 3 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251029125001.15086-1-wafer@jaguarmicro.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>
hw/virtio/vhost-vdpa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues
Posted by Wafer Xie 3 months, 1 week ago
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)

Fixes: b6662cb7 ("vdpa: add vhost_vdpa->suspended parameter")

Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
---
 hw/virtio/vhost-vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7061b6e1a3..2d5e6aca74 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
         return 0;
     }
 
-    if (!v->suspended) {
+    if (!v->suspended && vhost_vdpa_first_dev(dev)) {
         /*
          * Cannot trust in value returned by device, let vhost recover used
          * idx from guest.
-- 
2.34.1
Re: [PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues
Posted by Eugenio Perez Martin 3 months ago
On Wed, Oct 29, 2025 at 1:50 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)
>
> Fixes: b6662cb7 ("vdpa: add vhost_vdpa->suspended parameter")
>
> Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
> ---
>  hw/virtio/vhost-vdpa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 7061b6e1a3..2d5e6aca74 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
>          return 0;
>      }
>
> -    if (!v->suspended) {
> +    if (!v->suspended && vhost_vdpa_first_dev(dev)) {

I'm sorry I missed this fix!

Good catch, thank you very much! But the right fix is to move
v->suspended to v->shared, and then all the vhost_vdpa devices cannot
have different suspended states.

Apart from that, please include the tag

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

In the patch description.

Thanks!

>          /*
>           * Cannot trust in value returned by device, let vhost recover used
>           * idx from guest.
> --
> 2.34.1
>
Re: [PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues
Posted by Michael S. Tsirkin 5 days, 15 hours ago
On Thu, Nov 06, 2025 at 09:04:46AM +0100, Eugenio Perez Martin wrote:
> On Wed, Oct 29, 2025 at 1:50 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)
> >
> > Fixes: b6662cb7 ("vdpa: add vhost_vdpa->suspended parameter")
> >
> > Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
> > ---
> >  hw/virtio/vhost-vdpa.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > index 7061b6e1a3..2d5e6aca74 100644
> > --- a/hw/virtio/vhost-vdpa.c
> > +++ b/hw/virtio/vhost-vdpa.c
> > @@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
> >          return 0;
> >      }
> >
> > -    if (!v->suspended) {
> > +    if (!v->suspended && vhost_vdpa_first_dev(dev)) {
> 
> I'm sorry I missed this fix!
> 
> Good catch, thank you very much! But the right fix is to move
> v->suspended to v->shared, and then all the vhost_vdpa devices cannot
> have different suspended states.
> 
> Apart from that, please include the tag
> 
> Fixes: 0bb302a9960a ("vdpa: add vhost_vdpa_suspend")
> 
> In the patch description.
> 
> Thanks!


Eugenio do you want to post the fix?

> >          /*
> >           * Cannot trust in value returned by device, let vhost recover used
> >           * idx from guest.
> > --
> > 2.34.1
> >


Re: [PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues
Posted by Eugenio Perez Martin 5 days, 15 hours ago
On Tue, Feb 3, 2026 at 2:40 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Thu, Nov 06, 2025 at 09:04:46AM +0100, Eugenio Perez Martin wrote:
> > On Wed, Oct 29, 2025 at 1:50 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)
> > >
> > > Fixes: b6662cb7 ("vdpa: add vhost_vdpa->suspended parameter")
> > >
> > > Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
> > > ---
> > >  hw/virtio/vhost-vdpa.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > > index 7061b6e1a3..2d5e6aca74 100644
> > > --- a/hw/virtio/vhost-vdpa.c
> > > +++ b/hw/virtio/vhost-vdpa.c
> > > @@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
> > >          return 0;
> > >      }
> > >
> > > -    if (!v->suspended) {
> > > +    if (!v->suspended && vhost_vdpa_first_dev(dev)) {
> >
> > I'm sorry I missed this fix!
> >
> > Good catch, thank you very much! But the right fix is to move
> > v->suspended to v->shared, and then all the vhost_vdpa devices cannot
> > have different suspended states.
> >
> > Apart from that, please include the tag
> >
> > Fixes: 0bb302a9960a ("vdpa: add vhost_vdpa_suspend")
> >
> > In the patch description.
> >
> > Thanks!
>
>
> Eugenio do you want to post the fix?
>

Wafer posted it some time ago, but I realize now it was posted with a
different subject:

https://mail.gnu.org/archive/html/qemu-devel/2025-11/msg02947.html
Re: [PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues
Posted by Michael S. Tsirkin 5 days, 13 hours ago
On Tue, Feb 03, 2026 at 02:56:19PM +0100, Eugenio Perez Martin wrote:
> On Tue, Feb 3, 2026 at 2:40 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Thu, Nov 06, 2025 at 09:04:46AM +0100, Eugenio Perez Martin wrote:
> > > On Wed, Oct 29, 2025 at 1:50 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)
> > > >
> > > > Fixes: b6662cb7 ("vdpa: add vhost_vdpa->suspended parameter")
> > > >
> > > > Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
> > > > ---
> > > >  hw/virtio/vhost-vdpa.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > > > index 7061b6e1a3..2d5e6aca74 100644
> > > > --- a/hw/virtio/vhost-vdpa.c
> > > > +++ b/hw/virtio/vhost-vdpa.c
> > > > @@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
> > > >          return 0;
> > > >      }
> > > >
> > > > -    if (!v->suspended) {
> > > > +    if (!v->suspended && vhost_vdpa_first_dev(dev)) {
> > >
> > > I'm sorry I missed this fix!
> > >
> > > Good catch, thank you very much! But the right fix is to move
> > > v->suspended to v->shared, and then all the vhost_vdpa devices cannot
> > > have different suspended states.
> > >
> > > Apart from that, please include the tag
> > >
> > > Fixes: 0bb302a9960a ("vdpa: add vhost_vdpa_suspend")
> > >
> > > In the patch description.
> > >
> > > Thanks!
> >
> >
> > Eugenio do you want to post the fix?
> >
> 
> Wafer posted it some time ago, but I realize now it was posted with a
> different subject:
> 
> https://mail.gnu.org/archive/html/qemu-devel/2025-11/msg02947.html


Oh right that one is tagged. Thanks!


Re: [PATCH] vdpa: fix cannot get vring base when stopping a vhost-vdpa device with multiple queues
Posted by Jason Wang 3 months ago
On Wed, Oct 29, 2025 at 8:50 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.

This looks like a bug, no?

> 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)
>
> Fixes: b6662cb7 ("vdpa: add vhost_vdpa->suspended parameter")
>
> Signed-off-by: Wafer Xie <wafer@jaguarmicro.com>
> ---
>  hw/virtio/vhost-vdpa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 7061b6e1a3..2d5e6aca74 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -1481,7 +1481,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
>          return 0;
>      }
>
> -    if (!v->suspended) {
> +    if (!v->suspended && vhost_vdpa_first_dev(dev)) {
>          /*
>           * Cannot trust in value returned by device, let vhost recover used
>           * idx from guest.
> --
> 2.34.1
>

Thanks