All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
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 1/4] vhost-blk: read any queue attribute of the backend from sysfs
Date: Fri, 27 Nov 2026 13:46:55 +0100	[thread overview]
Message-ID: <20261127124658.1180997-2-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261127124658.1180997-1-alexander.ivanov@virtuozzo.com>

Turn vhost_blk_has_write_zeroes() into vhost_blk_read_queue_attr(),
which takes the name of the limit to check, so that discard support can
be detected the same way. No functional change.

https://virtuozzo.atlassian.net/browse/VSTOR-141683

Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
 hw/block/vhost-blk.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 870f3496908..96878de5bb4 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -586,8 +586,8 @@ static bool vhost_blk_uevent_attach(VHostBlk *s, Error **errp)
     return true;
 }
 
-static bool vhost_blk_has_write_zeroes(dev_t rdev, bool *supported,
-                                       Error **errp)
+static bool vhost_blk_read_queue_attr(dev_t rdev, const char *attr,
+                                      bool *supported, Error **errp)
 {
     g_autofree char *dev = NULL;
     g_autofree char *part = NULL;
@@ -599,8 +599,9 @@ static bool vhost_blk_has_write_zeroes(dev_t rdev, bool *supported,
 
     dev = g_strdup_printf("/sys/dev/block/%u:%u", major(rdev), minor(rdev));
     part = g_strdup_printf("%s/partition", dev);
-    path = g_strdup_printf("%s/%squeue/write_zeroes_max_bytes", dev,
-                           g_file_test(part, G_FILE_TEST_EXISTS) ? "../" : "");
+    path = g_strdup_printf("%s/%squeue/%s", dev,
+                           g_file_test(part, G_FILE_TEST_EXISTS) ? "../" : "",
+                           attr);
     if (!g_file_get_contents(path, &val, NULL, &gerr)) {
         error_setg(errp, "%s", gerr->message);
         return false;
@@ -661,8 +662,9 @@ static bool vhost_blk_open_backend(VHostBlk *s, Error **errp)
         if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_WRITE_ZEROES)) {
             Error *local_err = NULL;
 
-            if (!vhost_blk_has_write_zeroes(s->backend_rdev, &s->write_zeroes,
-                                            &local_err)) {
+            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) {
-- 
2.53.0


  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 ` Alexander Ivanov [this message]
2026-11-27 12:46 ` [PATCH hci-8.2 v3 2/4] vhost-blk: factor out the sysfs probe of the backend Alexander Ivanov
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-2-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.