From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQcP4-0001Ls-KJ for qemu-devel@nongnu.org; Mon, 30 Sep 2013 08:16:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQcOx-000207-Ty for qemu-devel@nongnu.org; Mon, 30 Sep 2013 08:16:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQcOx-0001yK-Mi for qemu-devel@nongnu.org; Mon, 30 Sep 2013 08:16:35 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8UCGYdX004691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 Sep 2013 08:16:35 -0400 Message-ID: <52496BA9.7050104@redhat.com> Date: Mon, 30 Sep 2013 14:16:41 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1380542578-2387-1-git-send-email-famz@redhat.com> <1380542578-2387-6-git-send-email-famz@redhat.com> In-Reply-To: <1380542578-2387-6-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 5/7] commit: support commit active layer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Il 30/09/2013 14:02, Fam Zheng ha scritto: > + /* Mirror code already swapped bs and base, we drop the bs loop chain > + * formed by the swap: break the loop chain, trigger the chain unref. > + */ > + p = info->base->backing_hd; > + info->base->backing_hd = NULL; > + bdrv_unref(p); Should this code be in mirror_run? Perhaps extracting it into a new function together with the preceding lines: if (bdrv_get_flags(s->target) != bdrv_get_flags(s->common.bs)) { bdrv_reopen(s->target, bdrv_get_flags(s->common.bs), NULL); } bdrv_swap(s->target, s->common.bs); Same for this: > + if (bdrv_reopen(base_bs, bs->open_flags, &local_err)) { > + error_propagate(errp, local_err); > + return; > + } > + bdrv_ref(base_bs); Perhaps you can have an internal function mirror_start_job and two front-ends mirror_start + commit_active_start that wrap it. Similarly, mirror_start_job can take the base BDS and a bool instead of MirrorSyncMode (removing the need for MIRROR_SYNC_MODE_COMMON). But apart from these details, the series looks very nice. Paolo