Received: from eggs.gnu.org ([2001:4830:134:3::10]:54515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlvT9-0007a9-CR for qemu-devel@nongnu.org; Tue, 13 Oct 2015 05:02:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlvT5-0004b8-Ew for qemu-devel@nongnu.org; Tue, 13 Oct 2015 05:02:03 -0400 From: Alberto Garcia In-Reply-To: <20151013083922.GB4906@noname.str.redhat.com> References: <1444392941-28704-1-git-send-email-kwolf@redhat.com> <1444392941-28704-14-git-send-email-kwolf@redhat.com> <20151013083922.GB4906@noname.str.redhat.com> Date: Tue, 13 Oct 2015 11:01:34 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v3 13/16] block: Implement bdrv_append() without bdrv_swap() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: famz@redhat.com, qemu-block@nongnu.org, jcody@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com On Tue 13 Oct 2015 10:39:22 AM CEST, Kevin Wolf wrote: >> > +static void change_parent_backing_link(BlockDriverState *from, >> > + BlockDriverState *to) >> > +{ >> > + BdrvChild *c, *next; >> > + >> > + QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) { >> > + assert(c->role != &child_backing); >> > + c->bs = to; >> > + QLIST_REMOVE(c, next_parent); >> > + QLIST_INSERT_HEAD(&to->parents, c, next_parent); >> > + bdrv_ref(to); >> > + bdrv_unref(from); >> > + } >> > + if (from->blk) { >> > + blk_set_bs(from->blk, to); >> > + if (!to->device_list.tqe_prev) { >> > + QTAILQ_INSERT_BEFORE(from, to, device_list); >> > + } >> >> Is it even possible that this last condition is false? In what case >> would 'to' be already in bdrv_states? >> >> I understand that it would mean that it would already be attached to >> a BlockBackend, but that's not possible in this case. > > Yes, I think it's not possible currently (hopefully, because that > would cause other bugs), just being careful. Eventually we'll allow > more than one BlockBackend pointing to the same BDS, and then this is > a scenario that could happen. blk_set_bs() already asserts that to->blk == NULL, so if this is not possible here wouldn't it be better to use another assertion instead? When I was reviewing the code I kept wondering in what kind of scenario this condition could be false. Berto