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 v4 4/5] vhost-blk: pause the VM on a request failed with ENOSPC #VSTOR-152175
Date: Tue, 1 Dec 2026 09:25:30 +0000	[thread overview]
Message-ID: <010701a230ec6ca1-1f6f7a3e-f1ab-4f71-9cf2-747f0a0f3535-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261201091818.1894308-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 with no
  progress check or bound
- [Low] vhost-blk: BLOCK_IO_ERROR reports wrong op type and fake
  offset/bytes
- [Low] vhost-blk: realize warns about unsupported hold even with
  default werror
--

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

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

This commit makes vhost-blk set a hold policy in the kernel from werror and rerror. The kernel then holds requests that fail with ENOSPC instead of completing them with an error. QEMU stops the VM and emits BLOCK_IO_ERROR when a request is held, saves the held list on stop, and resubmits it on the next start.

> diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
> --- a/hw/block/vhost-blk.c
> +++ b/hw/block/vhost-blk.c
> @@ -32,6 +32,102 @@
[ ... ]
> +    while (done < s->nr_held) {
> +        nr = s->nr_held - done;
> +        reqs->nr = nr;
> +        for (i = 0; i < nr; i++) {
> +            reqs->reqs[i].vq = s->held[done + i].vq;
> +            reqs->reqs[i].head = s->held[done + i].head;
> +        }
> +
> +        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 done does not advance and the identical ioctl is reissued. There is no retry limit, backoff or zero-progress check.

vhost_blk_resubmit_held() runs from vhost_blk_start() with the BQL held, so the whole VM and QMP would hang under persistent host memory pressure. Should the ENOMEM retry give up, or back off, when reqs->nr is 0?

[ ... ]
> @@ -274,6 +397,38 @@ static void vhost_blk_vm_state(void *opaque, bool running, RunState state)
[ ... ]
> +    req = &reqs->reqs[reqs->nr - 1];
> +    path = object_get_canonical_path(OBJECT(dev));
> +
> +    qemu_system_vmstop_request_prepare();
> +    qapi_event_send_block_io_error(path, proxy->id ?: "", NULL,
> +                                   req->type == VIRTIO_BLK_T_IN ?
> +                                   IO_OPERATION_TYPE_READ :
> +                                   IO_OPERATION_TYPE_WRITE,
> +                                   BLOCK_ERROR_ACTION_STOP, true,
> +                                   req->error == ENOSPC, strerror(req->error),
> +                                   0, 0);

[Severity: Low]
Is the event content accurate here? Any held request whose type is not VIRTIO_BLK_T_IN, such as flush, discard or write-zeroes, is reported as a WRITE. The offset and bytes are always 0, 0. The commit message says the event is emitted "as the block layer does for other devices", but management software gets inaccurate operation, offset and bytes fields.

[ ... ]
> @@ -815,6 +978,14 @@ static void vhost_blk_device_realize(DeviceState *dev, Error **errp)
[ ... ]
> +    event_notifier_set_handler(&s->error_notifier, vhost_blk_error_event);
> +    s->hold_supported = !ioctl(s->vhostfd, VHOST_BLK_SET_ERROR_POLICY,
> +                               &policy);
> +    if (!s->hold_supported && vhost_blk_error_policy(s)) {
> +        warn_report("vhost-blk: the kernel cannot hold failed requests, "
> +                    "werror and rerror have no effect");
> +    }

[Severity: Low]
Will this warning fire for every device on an older kernel? Realize maps werror=AUTO to BLOCKDEV_ON_ERROR_ENOSPC, so vhost_blk_error_policy() is non-zero even when the user never set werror or rerror. The result is log noise on every vhost-blk device, while the commit message only says "warn and run as before".

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

  reply	other threads:[~2026-12-01  9:25 UTC|newest]

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

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=010701a230ec6ca1-1f6f7a3e-f1ab-4f71-9cf2-747f0a0f3535-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.