All of lore.kernel.org
 help / color / mirror / Atom feed
From: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com,
	pbonzini@redhat.com, wency@cn.fujitsu.com,
	Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH RFC 3/7] replication: add shared-disk and shared-disk-id options
Date: Wed, 26 Oct 2016 09:58:51 +0800	[thread overview]
Message-ID: <58100DDB.9060808@cn.fujitsu.com> (raw)
In-Reply-To: <1476971860-20860-4-git-send-email-zhang.zhanghailiang@huawei.com>

On 10/20/2016 09:57 PM, zhanghailiang wrote:
> We use these two options to identify which disk is
> shared
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
> ---
>   block/replication.c | 33 +++++++++++++++++++++++++++++++++
>   1 file changed, 33 insertions(+)
>
> diff --git a/block/replication.c b/block/replication.c
> index 3bd1cf1..2a2fdb2 100644
> --- a/block/replication.c
> +++ b/block/replication.c
> @@ -25,9 +25,12 @@
>   typedef struct BDRVReplicationState {
>       ReplicationMode mode;
>       int replication_state;
> +    bool is_shared_disk;
> +    char *shared_disk_id;
>       BdrvChild *active_disk;
>       BdrvChild *hidden_disk;
>       BdrvChild *secondary_disk;
> +    BdrvChild *primary_disk;
>       char *top_id;
>       ReplicationState *rs;
>       Error *blocker;
> @@ -53,6 +56,9 @@ static void replication_stop(ReplicationState *rs, bool failover,
>
>   #define REPLICATION_MODE        "mode"
>   #define REPLICATION_TOP_ID      "top-id"
> +#define REPLICATION_SHARED_DISK "shared-disk"
> +#define REPLICATION_SHARED_DISK_ID "shared-disk-id"
> +
>   static QemuOptsList replication_runtime_opts = {
>       .name = "replication",
>       .head = QTAILQ_HEAD_INITIALIZER(replication_runtime_opts.head),
> @@ -65,6 +71,14 @@ static QemuOptsList replication_runtime_opts = {
>               .name = REPLICATION_TOP_ID,
>               .type = QEMU_OPT_STRING,
>           },
> +        {
> +            .name = REPLICATION_SHARED_DISK_ID,
> +            .type = QEMU_OPT_STRING,
> +        },
> +        {
> +            .name = REPLICATION_SHARED_DISK,
> +            .type = QEMU_OPT_BOOL,
> +        },
>           { /* end of list */ }
>       },
>   };
> @@ -85,6 +99,8 @@ static int replication_open(BlockDriverState *bs, QDict *options,
>       QemuOpts *opts = NULL;
>       const char *mode;
>       const char *top_id;
> +    const char *shared_disk_id;
> +    BlockBackend *blk;
>
>       ret = -EINVAL;
>       opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort);
> @@ -114,6 +130,22 @@ static int replication_open(BlockDriverState *bs, QDict *options,
>                      "The option mode's value should be primary or secondary");
>           goto fail;
>       }

Now we have four runtime options 
"mode"/"top-id"/"shared-disk"/"shared-disk-id". But the current checking 
logic is too weak, i think you need enhance it to avoid opts misusage.

> +    s->is_shared_disk = qemu_opt_get_bool(opts, REPLICATION_SHARED_DISK,
> +                                        false);

Missing one space.

> +    if (s->is_shared_disk && (s->mode == REPLICATION_MODE_PRIMARY)) {
> +        shared_disk_id = qemu_opt_get(opts, REPLICATION_SHARED_DISK_ID);
> +        if (!shared_disk_id) {
> +            error_setg(&local_err, "Missing shared disk blk");
> +            goto fail;
> +        }
> +        s->shared_disk_id = g_strdup(shared_disk_id);
> +        blk = blk_by_name(s->shared_disk_id);
> +        if (!blk) {
> +            error_setg(&local_err, "There is no %s block", s->shared_disk_id);
> +            goto fail;
> +        }
> +        s->primary_disk = blk_root(blk);
> +    }
>
>       s->rs = replication_new(bs, &replication_ops);
>
> @@ -130,6 +162,7 @@ static void replication_close(BlockDriverState *bs)
>   {
>       BDRVReplicationState *s = bs->opaque;
>
> +    g_free(s->shared_disk_id);
>       if (s->replication_state == BLOCK_REPLICATION_RUNNING) {
>           replication_stop(s->rs, false, NULL);
>       }
>

  parent reply	other threads:[~2016-10-26  1:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 13:57 [Qemu-devel] [PATCH RFC 0/7] COLO block replication supports shared disk case zhanghailiang
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 1/7] docs/block-replication: Add description for shared-disk case zhanghailiang
2016-10-25  9:03   ` Changlong Xie
2016-11-28  5:13     ` Hailiang Zhang
2016-11-28  6:00       ` Changlong Xie
2016-11-28  5:58         ` Hailiang Zhang
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 2/7] block-backend: Introduce blk_root() helper zhanghailiang
2016-10-25  9:58   ` Changlong Xie
2016-12-05  2:41     ` Hailiang Zhang
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 3/7] replication: add shared-disk and shared-disk-id options zhanghailiang
2016-10-25 10:01   ` Changlong Xie
2016-12-05  3:08     ` Hailiang Zhang
2016-10-26  1:58   ` Changlong Xie [this message]
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 4/7] replication: Split out backup_do_checkpoint() from secondary_do_checkpoint() zhanghailiang
2016-10-26  1:40   ` Changlong Xie
2016-12-05  3:41     ` Hailiang Zhang
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 5/7] replication: fix code logic with the new shared_disk option zhanghailiang
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 6/7] replication: Implement block replication for shared disk case zhanghailiang
2016-10-20 13:57 ` [Qemu-devel] [PATCH RFC 7/7] nbd/replication: implement .bdrv_get_info() for nbd and replication driver zhanghailiang
2016-10-20 15:34   ` Eric Blake
2016-10-24  2:44     ` Hailiang Zhang
2016-10-26  2:06 ` [Qemu-devel] [PATCH RFC 0/7] COLO block replication supports shared disk case Changlong Xie
2016-11-22 10:33 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-11-23  1:47   ` Hailiang Zhang

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=58100DDB.9060808@cn.fujitsu.com \
    --to=xiecl.fnst@cn.fujitsu.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wency@cn.fujitsu.com \
    --cc=zhang.zhanghailiang@huawei.com \
    --cc=zhangchen.fnst@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.