[PATCH] virtio-pmem: ignore empty queue notifications

Li Chen posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260106083859.380338-1-me@linux.beauty
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
hw/virtio/virtio-pmem.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] virtio-pmem: ignore empty queue notifications
Posted by Li Chen 1 month ago
From: Li Chen <chenl311@chinatelecom.cn>

virtio_pmem_flush() treats a NULL return from virtqueue_pop() as a fatal
error and calls virtio_error(), which puts the device into NEEDS_RESET.

However, virtqueue handlers can be invoked when no element is available,
so an empty queue should be handled as a benign no-op.

With a Linux guest this avoids spurious NEEDS_RESET and the resulting
-EIO propagation (e.g. EXT4 journal abort and remount-ro).

Signed-off-by: Li Chen <me@linux.beauty>
---
 hw/virtio/virtio-pmem.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c
index 3416ea1827..cec1072f78 100644
--- a/hw/virtio/virtio-pmem.c
+++ b/hw/virtio/virtio-pmem.c
@@ -74,7 +74,6 @@ static void virtio_pmem_flush(VirtIODevice *vdev, VirtQueue *vq)
     trace_virtio_pmem_flush_request();
     req_data = virtqueue_pop(vq, sizeof(VirtIODeviceRequest));
     if (!req_data) {
-        virtio_error(vdev, "virtio-pmem missing request data");
         return;
     }
 
-- 
2.52.0
Re: [PATCH] virtio-pmem: ignore empty queue notifications
Posted by Michael Tokarev 1 day, 10 hours ago
On 1/6/26 11:38, Li Chen wrote:
> From: Li Chen <chenl311@chinatelecom.cn>
> 
> virtio_pmem_flush() treats a NULL return from virtqueue_pop() as a fatal
> error and calls virtio_error(), which puts the device into NEEDS_RESET.
> 
> However, virtqueue handlers can be invoked when no element is available,
> so an empty queue should be handled as a benign no-op.
> 
> With a Linux guest this avoids spurious NEEDS_RESET and the resulting
> -EIO propagation (e.g. EXT4 journal abort and remount-ro).

This feels like a qemu-stable material.

Please let me know if it isn't.

Thanks,

/mjt

> Signed-off-by: Li Chen <me@linux.beauty>
> ---
>   hw/virtio/virtio-pmem.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c
> index 3416ea1827..cec1072f78 100644
> --- a/hw/virtio/virtio-pmem.c
> +++ b/hw/virtio/virtio-pmem.c
> @@ -74,7 +74,6 @@ static void virtio_pmem_flush(VirtIODevice *vdev, VirtQueue *vq)
>       trace_virtio_pmem_flush_request();
>       req_data = virtqueue_pop(vq, sizeof(VirtIODeviceRequest));
>       if (!req_data) {
> -        virtio_error(vdev, "virtio-pmem missing request data");
>           return;
>       }
>
Re: [PATCH] virtio-pmem: ignore empty queue notifications
Posted by Michael S. Tsirkin 1 month ago
On Tue, Jan 06, 2026 at 04:38:59PM +0800, Li Chen wrote:
> From: Li Chen <chenl311@chinatelecom.cn>
> 
> virtio_pmem_flush() treats a NULL return from virtqueue_pop() as a fatal
> error and calls virtio_error(), which puts the device into NEEDS_RESET.
> 
> However, virtqueue handlers can be invoked when no element is available,
> so an empty queue should be handled as a benign no-op.
> 
> With a Linux guest this avoids spurious NEEDS_RESET and the resulting
> -EIO propagation (e.g. EXT4 journal abort and remount-ro).
> 
> Signed-off-by: Li Chen <me@linux.beauty>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/virtio/virtio-pmem.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c
> index 3416ea1827..cec1072f78 100644
> --- a/hw/virtio/virtio-pmem.c
> +++ b/hw/virtio/virtio-pmem.c
> @@ -74,7 +74,6 @@ static void virtio_pmem_flush(VirtIODevice *vdev, VirtQueue *vq)
>      trace_virtio_pmem_flush_request();
>      req_data = virtqueue_pop(vq, sizeof(VirtIODeviceRequest));
>      if (!req_data) {
> -        virtio_error(vdev, "virtio-pmem missing request data");
>          return;
>      }
>  
> -- 
> 2.52.0