From patchwork Wed Jun 8 18:13:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Md Haris Iqbal X-Patchwork-Id: 9165423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C9C6C60572 for ; Wed, 8 Jun 2016 18:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C017A269A3 for ; Wed, 8 Jun 2016 18:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B39142824F; Wed, 8 Jun 2016 18:16:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A1CD269A3 for ; Wed, 8 Jun 2016 18:16:00 +0000 (UTC) Received: from localhost ([::1]:58771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAi1I-0000sA-0H for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 14:16:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAhzL-0008DW-O9 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 14:14:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAhzF-0005z6-Ln for qemu-devel@nongnu.org; Wed, 08 Jun 2016 14:13:58 -0400 Received: from mail-pa0-x244.google.com ([2607:f8b0:400e:c03::244]:35689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAhzF-0005yo-C5 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 14:13:53 -0400 Received: by mail-pa0-x244.google.com with SMTP id gp3so1012844pac.2 for ; Wed, 08 Jun 2016 11:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=MnuWgjpnp46zDeR//UCTd2R5cWTs+oAxXxMR22+cDf0=; b=kZ3VbikGF6LaN31HBbWJmLDlz55p2MNbQBSw+avNMtQtgHvOGPWqjNrPSF0/IFn9FN Xk6YOjJxWxaPBrSq0KrHXMEj3QgkYrptp0CHFrCRCBN+UWA6+iv/Np/ovEhsnl8ZnlGW 8E7Ruy9l9UBke8Hfehitn3y3sOyzFuDUgaIwCupjCxlqckSNOamVAdnpc09X4sAL0F+0 ROc9PF58+wAMdgchkndaWg/4syKv4rNutAk4Mx4/5W4K7v8DVMG1qE9F1TnQU9fuKPid /zUeynsjoKqWY/yq7BINGW6jiIMNg+tMU7a9aFwJOQsNL4VHd5SCcGojcyhw9UDXGDnp YS/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MnuWgjpnp46zDeR//UCTd2R5cWTs+oAxXxMR22+cDf0=; b=FlCyawWvgbKolRy9IccrOFzmC/stFlG0A2WlOzoPiNPnU4XUXr81USSGaGnn947QHF T27BOcvTDwhBQFGzFwEFJh8UJyjHRxZ2R0rIwzkFNFM3/xJ7Twxd8qXyHzPAeOfQcwvz DI+jv7IPDR6PvN9vc73ScryQ0cjzCjL6QFBiDNf2rgaRkbg3lI4eFnlrU0W2hPxmIXNl st/iQXGk0X6UEygOVsre2QYT0Rr12jHPVvFFZ6h/NnBQhHAgBPG8vIImuKLm5q1sGsW3 PK+uTfgeAP1h7wFspEruBnB2zKj2+BZZzo7Q+ZhmtZ6UCcg2La3/YcWbM7VtjyqOBIN7 va+w== X-Gm-Message-State: ALyK8tKDidIkV/wYZ0DVmiCXiDB7ytQokNb2u2pAeEs1EepYQYpoXAzKLhrMkMoJMUf/Jg== X-Received: by 10.66.220.168 with SMTP id px8mr7037401pac.83.1465409632638; Wed, 08 Jun 2016 11:13:52 -0700 (PDT) Received: from dragon-master.nitk.ac.in ([14.139.155.210]) by smtp.googlemail.com with ESMTPSA id i8sm3961107pao.26.2016.06.08.11.13.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 11:13:52 -0700 (PDT) From: Md Haris Iqbal To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 23:43:35 +0530 Message-Id: <1465409615-16365-1-git-send-email-haris.phnx@gmail.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::244 Subject: [Qemu-devel] [Qemu-devel [RFC] [WIP] v1] Adding feature to reconnect with -r option to migrate command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Md Haris Iqbal , dgilbert@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP --- hmp-commands.hx | 10 +++++--- hmp.c | 4 ++- include/migration/migration.h | 1 + migration/migration.c | 60 +++++++++++++++++++++++++++++++++---------- qapi-schema.json | 2 +- qmp-commands.hx | 3 ++- 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 4f4f60a..2e7aed3 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -893,10 +893,11 @@ ETEXI { .name = "migrate", - .args_type = "detach:-d,blk:-b,inc:-i,uri:s", - .params = "[-d] [-b] [-i] uri", + .args_type = "detach:-d,recover:-r,blk:-b,inc:-i,uri:s", + .params = "[-d] [-r] [-b] [-i] uri", .help = "migrate to URI (using -d to not wait for completion)" - "\n\t\t\t -b for migration without shared storage with" + "\n\t\t\t -r to recover from a broken migration\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)", @@ -905,9 +906,10 @@ ETEXI STEXI -@item migrate [-d] [-b] [-i] @var{uri} +@item migrate [-d] [-r] [-b] [-i] @var{uri} @findex migrate Migrate to @var{uri} (using -d to not wait for completion). + -r to recover from a broken migration -b for migration with full copy of disk -i for migration with incremental copy of disk (base image is shared) ETEXI diff --git a/hmp.c b/hmp.c index d510236..ec8fab4 100644 --- a/hmp.c +++ b/hmp.c @@ -1544,12 +1544,14 @@ static void hmp_migrate_status_cb(void *opaque) void hmp_migrate(Monitor *mon, const QDict *qdict) { bool detach = qdict_get_try_bool(qdict, "detach", false); + bool recover = qdict_get_try_bool(qdict, "recover", false); bool blk = qdict_get_try_bool(qdict, "blk", false); bool inc = qdict_get_try_bool(qdict, "inc", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL; - qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err); + qmp_migrate(uri, !!recover, recover, !!blk, blk, !!inc, inc, false, false, + &err); if (err) { error_report_err(err); return; diff --git a/include/migration/migration.h b/include/migration/migration.h index ac2c12c..4a3201b 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -139,6 +139,7 @@ struct MigrationState int state; MigrationParams params; + bool in_recovery; /* State related to return path */ struct { diff --git a/migration/migration.c b/migration/migration.c index 991313a..a77f62e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -933,6 +933,7 @@ MigrationState *migrate_init(const MigrationParams *params) s->xfer_limit = 0; s->cleanup_bh = 0; s->to_dst_file = NULL; + s->in_recovery = false; s->state = MIGRATION_STATUS_NONE; s->params = *params; s->rp_state.from_dst_file = NULL; @@ -992,13 +993,14 @@ void qmp_migrate_incoming(const char *uri, Error **errp) once = false; } -void qmp_migrate(const char *uri, bool has_blk, bool blk, - bool has_inc, bool inc, bool has_detach, bool detach, +void qmp_migrate(const char *uri, bool in_recover, bool recover, bool has_blk, + bool blk, bool has_inc, bool inc, bool has_detach, bool detach, Error **errp) { Error *local_err = NULL; MigrationState *s = migrate_get_current(); MigrationParams params; + bool recovery = in_recover && recover; const char *p; params.blk = has_blk && blk; @@ -1023,7 +1025,31 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, return; } - s = migrate_init(¶ms); + if (recovery ^ atomic_mb_read(&s->in_recovery)) { + if (recovery) { + /* No VM is waiting for recovery and + * recovery option was set + */ + + error_setg(errp, QERR_UNDEFINED_ERROR); + return; + } else { + /* A VM is waiting for recovery and + * no recovery option is set + */ + + error_setg(errp, QERR_UNDEFINED_ERROR); + return; + } + } else { + if (!recovery) { + /* No VM is waiting for recovery and + * no recovery option is set + */ + fprintf(stderr, "hello1\n"); + s = migrate_init(¶ms); + } + } if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); @@ -1767,16 +1793,6 @@ static void *migration_thread(void *opaque) void migrate_fd_connect(MigrationState *s) { - /* This is a best 1st approximation. ns to ms */ - s->expected_downtime = max_downtime/1000000; - s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); - - qemu_file_set_rate_limit(s->to_dst_file, - s->bandwidth_limit / XFER_LIMIT_RATIO); - - /* Notify before starting migration thread */ - notifier_list_notify(&migration_state_notifiers, s); - /* * Open the return path; currently for postcopy but other things might * also want it. @@ -1791,6 +1807,24 @@ void migrate_fd_connect(MigrationState *s) } } + if (atomic_mb_read(&s->in_recovery)) { + atomic_mb_set(&s->in_recovery, 0); + + fprintf(stderr, "recovered\n"); + return; + } + + /* This is a best 1st approximation. ns to ms */ + s->expected_downtime = max_downtime/1000000; + s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); + + qemu_file_set_rate_limit(s->to_dst_file, + s->bandwidth_limit / XFER_LIMIT_RATIO); + + /* Notify before starting migration thread */ + notifier_list_notify(&migration_state_notifiers, s); + + migrate_compress_threads_create(); qemu_thread_create(&s->thread, "migration", migration_thread, s, QEMU_THREAD_JOINABLE); diff --git a/qapi-schema.json b/qapi-schema.json index 54634c4..1b7b1e1 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2070,7 +2070,7 @@ # Since: 0.14.0 ## { 'command': 'migrate', - 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } } + 'data': {'uri': 'str', '*recover': 'bool', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } } ## # @migrate-incoming diff --git a/qmp-commands.hx b/qmp-commands.hx index de896a5..c8a1a93 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -612,7 +612,7 @@ EQMP { .name = "migrate", - .args_type = "detach:-d,blk:-b,inc:-i,uri:s", + .args_type = "detach:-d,recover:-r,blk:-b,inc:-i,uri:s", .mhandler.cmd_new = qmp_marshal_migrate, }, @@ -625,6 +625,7 @@ Migrate to URI. Arguments: - "blk": block migration, full disk copy (json-bool, optional) +- "recover": recover migration (json-bool, optional) - "inc": incremental disk copy (json-bool, optional) - "uri": Destination URI (json-string)