From: "Zhu, Lingshan" <lingshan.zhu@intel.com>
To: Jason Wang <jasowang@redhat.com>,
Eugenio Perez Martin <eperezma@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] vdpa: dont check vhost_vdpa->suspended when unsupported
Date: Fri, 9 Jun 2023 16:49:00 +0800 [thread overview]
Message-ID: <3c623e34-fbd2-03fb-e88a-d8d23feee4ad@intel.com> (raw)
In-Reply-To: <CACGkMEvsX0=QsrbjgHVxZ9BAz4b+64waErtvX6bZcPcgpJV-pg@mail.gmail.com>
On 6/9/2023 11:13 AM, Jason Wang wrote:
> On Wed, Jun 7, 2023 at 11:37 PM Eugenio Perez Martin
> <eperezma@redhat.com> wrote:
>> On Wed, Jun 7, 2023 at 11:09 AM Zhu Lingshan <lingshan.zhu@intel.com> wrote:
>>> When read the state of a virtqueue, vhost_vdpa need
>>> to check whether the device is suspended.
>>>
>>> This commit verifies whether VHOST_BACKEND_F_SUSPEND is
>>> negotiated when checking vhost_vdpa->suspended.
>>>
>> I'll add: Otherwise, qemu prints XXX error message.
>>
>> On second thought, not returning an error prevents the caller
>> (vhost.c:vhost_virtqueue_stop) from recovering used idx from the
>> guest.
>>
>> I'm not sure about the right fix for this, should we call
>> virtio_queue_restore_last_avail_idx here?
> It should be the duty of the caller:
>
> E.g in vhost_virtqueue_stop() we had:
>
> => r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
> if (r < 0) {
> VHOST_OPS_DEBUG(r, "vhost VQ %u ring restore failed: %d", idx, r);
> /* Connection to the backend is broken, so let's sync internal
> * last avail idx to the device used idx.
> */
> virtio_queue_restore_last_avail_idx(vdev, idx);
> } else {
> virtio_queue_set_last_avail_idx(vdev, idx, state.num);
I agree call virtio_queue_restore_last_avail_idx here in the caller is
better. However I found this debug message is confused:
_get_vring_base() read the queue state, it does not restore anything,
and if failed to read the queue state, it invokes
virtio_queue_restore_last_avail_idx()
to recover, still works, handled the problem internally.
So how about we remove this debug message or change it to:
restore last_avail_idx of vhost vq N from vring used_idx.
Thanks
>
> Thansk
>
>> Communicate that the backend
>> cannot suspend so vhost.c can print a better error message?
>>
>> Thanks!
>>
>>> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.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 b3094e8a8b..ae176c06dd 100644
>>> --- a/hw/virtio/vhost-vdpa.c
>>> +++ b/hw/virtio/vhost-vdpa.c
>>> @@ -1397,7 +1397,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
>>> return 0;
>>> }
>>>
>>> - if (!v->suspended) {
>>> + if ((dev->backend_cap & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && (!v->suspended)) {
>>> /*
>>> * Cannot trust in value returned by device, let vhost recover used
>>> * idx from guest.
>>> --
>>> 2.39.1
>>>
prev parent reply other threads:[~2023-06-09 8:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 17:08 [PATCH] vdpa: dont check vhost_vdpa->suspended when unsupported Zhu Lingshan
2023-06-07 13:51 ` Eugenio Perez Martin
2023-06-08 7:07 ` Zhu, Lingshan
2023-06-08 8:49 ` Eugenio Perez Martin
2023-06-08 9:34 ` Zhu, Lingshan
2023-06-08 10:59 ` Eugenio Perez Martin
2023-06-08 13:19 ` Zhu, Lingshan
2023-06-08 14:38 ` Eugenio Perez Martin
2023-06-09 3:13 ` Jason Wang
2023-06-09 8:49 ` Zhu, Lingshan [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=3c623e34-fbd2-03fb-e88a-d8d23feee4ad@intel.com \
--to=lingshan.zhu@intel.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).