qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] block/export: Add vhost-user-blk resize support


From: Xie Yongji
Subject: [PATCH 2/2] block/export: Add vhost-user-blk resize support
Date: Fri, 21 Jan 2022 16:46:44 +0800

To support block resize, this updates the capacity field
in configuration space and use vu_notify_config_change()
to notify the vhost-user master on the block resize callback.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 block/export/vhost-user-blk-server.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/block/export/vhost-user-blk-server.c 
b/block/export/vhost-user-blk-server.c
index 1862563336..929a0bd007 100644
--- a/block/export/vhost-user-blk-server.c
+++ b/block/export/vhost-user-blk-server.c
@@ -435,6 +435,20 @@ static void blk_aio_detach(void *opaque)
     vexp->export.ctx = NULL;
 }
 
+static void vu_blk_resize(void *opaque)
+{
+    BlockExport *exp = opaque;
+    VuBlkExport *vexp = container_of(exp, VuBlkExport, export);
+
+    vexp->blkcfg.capacity =
+        cpu_to_le64(blk_getlength(exp->blk) >> VIRTIO_BLK_SECTOR_BITS);
+    vu_notify_config_change(&vexp->vu_server.vu_dev);
+}
+
+static const BlockDevOps vu_block_ops = {
+    .resize_cb = vu_blk_resize,
+};
+
 static void
 vu_blk_initialize_config(BlockDriverState *bs,
                          struct virtio_blk_config *config,
@@ -513,6 +527,8 @@ static int vu_blk_exp_create(BlockExport *exp, 
BlockExportOptions *opts,
         return -EADDRNOTAVAIL;
     }
 
+    blk_set_dev_ops(exp->blk, &vu_block_ops, exp);
+
     return 0;
 }
 
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]