From: Xie Yongji <xieyongji@bytedance.com>
To: Coiby.Xu@gmail.com, stefanha@redhat.com,
marcandre.lureau@redhat.com, kwolf@redhat.com, mreitz@redhat.com
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: [PATCH 2/2] block/export: Add vhost-user-blk resize support
Date: Fri, 21 Jan 2022 16:46:44 +0800 [thread overview]
Message-ID: <20220121084644.217-2-xieyongji@bytedance.com> (raw)
In-Reply-To: <20220121084644.217-1-xieyongji@bytedance.com>
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
prev parent reply other threads:[~2022-01-21 10:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 8:46 [PATCH 1/2] libvhost-user: Add vu_notify_config_change() to support config change notify Xie Yongji
2022-01-21 8:46 ` Xie Yongji [this message]
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=20220121084644.217-2-xieyongji@bytedance.com \
--to=xieyongji@bytedance.com \
--cc=Coiby.Xu@gmail.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).