@@ -2003,6 +2003,13 @@ int blk_truncate(BlockBackend *blk, int64_t offset, PreallocMode prealloc,
return bdrv_truncate(blk->root, offset, prealloc, errp);
}
+void blk_legacy_resize_cb(BlockBackend *blk)
+{
+ if (blk->legacy_dev) {
+ xen_blk_resize_cb(blk->dev);
+ }
+}
+
static void blk_pdiscard_entry(void *opaque)
{
BlkRwCo *rwco = opaque;
@@ -3174,6 +3174,7 @@ void qmp_block_resize(bool has_device, const char *device,
{
Error *local_err = NULL;
BlockBackend *blk = NULL;
+ BlockBackend *cb_blk = NULL;
BlockDriverState *bs;
AioContext *aio_context;
int ret;
@@ -3186,6 +3187,10 @@ void qmp_block_resize(bool has_device, const char *device,
return;
}
+ if (has_device) {
+ cb_blk = blk_by_name(device);
+ }
+
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
@@ -3212,6 +3217,9 @@ void qmp_block_resize(bool has_device, const char *device,
bdrv_drained_begin(bs);
ret = blk_truncate(blk, size, PREALLOC_MODE_OFF, errp);
+ if (!ret && cb_blk) {
+ blk_legacy_resize_cb(cb_blk);
+ }
bdrv_drained_end(bs);
out:
@@ -1013,6 +1013,15 @@ char *xen_blk_get_attached_dev_id(void *dev)
return g_strdup_printf("xen-qdisk-%i", blkdev->xendev.dev);
}
+void xen_blk_resize_cb(void *dev)
+{
+ struct XenBlkDev *blkdev = dev;
+ blkdev->file_size = blk_getlength(blkdev->blk);
+ xenstore_write_be_int64(&blkdev->xendev, "sectors",
+ blkdev->file_size / blkdev->file_blk);
+ xen_be_set_state(&blkdev->xendev, blkdev->xendev.be_state);
+}
+
struct XenDevOps xen_blkdev_ops = {
.flags = DEVOPS_FLAG_NEED_GNTDEV,
.size = sizeof(struct XenBlkDev),
@@ -50,4 +50,6 @@ void xen_register_framebuffer(struct MemoryRegion *mr);
char *xen_blk_get_attached_dev_id(void *dev);
+void xen_blk_resize_cb(void *dev);
+
#endif /* QEMU_HW_XEN_H */
@@ -236,4 +236,6 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
BlockBackend *blk_out, int64_t off_out,
int bytes, BdrvRequestFlags flags);
+void blk_legacy_resize_cb(BlockBackend *blk);
+
#endif
@@ -17,3 +17,7 @@ char *xen_blk_get_attached_dev_id(void *dev)
{
return g_strdup("");
}
+
+void xen_blk_resize_cb(void *dev)
+{
+}
In the context of a monitor based disk resize, provide notification of the new size to the front end xen block driver via a xenstore update. Signed-off-by: Bruce Rogers <brogers@suse.com> --- block/block-backend.c | 7 +++++++ blockdev.c | 8 ++++++++ hw/block/xen_disk.c | 9 +++++++++ include/hw/xen/xen.h | 2 ++ include/sysemu/block-backend.h | 2 ++ stubs/xen-common.c | 4 ++++ 6 files changed, 32 insertions(+)