From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, svt-core@virtuozzo.com
Subject: [PATCH hci-8.1 v6 5/7] vhost-blk: reset the owner when vhost_blk_start() fails
Date: Tue, 17 Nov 2026 18:37:32 +0100 [thread overview]
Message-ID: <20261117173734.3225443-6-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261117173734.3225443-1-alexander.ivanov@virtuozzo.com>
Every failure after VHOST_SET_OWNER leaves QEMU the owner of the vhost
device with its worker threads running. The next start attempt then
fails on VHOST_SET_OWNER with -EBUSY until the guest resets the device.
Undo VHOST_SET_OWNER on these paths, as vhost_blk_reset() does.
https://virtuozzo.atlassian.net/browse/VSTOR-107537
Fixes: 0ff3cb5ff28f ("block: add vhost-blk backend")
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
hw/block/vhost-blk.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 1db8cfc7445..c817d0e3edf 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -60,21 +60,23 @@ static int vhost_blk_start(VirtIODevice *vdev)
nworkers = s->conf.num_threads;
if (nworkers != 1 && ioctl(s->vhostfd, VHOST_SET_NWORKERS, &nworkers)) {
error_report("vhost-blk: unable to set number of kernel threads");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_reset_owner;
}
if (s->conf.serial) {
strncpy(serial, s->conf.serial, VIRTIO_BLK_ID_BYTES - 1);
if (ioctl(s->vhostfd, VHOST_BLK_SET_SERIAL, serial)) {
error_report("vhost-blk: unable to set drive serial %s", serial);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_reset_owner;
}
}
ret = k->set_guest_notifiers(qbus->parent, hdev->nvqs, true);
if (ret < 0) {
error_report("vhost-blk: unable to bind guest notifiers");
- return ret;
+ goto err_reset_owner;
}
ret = vhost_dev_enable_notifiers(hdev, vdev);
@@ -121,6 +123,10 @@ err_set:
if (k->set_guest_notifiers(qbus->parent, hdev->nvqs, false) < 0) {
error_report("vhost-blk: unable to unbind guest notifiers");
}
+err_reset_owner:
+ if (ioctl(s->vhostfd, VHOST_RESET_OWNER, NULL)) {
+ error_report("vhost-blk: unable to reset owner: %s", strerror(errno));
+ }
return ret;
--
2.53.0
next prev parent reply other threads:[~2026-11-17 17:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 17:37 [PATCH hci-8.1 v6 0/7] vhost-blk: switch from VHOST_SET_NWORKERS to the mainstream worker ioctls Alexander Ivanov
2026-11-17 17:37 ` [PATCH hci-8.1 v6 1/7] vhost-backend: add vhost_set_fork_from_owner op Alexander Ivanov
2026-11-17 17:39 ` no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 2/7] vhost-blk: reject num-queues above VHOST_BLK_MAX_QUEUES Alexander Ivanov
2026-11-17 17:40 ` no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 3/7] vhost-blk: use a local vhost_dev pointer in start and stop Alexander Ivanov
2026-11-17 17:41 ` no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 4/7] vhost-blk: fix vhost_blk_start() returning 0 on failure Alexander Ivanov
2026-11-17 17:42 ` no-reply
2026-11-17 17:37 ` Alexander Ivanov [this message]
2026-11-17 17:43 ` [PATCH hci-8.1 v6 5/7] vhost-blk: reset the owner when vhost_blk_start() fails no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 6/7] vhost-blk: create kernel threads with the mainstream worker ioctls Alexander Ivanov
2026-11-17 17:47 ` no-reply
2026-11-17 17:37 ` [PATCH hci-8.1 v6 7/7] linux-headers: drop VHOST_SET_NWORKERS Alexander Ivanov
2026-11-17 17:49 ` 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=20261117173734.3225443-6-alexander.ivanov@virtuozzo.com \
--to=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.