All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: no-reply@sashiko.virtuozzo.com, andrey.zhadchenko@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, svt-core@virtuozzo.com
Subject: Re: [PATCH hci-8.1 2/2] vhost-blk: pause the VM on an IO_ERROR uevent from dm-qcow2 #VSTOR-152175
Date: Wed, 18 Nov 2026 08:51:22 +0100	[thread overview]
Message-ID: <b6a400ca-573c-4363-8ba7-5ad2cf0be58e@virtuozzo.com> (raw)
In-Reply-To: <010701a1e92f340f-afcb6aa6-92e1-4d58-9eb1-5f0ee108d23c-000000@eu-central-1.amazonses.com>

>> +static void vhost_blk_io_error(VHostBlk *s, bool is_read, int error)
>> +{
>> +    DeviceState *dev = DEVICE(s);
>> +    DeviceState *proxy = dev->parent_bus ? dev->parent_bus->parent : NULL;
>> +    BlockdevOnError on_err = is_read ? s->conf.conf.rerror
>> +                                     : s->conf.conf.werror;
>> +    g_autofree char *path = NULL;
>> +
>> +    if (on_err != BLOCKDEV_ON_ERROR_STOP &&
>> +        (on_err != BLOCKDEV_ON_ERROR_ENOSPC || error != ENOSPC)) {
>> +        return;
>> +    }
>> +
>> +    /* dm-qcow2 repeats the event on every failed retry of a held request */
>> +    if (!runstate_is_running()) {
>> +        return;
>> +    }
>> +
>> +    path = object_get_canonical_path(OBJECT(dev));
>> +
>> +    s->io_error_held = true;
>> +    if (!s->io_error_blocker) {
> [Severity: Medium]
> Does this early return drop the first IO_ERROR event when the VM is in
> PAUSED, FINISH_MIGRATE or SAVE_VM?
>
> vhost_blk_vm_state() has already run vhost_blk_stop() and
> vhost_blk_reset() in those states. A request that fails afterwards can
> be held by dm-qcow2, but its event returns here before io_error_held is
> set or the blocker is added. vhost_blk_pre_save() then returns 0, so
> savevm or migration can complete while dm-qcow2 still holds a request
> the guest has submitted.
>
> The comment only justifies skipping repeats once the VM is already in
> IO_ERROR. Would it work to set io_error_held and add the blocker before
> this check, and skip only the vmstop and the event here?
Stopping vhost-blk detaches the backend, and the kernel waits in
vhost_blk_flush() for every in-flight request, so in PAUSED or
FINISH_MIGRATE nothing of ours can still be held by dm-qcow2, and
an event that arrives later is about a request that has already
completed, so setting io_error_held for it would only block migration
from a paused VM for no reason.
> [Severity: Low]
> Does this check dedupe anything inside the drain loop of
> vhost_blk_uevent_read()? qemu_system_vmstop_request() only records the
> request and wakes the main loop. The run state stays RUNNING until the
> main loop runs vm_stop(). Several queued IO_ERROR datagrams read in one
> pass all get through, so management sees duplicate BLOCK_IO_ERROR events
> and repeated vmstop requests. The comment and commit message say repeats
> are ignored, which only holds after the stop has been processed.
> Checking s->io_error_held here would close the window.
Fixed.
>
> [ ... ]
>
>> @@ -373,11 +431,18 @@ static void vhost_blk_uevent_read(void *opaque)
>>               field += field_len + 1;
>>           }
>>   
>> -        if (action_change && subsystem_block && resize &&
>> -            event_major == major(s->backend_rdev) &&
>> -            event_minor == minor(s->backend_rdev)) {
>> +        if (!action_change || !subsystem_block ||
>> +            event_major != major(s->backend_rdev) ||
>> +            event_minor != minor(s->backend_rdev)) {
>> +            continue;
>> +        }
>> +
>> +        if (resize) {
>>               qemu_bh_schedule(s->resize_bh);
>>           }
>> +        if (io_error) {
>> +            vhost_blk_io_error(s, io_error_read, io_error_errno);
>> +        }
>>       }
>>   }
> [Severity: Low]
> Is a lost IO_ERROR event recoverable? The ENOBUFS branch earlier in this
> function only schedules resize_bh, which re-reads the capacity. If the
> netlink socket overruns and the IO_ERROR datagram is among those
> dropped, QEMU never stops the VM and never emits BLOCK_IO_ERROR. The
> guest keeps running with a request held in the kernel, and nothing
> re-queries that state.
No change needed: dm-qcow2 retries held requests every 20 seconds
and sends a fresh IO_ERROR uevent whenever a retry fails, so a dropped
event only delays the stop until the next failed retry.
>
> [ ... ]
>
>> @@ -635,6 +700,14 @@ static void vhost_blk_device_realize(DeviceState *dev, Error **errp)
>>           return;
>>       }
>>   
>> +    if (!conf->ueventfd &&
>> +        (conf->conf.werror == BLOCKDEV_ON_ERROR_STOP ||
>> +         conf->conf.rerror == BLOCKDEV_ON_ERROR_STOP)) {
>> +        error_setg(errp, "vhost-blk: 'stop' error policy requires the "
>> +                   "'ueventfd' property");
>> +        return;
>> +    }
> [Severity: Low]
> Should enospc also require ueventfd here? The commit message says the
> enospc or stop policy is affected, but only stop is checked. The default
> werror (auto) is mapped to enospc earlier in realize. Without ueventfd, a
> held ENOSPC write never reaches vhost_blk_io_error(), so the VM keeps
> running with the request stuck. Either check werror == ENOSPC as well or
> document the limitation.
enospc is the default werror, so rejecting it without ueventfd would
break every vhost-blk device configured without the socket; the commit
message now says this explicitly.

  reply	other threads:[~2026-11-18  7:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 10:50 [PATCH hci-8.1 0/2] vhost-blk: support the werror/rerror policies Alexander Ivanov
2026-11-17 10:50 ` [PATCH hci-8.1 1/2] vhost-blk: add the werror and rerror properties #VSTOR-152175 Alexander Ivanov
2026-11-17 11:03   ` no-reply
2026-11-17 18:12   ` Andrey Drobyshev
2026-11-18  7:52     ` Alexander Ivanov
2026-11-17 10:50 ` [PATCH hci-8.1 2/2] vhost-blk: pause the VM on an IO_ERROR uevent from dm-qcow2 #VSTOR-152175 Alexander Ivanov
2026-11-17 11:05   ` no-reply
2026-11-18  7:51     ` Alexander Ivanov [this message]
2026-11-17 18:12   ` Andrey Drobyshev
2026-11-18  8:01     ` Alexander Ivanov
2026-11-17 10:59 ` [PATCH hci-8.1 0/2] vhost-blk: support the werror/rerror policies Andrey Drobyshev
2026-11-17 18:14   ` Denis V. Lunev
2026-11-18  8:05     ` 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=b6a400ca-573c-4363-8ba7-5ad2cf0be58e@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=no-reply@sashiko.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.