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.2 v3 2/4] vhost-blk: factor out the sysfs probe of the backend
Date: Fri, 27 Nov 2026 13:46:56 +0100 [thread overview]
Message-ID: <20261127124658.1180997-3-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261127124658.1180997-1-alexander.ivanov@virtuozzo.com>
Move the sysfs probe of the backend into vhost_blk_probe_backend(), so
that discard can reuse it. No functional change.
https://virtuozzo.atlassian.net/browse/VSTOR-141683
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
hw/block/vhost-blk.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 96878de5bb4..427b73510ae 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -617,6 +617,26 @@ static bool vhost_blk_read_queue_attr(dev_t rdev, const char *attr,
return true;
}
+static void vhost_blk_probe_backend(VHostBlk *s, unsigned int bit,
+ const char *attr, const char *name,
+ bool *supported)
+{
+ Error *local_err = NULL;
+
+ if (!virtio_has_feature(s->host_features, bit)) {
+ return;
+ }
+
+ if (!vhost_blk_read_queue_attr(s->backend_rdev, attr, supported,
+ &local_err)) {
+ warn_reportf_err(local_err, "vhost-blk: unable to read %s limit of "
+ "'%s': ", name, s->conf.devpath);
+ } else if (!*supported) {
+ warn_report("vhost-blk: '%s' does not support %s", s->conf.devpath,
+ name);
+ }
+}
+
static bool vhost_blk_open_backend(VHostBlk *s, Error **errp)
{
ERRP_GUARD();
@@ -659,19 +679,9 @@ static bool vhost_blk_open_backend(VHostBlk *s, Error **errp)
goto fail;
}
- if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_WRITE_ZEROES)) {
- Error *local_err = NULL;
-
- if (!vhost_blk_read_queue_attr(s->backend_rdev,
- "write_zeroes_max_bytes",
- &s->write_zeroes, &local_err)) {
- warn_reportf_err(local_err, "vhost-blk: unable to read write "
- "zeroes limit of '%s': ", s->conf.devpath);
- } else if (!s->write_zeroes) {
- warn_report("vhost-blk: '%s' does not support write zeroes",
- s->conf.devpath);
- }
- }
+ vhost_blk_probe_backend(s, VIRTIO_BLK_F_WRITE_ZEROES,
+ "write_zeroes_max_bytes", "write zeroes",
+ &s->write_zeroes);
}
vhost_blk_update_size(s, errp);
--
2.53.0
next prev parent reply other threads:[~2026-11-27 12:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 12:46 [PATCH hci-8.2 v3 0/4] vhost-blk: support discard Alexander Ivanov
2026-11-27 12:46 ` [PATCH hci-8.2 v3 1/4] vhost-blk: read any queue attribute of the backend from sysfs Alexander Ivanov
2026-11-27 12:46 ` Alexander Ivanov [this message]
2026-11-27 12:46 ` [PATCH hci-8.2 v3 3/4] vhost-blk: advertise discard on a backend that supports it Alexander Ivanov
2026-11-27 12:46 ` [PATCH hci-8.2 v3 4/4] vhost-blk: fail realize when the kernel lacks write zeroes or discard Alexander Ivanov
2026-11-27 15:24 ` [PATCH hci-8.2 v3 0/4] vhost-blk: support discard Andrey Drobyshev
2026-11-30 14:09 ` Andrey Zhadchenko
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=20261127124658.1180997-3-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.