From patchwork Mon Nov 14 21:09:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 125613 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 AB53EB720C for ; Tue, 15 Nov 2011 08:11:22 +1100 (EST) Received: from localhost ([::1]:49075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ3o8-0004g4-Lt for incoming@patchwork.ozlabs.org; Mon, 14 Nov 2011 16:11:12 -0500 Received: from eggs.gnu.org ([140.186.70.92]:50025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ3nj-0003j1-Lf for qemu-devel@nongnu.org; Mon, 14 Nov 2011 16:10:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQ3nh-0002to-EY for qemu-devel@nongnu.org; Mon, 14 Nov 2011 16:10:47 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:39733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ3nh-0002td-6e for qemu-devel@nongnu.org; Mon, 14 Nov 2011 16:10:45 -0500 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Nov 2011 14:10:41 -0700 Received: from d03relay02.boulder.ibm.com ([9.17.195.227]) by e31.co.us.ibm.com ([192.168.1.131]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 Nov 2011 14:10:06 -0700 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pAEL9qLa138692 for ; Mon, 14 Nov 2011 14:10:01 -0700 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pAEL9pDR032686 for ; Mon, 14 Nov 2011 14:09:52 -0700 Received: from titi.austin.rr.com (sig-9-65-229-191.mts.ibm.com [9.65.229.191]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pAEL9ncb032518; Mon, 14 Nov 2011 14:09:50 -0700 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 14 Nov 2011 15:09:43 -0600 Message-Id: <1321304987-23041-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 x-cbid: 11111421-7282-0000-0000-000003C5622A X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.149 Cc: Kevin Wolf , Lucas Meneghel Rodrigues , Anthony Liguori , Stefan Hajnoczi , Juan Quintela , Avi Kivity Subject: [Qemu-devel] [PATCH 1/5] migrate: add migration blockers 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 This lets different subsystems register an Error that is thrown whenever migration is attempted. This works nicely because it gracefully supports things like hotplug. Right now, if multiple errors are registered, only one of them is reported. I expect that for 1.1, we'll extend query-migrate to return all of the reasons why migration is disabled at any given point in time. Signed-off-by: Anthony Liguori --- migration.c | 18 ++++++++++++++++++ migration.h | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/migration.c b/migration.c index 41c3c24..6764d3a 100644 --- a/migration.c +++ b/migration.c @@ -398,6 +398,18 @@ static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc) return s; } +static GSList *migration_blockers; + +void migrate_add_blocker(Error *reason) +{ + migration_blockers = g_slist_prepend(migration_blockers, reason); +} + +void migrate_del_blocker(Error *reason) +{ + migration_blockers = g_slist_remove(migration_blockers, reason); +} + int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) { MigrationState *s = migrate_get_current(); @@ -417,6 +429,12 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) return -1; } + if (migration_blockers) { + Error *err = migration_blockers->data; + qerror_report_err(err); + return -1; + } + s = migrate_init(mon, detach, blk, inc); if (strstart(uri, "tcp:", &p)) { diff --git a/migration.h b/migration.h index 1b8ee58..0682179 100644 --- a/migration.h +++ b/migration.h @@ -17,6 +17,7 @@ #include "qdict.h" #include "qemu-common.h" #include "notify.h" +#include "error.h" typedef struct MigrationState MigrationState; @@ -89,4 +90,18 @@ int ram_load(QEMUFile *f, void *opaque, int version_id); extern int incoming_expected; +/** + * @migrate_add_blocker - prevent migration from proceeding + * + * @reason - an error to be returned whenever migration is attempted + */ +void migrate_add_blocker(Error *reason); + +/** + * @migrate_del_blocker - remove a blocking error from migration + * + * @reason - the error blocking migration + */ +void migrate_del_blocker(Error *reason); + #endif