From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8mfO-0002fP-J0 for qemu-devel@nongnu.org; Mon, 21 Nov 2016 06:21:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8mfL-0000bO-FX for qemu-devel@nongnu.org; Mon, 21 Nov 2016 06:21:42 -0500 References: <1479555831-30960-1-git-send-email-zhang.zhanghailiang@huawei.com> From: Hailiang Zhang Message-ID: <5832D695.1040208@huawei.com> Date: Mon, 21 Nov 2016 19:12:21 +0800 MIME-Version: 1.0 In-Reply-To: <1479555831-30960-1-git-send-email-zhang.zhanghailiang@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] migration: re-active images when migration fails to complete List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: quintela@redhat.com, amit.shah@redhat.com Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: qemu-stable@nongnu.org On 2016/11/19 19:43, zhanghailiang wrote: > commit fe904ea8242cbae2d7e69c052c754b8f5f1ba1d6 fixed a case > which migration aborted QEMU because it didn't regain the control > of images while some errors happened. > > Actually, we have another case in that error path to abort QEMU > because of the same reason: > migration_thread() > migration_completion() > bdrv_inactivate_all() ----------------> inactivate images > qemu_savevm_state_complete_precopy() > socket_writev_buffer() --------> error because destination fails > qemu_fflush() -------------------> set error on migration stream > qemu_mutex_unlock_iothread() ------> unlock > qmp_migrate_cancel() ---------------------> user cancelled migration > migrate_set_state() ------------------> set migrate CANCELLING > migration_completion() -----------------> go on to fail_invalidate > if (s->state == MIGRATION_STATUS_ACTIVE) -> Jump this branch > migration_thread() -----------------------> break migration loop > vm_start() -----------------------------> restart guest with inactive > images > We failed to regain the control of images because we only regain it > while the migration state is "active", but here users cancelled the migration > when they found some errors happened (for example, libvirtd daemon is shutdown > in destination unexpectedly). > > Signed-off-by: zhanghailiang > --- > migration/migration.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/migration/migration.c b/migration/migration.c > index f498ab8..0c1ee6d 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -1752,7 +1752,8 @@ fail_invalidate: > /* If not doing postcopy, vm_start() will be called: let's regain > * control on images. > */ > - if (s->state == MIGRATION_STATUS_ACTIVE) { > + if (s->state == MIGRATION_STATUS_ACTIVE || > + s->state == MIGRATION_STATUS_CANCELLING) { > Error *local_err = NULL; > > bdrv_invalidate_cache_all(&local_err); >