[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 7/7] nbd/replication: implement .bdrv_get_info()
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH RFC 7/7] nbd/replication: implement .bdrv_get_info() for nbd and replication driver |
Date: |
Thu, 20 Oct 2016 21:57:40 +0800 |
Without this callback, there will be an error reports in the primary side:
"qemu-system-x86_64: Couldn't determine the cluster size of the target image,
which has no backing file: Operation not supported
Aborting, since this may create an unusable destination image"
For nbd driver, it doesn't have cluster size, so here we return
a fake value for it.
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Wen Congyang <address@hidden>
---
block/nbd.c | 12 ++++++++++++
block/replication.c | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/block/nbd.c b/block/nbd.c
index 6bc06d6..96d7023 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -40,6 +40,8 @@
#define EN_OPTSTR ":exportname="
+#define NBD_FAKE_CLUSTER_SIZE 512
+
typedef struct BDRVNBDState {
NbdClientSession client;
@@ -483,6 +485,13 @@ static void nbd_refresh_filename(BlockDriverState *bs,
QDict *options)
bs->full_open_options = opts;
}
+static int nbd_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+ bdi->cluster_size = NBD_FAKE_CLUSTER_SIZE;
+
+ return 0;
+}
+
static BlockDriver bdrv_nbd = {
.format_name = "nbd",
.protocol_name = "nbd",
@@ -499,6 +508,7 @@ static BlockDriver bdrv_nbd = {
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
.bdrv_refresh_filename = nbd_refresh_filename,
+ .bdrv_get_info = nbd_get_info,
};
static BlockDriver bdrv_nbd_tcp = {
@@ -517,6 +527,7 @@ static BlockDriver bdrv_nbd_tcp = {
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
.bdrv_refresh_filename = nbd_refresh_filename,
+ .bdrv_get_info = nbd_get_info,
};
static BlockDriver bdrv_nbd_unix = {
@@ -535,6 +546,7 @@ static BlockDriver bdrv_nbd_unix = {
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
.bdrv_refresh_filename = nbd_refresh_filename,
+ .bdrv_get_info = nbd_get_info,
};
static void bdrv_nbd_init(void)
diff --git a/block/replication.c b/block/replication.c
index e66b1ca..14c718e 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -707,6 +707,11 @@ static void replication_stop(ReplicationState *rs, bool
failover, Error **errp)
aio_context_release(aio_context);
}
+static int replication_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+ return bdrv_get_info(bs->file->bs, bdi);
+}
+
BlockDriver bdrv_replication = {
.format_name = "replication",
.protocol_name = "replication",
@@ -719,6 +724,7 @@ BlockDriver bdrv_replication = {
.bdrv_co_readv = replication_co_readv,
.bdrv_co_writev = replication_co_writev,
+ .bdrv_get_info = replication_get_info,
.is_filter = true,
.bdrv_recurse_is_first_non_filter =
replication_recurse_is_first_non_filter,
--
1.8.3.1
- [Qemu-devel] [PATCH RFC 0/7] COLO block replication supports shared disk case, zhanghailiang, 2016/10/20
- [Qemu-devel] [PATCH RFC 3/7] replication: add shared-disk and shared-disk-id options, zhanghailiang, 2016/10/20
- [Qemu-devel] [PATCH RFC 2/7] block-backend: Introduce blk_root() helper, zhanghailiang, 2016/10/20
- [Qemu-devel] [PATCH RFC 6/7] replication: Implement block replication for shared disk case, zhanghailiang, 2016/10/20
- [Qemu-devel] [PATCH RFC 4/7] replication: Split out backup_do_checkpoint() from secondary_do_checkpoint(), zhanghailiang, 2016/10/20
- [Qemu-devel] [PATCH RFC 5/7] replication: fix code logic with the new shared_disk option, zhanghailiang, 2016/10/20
- [Qemu-devel] [PATCH RFC 7/7] nbd/replication: implement .bdrv_get_info() for nbd and replication driver,
zhanghailiang <=
- [Qemu-devel] [PATCH RFC 1/7] docs/block-replication: Add description for shared-disk case, zhanghailiang, 2016/10/20
- Re: [Qemu-devel] [PATCH RFC 0/7] COLO block replication supports shared disk case, Changlong Xie, 2016/10/25