From patchwork Fri Aug 5 07:11:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 108615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 541BBB6F70 for ; Fri, 5 Aug 2011 17:11:47 +1000 (EST) Received: from localhost ([::1]:34346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpEZL-0002jx-IG for incoming@patchwork.ozlabs.org; Fri, 05 Aug 2011 03:11:43 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpEZC-0002jr-Ij for qemu-devel@nongnu.org; Fri, 05 Aug 2011 03:11:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpEZ8-0007Dd-92 for qemu-devel@nongnu.org; Fri, 05 Aug 2011 03:11:34 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:44140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpEZ7-0007DU-TL for qemu-devel@nongnu.org; Fri, 05 Aug 2011 03:11:30 -0400 Received: from smtp08.web.de ( [172.20.5.216]) by fmmailgate03.web.de (Postfix) with ESMTP id 8C0FB19750BB3; Fri, 5 Aug 2011 09:11:27 +0200 (CEST) Received: from [88.65.250.235] (helo=mchn199C.mchp.siemens.de) by smtp08.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1QpEZ5-0003z3-00; Fri, 05 Aug 2011 09:11:27 +0200 Message-ID: <4E3B979E.8030402@web.de> Date: Fri, 05 Aug 2011 09:11:26 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Luiz Capitulino , qemu-devel X-Enigmail-Version: 1.2 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX18EYNq+zcFprOvpkjJnTNs0o6fhgD0Tb4DKHzhX Tpn6C9m4Hw2q2pCvH2/Jjfwv9d8fx8vhvubOvLo5iQpd93tpqz qhxuXQkcQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.234 Cc: Marcelo Tosatti , Michael Tokarev Subject: [Qemu-devel] [PATCH] Reorganize and fix monitor resume after migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka If migration failed in migrate_fd_put_buffer, the monitor may have been resumed not only in the error path of that function but also once again in migrate_fd_put_ready which is called unconditionally by migrate_fd_connect. Fix this by establishing a cleaner policy: the monitor shall be resumed when the migration file is closed, either via callback (migrate_fd_close) or in migrate_fd_cleanup if no file is open (i.e. no callback invoked). Signed-off-by: Jan Kiszka Reported-By: Michael Tokarev Tested-By: Michael Tokarev --- migration.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/migration.c b/migration.c index 2a15b98..756fa62 100644 --- a/migration.c +++ b/migration.c @@ -292,18 +292,17 @@ int migrate_fd_cleanup(FdMigrationState *s) ret = -1; } s->file = NULL; + } else { + if (s->mon) { + monitor_resume(s->mon); + } } - if (s->fd != -1) + if (s->fd != -1) { close(s->fd); - - /* Don't resume monitor until we've flushed all of the buffers */ - if (s->mon) { - monitor_resume(s->mon); + s->fd = -1; } - s->fd = -1; - return ret; } @@ -330,9 +329,6 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size) if (ret == -EAGAIN) { qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s); } else if (ret < 0) { - if (s->mon) { - monitor_resume(s->mon); - } s->state = MIG_STATE_ERROR; notifier_list_notify(&migration_state_notifiers, NULL); } @@ -458,6 +454,9 @@ int migrate_fd_close(void *opaque) { FdMigrationState *s = opaque; + if (s->mon) { + monitor_resume(s->mon); + } qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); return s->close(s); }