[PATCH] libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick

Zheyu Ma posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240320090442.267525-1-zheyuma97@gmail.com
Maintainers: Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/libqos/virtio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick
Posted by Zheyu Ma 1 month, 1 week ago
In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from
vq->avail instead of the correct vq->used location. This update ensures 'flags'
are read from the correct location as per the virtio standard.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 tests/qtest/libqos/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
index 82a6e122bf..a21b6eee9c 100644
--- a/tests/qtest/libqos/virtio.c
+++ b/tests/qtest/libqos/virtio.c
@@ -394,7 +394,7 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
     qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
 
     /* Must read after idx is updated */
-    flags = qvirtio_readw(d, qts, vq->avail);
+    flags = qvirtio_readw(d, qts, vq->used);
     avail_event = qvirtio_readw(d, qts, vq->used + 4 +
                                 sizeof(struct vring_used_elem) * vq->size);
 
-- 
2.34.1
Re: [PATCH] libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick
Posted by Stefan Hajnoczi 1 month, 1 week ago
On Wed, 20 Mar 2024 at 09:10, Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from
> vq->avail instead of the correct vq->used location. This update ensures 'flags'
> are read from the correct location as per the virtio standard.
>
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
>  tests/qtest/libqos/virtio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

> diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
> index 82a6e122bf..a21b6eee9c 100644
> --- a/tests/qtest/libqos/virtio.c
> +++ b/tests/qtest/libqos/virtio.c
> @@ -394,7 +394,7 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
>      qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
>
>      /* Must read after idx is updated */
> -    flags = qvirtio_readw(d, qts, vq->avail);
> +    flags = qvirtio_readw(d, qts, vq->used);
>      avail_event = qvirtio_readw(d, qts, vq->used + 4 +
>                                  sizeof(struct vring_used_elem) * vq->size);
>
> --
> 2.34.1
>
>
Re: [PATCH] libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick
Posted by Philippe Mathieu-Daudé 1 month, 1 week ago
Cc'ing Marc & Stefan for commit 1053587c3f ("libqos: Added EVENT_IDX 
support").

On 20/3/24 10:04, Zheyu Ma wrote:
> In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from
> vq->avail instead of the correct vq->used location. This update ensures 'flags'
> are read from the correct location as per the virtio standard.
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
>   tests/qtest/libqos/virtio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
> index 82a6e122bf..a21b6eee9c 100644
> --- a/tests/qtest/libqos/virtio.c
> +++ b/tests/qtest/libqos/virtio.c
> @@ -394,7 +394,7 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
>       qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
>   
>       /* Must read after idx is updated */
> -    flags = qvirtio_readw(d, qts, vq->avail);
> +    flags = qvirtio_readw(d, qts, vq->used);
>       avail_event = qvirtio_readw(d, qts, vq->used + 4 +
>                                   sizeof(struct vring_used_elem) * vq->size);
>   

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>