qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	kwolf@redhat.com, xuquan8@huawei.com, xiecl.fnst@cn.fujitsu.com,
	Wen Congyang <wency@cn.fujitsu.com>,
	zhangchen.fnst@cn.fujitsu.com, qemu-block@nongnu.org,
	qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v3 2/6] replication: add shared-disk and shared-disk-id options
Date: Wed, 1 Mar 2017 10:21:29 +0000	[thread overview]
Message-ID: <20170301102129.GA29473@stefanha-x1.localdomain> (raw)
In-Reply-To: <58B645AA.3030301@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 2274 bytes --]

On Wed, Mar 01, 2017 at 11:53:14AM +0800, Hailiang Zhang wrote:
> On 2017/2/28 1:10, Stefan Hajnoczi wrote:
> > On Fri, Jan 20, 2017 at 11:47:56AM +0800, zhanghailiang wrote:
> > > @@ -119,12 +136,31 @@ static int replication_open(BlockDriverState *bs, QDict *options,
> > >                      "The option mode's value should be primary or secondary");
> > >           goto fail;
> > >       }
> > > +    s->is_shared_disk = qemu_opt_get_bool(opts, REPLICATION_SHARED_DISK,
> > > +                                          false);
> > > +    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 option");
> > > +            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;
> > > +        }
> > > +        /* We can't access root member of BlockBackend directly */
> > > +        tmp_bs = blk_bs(blk);
> > > +        s->primary_disk = QLIST_FIRST(&tmp_bs->parents);
> > 
> > Why is this necessary?
> > 
> > We already have the BlockBackend for the primary disk.  I'm not sure why
> > the BdrvChild is needed.
> > 
> 
> Er, the helper backup_job_create() needs the BlockDriverState for the primary disk,

You can get the BDS any time using blk_bs().

> besides, we want to make it same with 'secondary_disk' in struct BDRVReplicationState.

Block drivers are allowed to access BDS->parents so it's not necessarily
a problem that the code does this.  But it's rare and usually means
there is a non-standard relationship between BDS nodes.

It wasn't obvious from the code why you are going through the trouble of
getting a BdrvChild instead of using the BlockBackend (the normal way of
accessing a drive).

Perhaps a comment would help:

/* We have a BlockBackend for the primary disk but use BdrvChild for
 * consistency - active_disk, secondary_disk, etc are also BdrvChild.
 */

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2017-03-01 10:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20  3:47 [Qemu-devel] [PATCH v3 0/6] COLO block replication supports shared disk case zhanghailiang
2017-01-20  3:47 ` [Qemu-devel] [PATCH v3 1/6] docs/block-replication: Add description for shared-disk case zhanghailiang
2017-02-27 16:46   ` Stefan Hajnoczi
2017-03-01  3:09     ` Hailiang Zhang
2017-03-01 10:22       ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-01-20  3:47 ` [Qemu-devel] [PATCH v3 2/6] replication: add shared-disk and shared-disk-id options zhanghailiang
2017-02-27 17:10   ` Stefan Hajnoczi
2017-03-01  3:53     ` Hailiang Zhang
2017-03-01 10:21       ` Stefan Hajnoczi [this message]
2017-01-20  3:47 ` [Qemu-devel] [PATCH v3 3/6] replication: Split out backup_do_checkpoint() from secondary_do_checkpoint() zhanghailiang
2017-01-20  3:47 ` [Qemu-devel] [PATCH v3 4/6] replication: fix code logic with the new shared_disk option zhanghailiang
2017-01-20  3:47 ` [Qemu-devel] [PATCH v3 5/6] replication: Implement block replication for shared disk case zhanghailiang
2017-02-27 17:37   ` Stefan Hajnoczi
2017-03-07 14:30     ` Hailiang Zhang
2017-03-10  4:17       ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-01-20  3:48 ` [Qemu-devel] [PATCH v3 6/6] nbd/replication: implement .bdrv_get_info() for nbd and replication driver zhanghailiang
2017-02-23 12:46 ` [Qemu-devel] [PATCH v3 0/6] COLO block replication supports shared disk case 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=20170301102129.GA29473@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wency@cn.fujitsu.com \
    --cc=xiecl.fnst@cn.fujitsu.com \
    --cc=xuquan8@huawei.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 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).