[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interf
From: |
Wen Congyang |
Subject: |
[Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interfaces for block replication |
Date: |
Thu, 12 Feb 2015 11:07:11 +0800 |
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
block/nbd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/block/nbd.c b/block/nbd.c
index 19b9200..1ff6ecf 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -445,6 +445,58 @@ static void nbd_refresh_filename(BlockDriverState *bs)
bs->full_open_options = opts;
}
+static int nbd_start_replication(BlockDriverState *bs, int mode)
+{
+ BDRVNBDState *s = bs->opaque;
+ Error *local_err = NULL;
+ int ret;
+
+ /*
+ * TODO: support COLO_SECONDARY_MODE if we allow secondary
+ * QEMU becoming primary QEMU.
+ */
+ if (mode != COLO_PRIMARY_MODE) {
+ return -1;
+ }
+
+ if (s->connected) {
+ return -1;
+ }
+
+ /* TODO: NBD client should be one child of quorum, how to verify it? */
+ ret = nbd_connect_server(bs, &local_err);
+ if (local_err) {
+ error_free(local_err);
+ }
+
+ return ret;
+}
+
+static int nbd_do_checkpoint(BlockDriverState *bs)
+{
+ BDRVNBDState *s = bs->opaque;
+
+ if (!s->connected) {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int nbd_stop_replication(BlockDriverState *bs)
+{
+ BDRVNBDState *s = bs->opaque;
+
+ if (!s->connected) {
+ return -1;
+ }
+
+ nbd_client_session_close(&s->client);
+ s->connected = false;
+
+ return 0;
+}
+
static BlockDriver bdrv_nbd = {
.format_name = "nbd",
.protocol_name = "nbd",
@@ -514,6 +566,9 @@ static BlockDriver bdrv_nbd_colo = {
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
.bdrv_refresh_filename = nbd_refresh_filename,
+ .bdrv_start_replication = nbd_start_replication,
+ .bdrv_do_checkpoint = nbd_do_checkpoint,
+ .bdrv_stop_replication = nbd_stop_replication,
.has_variable_length = true,
};
--
2.1.0
- Re: [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child, (continued)
[Qemu-devel] [RFC PATCH 09/14] block: give backing image its own BlockBackend, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interfaces for block replication,
Wen Congyang <=
[Qemu-devel] [RFC PATCH 10/14] allow the backing image access the origin BlockDriverState, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 11/14] allow writing to the backing file, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 13/14] COW: move cow interfaces to a seperate file, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 08/14] block: add a new API to create a hidden BlockBackend, Wen Congyang, 2015/02/11