From patchwork Fri Nov 2 17:51:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 196686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 080172C00B9 for ; Sat, 3 Nov 2012 04:52:33 +1100 (EST) Received: from localhost ([::1]:59229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TULPz-0003e4-2z for incoming@patchwork.ozlabs.org; Fri, 02 Nov 2012 13:52:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TULPS-0003GU-0G for qemu-devel@nongnu.org; Fri, 02 Nov 2012 13:51:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TULPQ-0005Zi-Ou for qemu-devel@nongnu.org; Fri, 02 Nov 2012 13:51:57 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:52142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TULPQ-0005Nu-ES for qemu-devel@nongnu.org; Fri, 02 Nov 2012 13:51:56 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so2536065pad.4 for ; Fri, 02 Nov 2012 10:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=jUUqHACCyF1mUsG66mVm1uUOvcTXxJPnU5jOl5hzxsY=; b=eJw4lkX9raL2l7DsTfRbyyJj4INkBIi3pZVtNumlFSRf1VdWG7H9qo8/LfkukNRPu1 C6D1iJu96RvS3ZpnArr5c4gLEOxZgxdxhqFuuOxxNoCU1VK3qto6phrHNMIIgV/Jd3Yl XN2FzLLzIYlCfTXKjtqmJjUfBuEy0lRiVeJN3Bti3h6ijiOmMhMBZLA5DIDjEimVcY5o ggWk6b/0t+/qvoOhVP2PcRTSETLVgLSCrFdK3b2r3Adt1j0hvNrXm+yBFiSx9Tg0CjNx znOZbbfJNKJLbz0brKKhB6eVm52UD9Yu0KyOfoDO05C5lxeXM2avNhhaJkZBgH6/gxO+ n1uQ== Received: by 10.68.239.9 with SMTP id vo9mr1171138pbc.83.1351878715924; Fri, 02 Nov 2012 10:51:55 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id a4sm6052116pax.12.2012.11.02.10.51.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Nov 2012 10:51:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 2 Nov 2012 18:51:05 +0100 Message-Id: <1351878665-32413-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1351878665-32413-1-git-send-email-pbonzini@redhat.com> References: <1351878665-32413-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.45 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to a coroutine 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 The final part of incoming migration, which now consists of process_incoming_migration for all protocols, is thus made non-blocking. Reviewed-by: Orit Wasserman Signed-off-by: Paolo Bonzini --- migration.c | 21 ++++++++++++++++++++- 1 file modificato, 20 inserzioni(+). 1 rimozione(-) diff --git a/migration.c b/migration.c index 2741d97..73ce170 100644 --- a/migration.c +++ b/migration.c @@ -83,11 +83,13 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) } } -void process_incoming_migration(QEMUFile *f) +static void process_incoming_migration_co(void *opaque) { + QEMUFile *f = opaque; int ret; ret = qemu_loadvm_state(f); + qemu_set_fd_handler(qemu_get_fd(f), NULL, NULL, NULL); qemu_fclose(f); if (ret < 0) { fprintf(stderr, "load of migration failed\n"); @@ -107,6 +109,23 @@ void process_incoming_migration(QEMUFile *f) } } +static void enter_migration_coroutine(void *opaque) +{ + Coroutine *co = opaque; + qemu_coroutine_enter(co, NULL); +} + +void process_incoming_migration(QEMUFile *f) +{ + Coroutine *co = qemu_coroutine_create(process_incoming_migration_co); + int fd = qemu_get_fd(f); + + assert(fd != -1); + socket_set_nonblock(fd); + qemu_set_fd_handler(fd, enter_migration_coroutine, NULL, co); + qemu_coroutine_enter(co, f); +} + /* amount of nanoseconds we are willing to wait for migration to be down. * the choice of nanoseconds is because it is the maximum resolution that * get_clock() can achieve. It is an internal measure. All user-visible