All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
	 andrey.zhadchenko@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, svt-core@virtuozzo.com
Subject: Re: [PATCH hci-8.2 v3 4/5] vhost-blk: pause the VM on a request failed with ENOSPC #VSTOR-152175
Date: Tue, 1 Dec 2026 01:07:13 +0000	[thread overview]
Message-ID: <010701a22f243cea-a121e4cd-5006-4088-ba16-6140a4dd09f4-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261130094210.1686802-5-alexander.ivanov@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] vhost-blk: vhost_blk_resubmit_held() retries ENOMEM forever
  without progress
- [Medium] vhost-blk: vhost_blk_save_held() drops held requests when
  GET_HELD_REQS fails
- [Low] vhost-blk: vhost_blk_resubmit_held() drops a head on resubmit
  error
--

commit 81d26424eb761f296b39790b51894a86c271e60a
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>

vhost-blk: pause the VM on a request failed with ENOSPC

vhost-blk completes requests in the kernel, so werror and rerror have no effect. This commit sets a hold policy in the kernel from werror and rerror, and passes an eventfd that is signalled on a held request. QEMU then stops the VM with the io-error reason, saves the held requests when vhost stops, and resubmits them on the next start.

> diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
> index 124885a2b3005..19003def39335 100644
> --- a/hw/block/vhost-blk.c
> +++ b/hw/block/vhost-blk.c

[ ... ]

> +static void vhost_blk_save_held(VHostBlk *s)
> +{
> +    g_autofree struct vhost_blk_held_reqs *reqs = vhost_blk_get_held(s);
> +    int i;
> +
> +    g_free(s->held);
> +    s->held = NULL;
> +    s->nr_held = reqs ? reqs->nr : 0;

[Severity: Medium]
Does this lose held requests when VHOST_BLK_GET_HELD_REQS fails?
vhost_blk_get_held() returns NULL on any ioctl failure, and this line
treats that the same as an empty list.

The held heads are already consumed from the avail ring, and the kernel
list is dropped by the following VHOST_RESET_OWNER or the next
SET_BACKEND. Nothing is saved on the QEMU side, so these requests are
never resubmitted or completed, and the guest hangs on those descriptors.
Before this patch such requests were completed with an error. Should the
failure be distinguished from an empty list?

[ ... ]

> +static void vhost_blk_resubmit_held(VHostBlk *s)
> +{

[ ... ]

> +        if (!ioctl(s->vhostfd, VHOST_BLK_RESUBMIT, reqs)) {
> +            break;
> +        }
> +        if (reqs->nr >= nr) {
> +            error_report("vhost-blk: unable to resubmit held requests: %s",
> +                         strerror(errno));
> +            break;
> +        }
> +
> +        done += reqs->nr;
> +        if (errno == ENOMEM) {
> +            continue;
> +        }

[Severity: Medium]
Can this loop spin forever? If VHOST_BLK_RESUBMIT keeps failing with
ENOMEM and reports reqs->nr == 0, then "reqs->nr >= nr" is false,
"done += reqs->nr" adds nothing, and "continue" reissues the identical
request.

This runs from vhost_blk_start() on the main loop thread with the BQL
held (vm-state handler or set_status on DRIVER_OK), so the whole VM and
QMP would hang under host memory pressure. Would a no-progress check or
a retry bound help here?

> +        error_report("vhost-blk: unable to resubmit held request "
> +                     "vq %u head %u: %s", s->held[done].vq,
> +                     s->held[done].head, strerror(errno));
> +        done++;
> +    }
> +
> +    g_free(s->held);
> +    s->held = NULL;
> +    s->nr_held = 0;

[Severity: Low]
Is the guest request for a skipped head ever completed? When
VHOST_BLK_RESUBMIT fails for one head with an error other than ENOMEM,
the head is logged and skipped with done++, and s->held is freed after
the loop.

The linux-headers comment for VHOST_BLK_RESUBMIT says the kernel does not
track heads once they have been read out, so no later start can retry
this one. That guest I/O stays outstanding until the guest times out or
resets the device.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261130094210.1686802-1-alexander.ivanov@virtuozzo.com?part=4

  reply	other threads:[~2026-12-01  1:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:42 [PATCH hci-8.2 v3 0/5] vhost-blk: support the werror/rerror policies Alexander Ivanov
2026-11-30  9:42 ` [PATCH hci-8.2 v3 1/5] linux-headers: add the vhost-blk held request ioctls #VSTOR-152175 Alexander Ivanov
2026-12-01  0:53   ` no-reply
2026-12-01  9:03     ` Alexander Ivanov
2026-11-30  9:42 ` [PATCH hci-8.2 v3 2/5] vhost-blk: add the werror and rerror properties #VSTOR-152175 Alexander Ivanov
2026-12-01  0:54   ` no-reply
2026-11-30  9:42 ` [PATCH hci-8.2 v3 3/5] vhost-blk: stop vhost on every VM stop #VSTOR-152175 Alexander Ivanov
2026-12-01  0:58   ` no-reply
2026-12-01  9:07     ` Alexander Ivanov
2026-11-30  9:42 ` [PATCH hci-8.2 v3 4/5] vhost-blk: pause the VM on a request failed with ENOSPC #VSTOR-152175 Alexander Ivanov
2026-12-01  1:07   ` no-reply [this message]
2026-12-01  9:14     ` Alexander Ivanov
2026-11-30  9:42 ` [PATCH hci-8.2 v3 5/5] vhost-blk: migrate the held requests #VSTOR-152175 Alexander Ivanov
2026-12-01  1:10   ` no-reply

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=010701a22f243cea-a121e4cd-5006-4088-ba16-6140a4dd09f4-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=svt-core@virtuozzo.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.