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.1 v4 3/5] vhost-blk: use a local vhost_dev pointer in start and stop
Date: Thu, 29 Oct 2026 10:22:59 +0100	[thread overview]
Message-ID: <20261029092301.3286535-4-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261029092301.3286535-1-alexander.ivanov@virtuozzo.com>

Take &s->dev once into hdev in vhost_blk_start() and vhost_blk_stop()
instead of spelling it out at every use. No functional change.

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 | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index 8a015d54fa7..b3eb181ceae 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -36,6 +36,7 @@
 static int vhost_blk_start(VirtIODevice *vdev)
 {
     VHostBlk *s = VHOST_BLK(vdev);
+    struct vhost_dev *hdev = &s->dev;
     struct vhost_vring_file backend;
     int ret, i, nworkers;
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
@@ -70,22 +71,22 @@ static int vhost_blk_start(VirtIODevice *vdev)
         }
     }
 
-    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, true);
+    ret = k->set_guest_notifiers(qbus->parent, hdev->nvqs, true);
     if (ret < 0) {
         error_report("vhost-blk: unable to bind guest notifiers");
         return ret;
     }
 
-    ret = vhost_dev_enable_notifiers(&s->dev, vdev);
+    ret = vhost_dev_enable_notifiers(hdev, vdev);
     if (ret < 0) {
         error_report("vhost-blk: unable to enable dev notifiers: %s",
                      strerror(errno));
         goto err_set;
     }
 
-    s->dev.acked_features = vdev->guest_features & s->dev.features;
+    hdev->acked_features = vdev->guest_features & hdev->features;
 
-    ret = vhost_dev_start(&s->dev, vdev, false);
+    ret = vhost_dev_start(hdev, vdev, false);
     if (ret < 0) {
         error_report("vhost-blk: unable to start vhost dev");
         goto err_disable;
@@ -100,11 +101,11 @@ static int vhost_blk_start(VirtIODevice *vdev)
         goto err_stop;
     }
 
-    for (i = 0; i < s->dev.nvqs; i++) {
-        vhost_virtqueue_mask(&s->dev, vdev, i, false);
+    for (i = 0; i < hdev->nvqs; i++) {
+        vhost_virtqueue_mask(hdev, vdev, i, false);
     }
 
-    for (i = 0; i < s->dev.nvqs; i++) {
+    for (i = 0; i < hdev->nvqs; i++) {
         event_notifier_set(virtio_queue_get_host_notifier(virtio_get_queue(vdev, i)));
     }
 
@@ -113,11 +114,11 @@ static int vhost_blk_start(VirtIODevice *vdev)
     return 0;
 
 err_stop:
-    vhost_dev_stop(&s->dev, vdev, false);
+    vhost_dev_stop(hdev, vdev, false);
 err_disable:
-    vhost_dev_disable_notifiers(&s->dev, vdev);
+    vhost_dev_disable_notifiers(hdev, vdev);
 err_set:
-    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
+    ret = k->set_guest_notifiers(qbus->parent, hdev->nvqs, false);
     if (ret < 0) {
         error_report("vhost-blk: unable to unbind guest notifiers");
     }
@@ -131,6 +132,7 @@ static void vhost_blk_stop(VirtIODevice *vdev)
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
     VHostBlk *s = VHOST_BLK(vdev);
+    struct vhost_dev *hdev = &s->dev;
     struct vhost_vring_file backend;
     int ret;
 
@@ -138,11 +140,11 @@ static void vhost_blk_stop(VirtIODevice *vdev)
         return;
     }
 
-    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
+    ret = k->set_guest_notifiers(qbus->parent, hdev->nvqs, false);
     if (ret < 0) {
         error_report("vhost-blk: unable to unbind guest notifiers");
     }
-    vhost_dev_disable_notifiers(&s->dev, vdev);
+    vhost_dev_disable_notifiers(hdev, vdev);
 
     /*
      * Detach the backend before vhost_dev_stop() samples the vring base,
@@ -156,7 +158,7 @@ static void vhost_blk_stop(VirtIODevice *vdev)
     ret = ioctl(s->vhostfd, VHOST_BLK_SET_BACKEND, &backend);
     assert(ret == 0);
 
-    vhost_dev_stop(&s->dev, vdev, false);
+    vhost_dev_stop(hdev, vdev, false);
 
     s->vhost_started = false;
 }
-- 
2.53.0


  parent reply	other threads:[~2026-10-29  9:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  9:22 [PATCH hci-8.1 v4 0/5] vhost-blk: switch from VHOST_SET_NWORKERS to the mainstream worker ioctls Alexander Ivanov
2026-10-29  9:22 ` [PATCH hci-8.1 v4 1/5] vhost-backend: add vhost_set_fork_from_owner op Alexander Ivanov
2026-10-29  9:24   ` no-reply
2026-10-29  9:22 ` [PATCH hci-8.1 v4 2/5] vhost-blk: reject num-queues above VHOST_BLK_MAX_QUEUES Alexander Ivanov
2026-10-29  9:24   ` no-reply
2026-10-29  9:22 ` Alexander Ivanov [this message]
2026-10-29  9:24   ` [PATCH hci-8.1 v4 3/5] vhost-blk: use a local vhost_dev pointer in start and stop no-reply
2026-10-29 10:04     ` Alexander Ivanov
2026-10-29  9:28   ` Andrey Drobyshev
2026-10-29  9:23 ` [PATCH hci-8.1 v4 4/5] vhost-blk: create kernel threads with the mainstream worker ioctls Alexander Ivanov
2026-10-29  9:27   ` no-reply
2026-10-29  9:57     ` Alexander Ivanov
2026-10-29  9:35   ` Andrey Drobyshev
2026-10-29 10:12   ` Andrey Zhadchenko
2026-10-29  9:23 ` [PATCH hci-8.1 v4 5/5] linux-headers: drop VHOST_SET_NWORKERS Alexander Ivanov
2026-10-29  9:25   ` 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=20261029092301.3286535-4-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.