From patchwork Thu Oct 18 10:22:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 192281 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 6CEE42C0089 for ; Thu, 18 Oct 2012 21:53:08 +1100 (EST) Received: from localhost ([::1]:42959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOnH0-0001kt-SV for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 06:24:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOnGc-0000nu-Rq for qemu-devel@nongnu.org; Thu, 18 Oct 2012 06:24:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOnGW-0001qv-HL for qemu-devel@nongnu.org; Thu, 18 Oct 2012 06:23:54 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:47856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOnGW-0001pn-B7 for qemu-devel@nongnu.org; Thu, 18 Oct 2012 06:23:48 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so8296519pbb.4 for ; Thu, 18 Oct 2012 03:23:48 -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=RsoUYn7agczBNE32NJBIFAT93g1SdH0vY4FyuujEQMc=; b=TUM/wDcctzL4t3yTi5W1p1JscsRqKODlmniQ1PQOTnXNjOBtRcIX4BFFnqgapvWN0o 4xSdrOQRHorgbPxj67fPNzkr1xlWDQ+eRNuaIJYBVjDRFNzjvG07jN1lHoWn1PukkrP4 jDHEPbpmNJZAY9mDgQbsP8/kZN/Zj6TJe7IWV9CtrC4Armg075RVejNnK4R4Q+uSlZoR HgBEnDdLN0M++HP0AAKW1BhW/7myXL5SA4QgR879moSGepEhfaY1eYGnLhHuUKgoW7xu QksBewOxVe4mMJvmXp/bgBrVPDZCys8340rnrRIppPSZ/QPCGIMxrLcpgHW5iVG1HO96 rY/g== Received: by 10.68.221.225 with SMTP id qh1mr64798035pbc.50.1350555828036; Thu, 18 Oct 2012 03:23:48 -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 hu5sm3581193pbc.72.2012.10.18.03.23.45 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Oct 2012 03:23:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 12:22:38 +0200 Message-Id: <1350555758-29988-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1350555758-29988-1-git-send-email-pbonzini@redhat.com> References: <1350555758-29988-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: quintela@redhat.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. Signed-off-by: Paolo Bonzini Reviewed-by: Orit Wasserman --- migration.c | 21 ++++++++++++++++++++- 1 file modificato, 20 inserzioni(+). 1 rimozione(-) diff --git a/migration.c b/migration.c index 0d74753..32d43e7 100644 --- a/migration.c +++ b/migration.c @@ -86,11 +86,13 @@ int qemu_start_incoming_migration(const char *uri, Error **errp) return ret; } -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"); @@ -110,6 +112,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