From patchwork Mon Jun 4 09:57:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 162729 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 28882100962 for ; Mon, 4 Jun 2012 21:12:31 +1000 (EST) Received: from localhost ([::1]:39993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU4c-00029e-HJ for incoming@patchwork.ozlabs.org; Mon, 04 Jun 2012 05:59:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU33-0008TV-9A for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:58:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbU2r-0004dn-D2 for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:58:04 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:46488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbU2q-0004aQ-TN for qemu-devel@nongnu.org; Mon, 04 Jun 2012 05:57:53 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 784194899A; Mon, 4 Jun 2012 18:57:47 +0900 (JST) Received: (nullmailer pid 5176 invoked by uid 1000); Mon, 04 Jun 2012 09:57:46 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Mon, 4 Jun 2012 18:57:36 +0900 Message-Id: <3a9d30837aaae505af285a425fab232637aec3cf.1338802192.git.yamahata@valinux.co.jp> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 210.128.90.3 Cc: benoit.hudzia@gmail.com, aarcange@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, t.hirofuchi@aist.go.jp, dlaor@redhat.com, satoshi.itoh@aist.go.jp, mdroth@linux.vnet.ibm.com, yoshikawa.takuya@oss.ntt.co.jp, owasserm@redhat.com, avi@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v2 34/41] postcopy outgoing: add -p and -n option to migrate command 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 Added -p option to migrate command for postcopy mode and introduce postcopy parameter for migration to indicate that postcopy mode is enabled. Add -n option for postcopy migration which indicates disabling background transfer. Signed-off-by: Isaku Yamahata --- Chnages v1 -> v2: - catch up for qapi change --- hmp-commands.hx | 12 ++++++++---- hmp.c | 6 +++++- migration.c | 9 +++++++++ migration.h | 2 ++ qapi-schema.json | 3 ++- qmp-commands.hx | 4 +++- savevm.c | 2 ++ 7 files changed, 31 insertions(+), 7 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 18cb415..3c647f7 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -798,23 +798,27 @@ ETEXI { .name = "migrate", - .args_type = "detach:-d,blk:-b,inc:-i,uri:s", - .params = "[-d] [-b] [-i] uri", + .args_type = "detach:-d,blk:-b,inc:-i,postcopy:-p,nobg:-n,uri:s", + .params = "[-d] [-b] [-i] [-p [-n]] uri", .help = "migrate to URI (using -d to not wait for completion)" "\n\t\t\t -b for migration without shared storage with" " full copy of disk\n\t\t\t -i for migration without " "shared storage with incremental copy of disk " - "(base image shared between src and destination)", + "(base image shared between src and destination)" + "\n\t\t\t-p for migration with postcopy mode enabled" + "\n\t\t\t-n for no background transfer of postcopy mode", .mhandler.cmd = hmp_migrate, }, STEXI -@item migrate [-d] [-b] [-i] @var{uri} +@item migrate [-d] [-b] [-i] [-p [-n]] @var{uri} @findex migrate Migrate to @var{uri} (using -d to not wait for completion). -b for migration with full copy of disk -i for migration with incremental copy of disk (base image is shared) + -p for migration with postcopy mode enabled + -n for migration with postcopy mode enabled without background transfer ETEXI { diff --git a/hmp.c b/hmp.c index bb0952e..d546a52 100644 --- a/hmp.c +++ b/hmp.c @@ -911,10 +911,14 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) int detach = qdict_get_try_bool(qdict, "detach", 0); int blk = qdict_get_try_bool(qdict, "blk", 0); int inc = qdict_get_try_bool(qdict, "inc", 0); + int postcopy = qdict_get_try_bool(qdict, "postcopy", 0); + int nobg = qdict_get_try_bool(qdict, "nobg", 0); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL; - qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err); + qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, + !!postcopy, postcopy, !!nobg, nobg, + &err); if (err) { monitor_printf(mon, "migrate: %s\n", error_get_pretty(err)); error_free(err); diff --git a/migration.c b/migration.c index 3b97aec..7ad62ef 100644 --- a/migration.c +++ b/migration.c @@ -388,12 +388,15 @@ void migrate_del_blocker(Error *reason) void qmp_migrate(const char *uri, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, + bool has_postcopy, bool postcopy, bool has_nobg, bool nobg, Error **errp) { MigrationState *s = migrate_get_current(); MigrationParams params = { .blk = false, .shared = false, + .postcopy = false, + .nobg = false, }; const char *p; int ret; @@ -404,6 +407,12 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, if (has_inc) { params.shared = inc; } + if (has_postcopy) { + params.postcopy = postcopy; + } + if (has_nobg) { + params.nobg = nobg; + } if (s->state == MIG_STATE_ACTIVE) { error_set(errp, QERR_MIGRATION_ACTIVE); diff --git a/migration.h b/migration.h index 4bbcf06..091b446 100644 --- a/migration.h +++ b/migration.h @@ -22,6 +22,8 @@ struct MigrationParams { int blk; int shared; + int postcopy; + int nobg; }; typedef struct MigrationState MigrationState; diff --git a/qapi-schema.json b/qapi-schema.json index 2ca7195..5861fb9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1717,7 +1717,8 @@ # Since: 0.14.0 ## { 'command': 'migrate', - 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } } + 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' , + '*postcopy': 'bool', '*nobg': 'bool'} } # @xen-save-devices-state: # diff --git a/qmp-commands.hx b/qmp-commands.hx index db980fa..7b5e5b7 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -469,7 +469,7 @@ EQMP { .name = "migrate", - .args_type = "detach:-d,blk:-b,inc:-i,uri:s", + .args_type = "detach:-d,blk:-b,inc:-i,postcopy:-p,nobg:-n,uri:s", .mhandler.cmd_new = qmp_marshal_input_migrate, }, @@ -483,6 +483,8 @@ Arguments: - "blk": block migration, full disk copy (json-bool, optional) - "inc": incremental disk copy (json-bool, optional) +- "postcopy": postcopy migration (json-bool, optional) +- "nobg": postcopy without background transfer (json-bool, optional) - "uri": Destination URI (json-string) Example: diff --git a/savevm.c b/savevm.c index 3adabad..bd4b5bf 100644 --- a/savevm.c +++ b/savevm.c @@ -1762,6 +1762,8 @@ static int qemu_savevm_state(QEMUFile *f) MigrationParams params = { .blk = 0, .shared = 0, + .postcopy = 0, + .nobg = 0, }; if (qemu_savevm_state_blocked(NULL)) {