Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807512/?format=api
{ "id": 807512, "url": "http://patchwork.ozlabs.org/api/patches/807512/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1504081950-2528-10-git-send-email-peterx@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504081950-2528-10-git-send-email-peterx@redhat.com>", "list_archive_url": null, "date": "2017-08-30T08:32:06", "name": "[RFC,v2,09/33] migration: implement \"postcopy-pause\" src logic", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ae3515ac9d7239c17feb2124569dff01c31a46c3", "submitter": { "id": 67717, "url": "http://patchwork.ozlabs.org/api/people/67717/?format=api", "name": "Peter Xu", "email": "peterx@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1504081950-2528-10-git-send-email-peterx@redhat.com/mbox/", "series": [ { "id": 552, "url": "http://patchwork.ozlabs.org/api/series/552/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=552", "date": "2017-08-30T08:31:59", "name": "Migration: postcopy failure recovery", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/552/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807512/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807512/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=peterx@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhzlL3FN3z9t2Q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 18:51:58 +1000 (AEST)", "from localhost ([::1]:49096 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dmyj6-0006E8-06\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 04:51:56 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:34061)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1dmyR5-00078n-2y\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:33:20 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1dmyR3-0003ID-Ng\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:33:19 -0400", "from mx1.redhat.com ([209.132.183.28]:47414)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <peterx@redhat.com>) id 1dmyR3-0003Hs-FH\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:33:17 -0400", "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 7FF1E80F6C;\n\tWed, 30 Aug 2017 08:33:16 +0000 (UTC)", "from pxdev.xzpeter.org.com (dhcp-14-103.nay.redhat.com\n\t[10.66.14.103])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 7C022871DD;\n\tWed, 30 Aug 2017 08:33:13 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 7FF1E80F6C", "From": "Peter Xu <peterx@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Wed, 30 Aug 2017 16:32:06 +0800", "Message-Id": "<1504081950-2528-10-git-send-email-peterx@redhat.com>", "In-Reply-To": "<1504081950-2528-1-git-send-email-peterx@redhat.com>", "References": "<1504081950-2528-1-git-send-email-peterx@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tWed, 30 Aug 2017 08:33:16 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [RFC v2 09/33] migration: implement \"postcopy-pause\"\n\tsrc logic", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Laurent Vivier <lvivier@redhat.com>,\n\tAndrea Arcangeli <aarcange@redhat.com>, \n\tJuan Quintela <quintela@redhat.com>,\n\tAlexey Perevalov <a.perevalov@samsung.com>, peterx@redhat.com,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Now when network down for postcopy, the source side will not fail the\nmigration. Instead we convert the status into this new paused state, and\nwe will try to wait for a rescue in the future.\n\nIf a recovery is detected, migration_thread() will reset its local\nvariables to prepare for that.\n\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n migration/migration.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++---\n migration/migration.h | 3 ++\n migration/trace-events | 1 +\n 3 files changed, 98 insertions(+), 4 deletions(-)", "diff": "diff --git a/migration/migration.c b/migration/migration.c\nindex f6130db..8d26ea8 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -993,6 +993,8 @@ static void migrate_fd_cleanup(void *opaque)\n \n notifier_list_notify(&migration_state_notifiers, s);\n block_cleanup_parameters(s);\n+\n+ qemu_sem_destroy(&s->postcopy_pause_sem);\n }\n \n void migrate_fd_error(MigrationState *s, const Error *error)\n@@ -1136,6 +1138,7 @@ MigrationState *migrate_init(void)\n s->migration_thread_running = false;\n error_free(s->error);\n s->error = NULL;\n+ qemu_sem_init(&s->postcopy_pause_sem, 0);\n \n migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);\n \n@@ -1938,6 +1941,80 @@ bool migrate_colo_enabled(void)\n return s->enabled_capabilities[MIGRATION_CAPABILITY_X_COLO];\n }\n \n+typedef enum MigThrError {\n+ /* No error detected */\n+ MIG_THR_ERR_NONE = 0,\n+ /* Detected error, but resumed successfully */\n+ MIG_THR_ERR_RECOVERED = 1,\n+ /* Detected fatal error, need to exit */\n+ MIG_THR_ERR_FATAL = 2,\n+} MigThrError;\n+\n+/*\n+ * We don't return until we are in a safe state to continue current\n+ * postcopy migration. Returns MIG_THR_ERR_RECOVERED if recovered, or\n+ * MIG_THR_ERR_FATAL if unrecovery failure happened.\n+ */\n+static MigThrError postcopy_pause(MigrationState *s)\n+{\n+ assert(s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);\n+ migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,\n+ MIGRATION_STATUS_POSTCOPY_PAUSED);\n+\n+ /* Current channel is possibly broken. Release it. */\n+ assert(s->to_dst_file);\n+ qemu_file_shutdown(s->to_dst_file);\n+ qemu_fclose(s->to_dst_file);\n+ s->to_dst_file = NULL;\n+\n+ error_report(\"Detected IO failure for postcopy. \"\n+ \"Migration paused.\");\n+\n+ /*\n+ * We wait until things fixed up. Then someone will setup the\n+ * status back for us.\n+ */\n+ while (s->state == MIGRATION_STATUS_POSTCOPY_PAUSED) {\n+ qemu_sem_wait(&s->postcopy_pause_sem);\n+ }\n+\n+ trace_postcopy_pause_continued();\n+\n+ return MIG_THR_ERR_RECOVERED;\n+}\n+\n+static MigThrError migration_detect_error(MigrationState *s)\n+{\n+ int ret;\n+\n+ /* Try to detect any file errors */\n+ ret = qemu_file_get_error(s->to_dst_file);\n+\n+ if (!ret) {\n+ /* Everything is fine */\n+ return MIG_THR_ERR_NONE;\n+ }\n+\n+ if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE && ret == -EIO) {\n+ /*\n+ * For postcopy, we allow the network to be down for a\n+ * while. After that, it can be continued by a\n+ * recovery phase.\n+ */\n+ return postcopy_pause(s);\n+ } else {\n+ /*\n+ * For precopy (or postcopy with error outside IO), we fail\n+ * with no time.\n+ */\n+ migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED);\n+ trace_migration_thread_file_err();\n+\n+ /* Time to stop the migration, now. */\n+ return MIG_THR_ERR_FATAL;\n+ }\n+}\n+\n /*\n * Master migration thread on the source VM.\n * It drives the migration and pumps the data down the outgoing channel.\n@@ -1962,6 +2039,7 @@ static void *migration_thread(void *opaque)\n /* The active state we expect to be in; ACTIVE or POSTCOPY_ACTIVE */\n enum MigrationStatus current_active_state = MIGRATION_STATUS_ACTIVE;\n bool enable_colo = migrate_colo_enabled();\n+ MigThrError thr_error;\n \n rcu_register_thread();\n \n@@ -2034,12 +2112,24 @@ static void *migration_thread(void *opaque)\n }\n }\n \n- if (qemu_file_get_error(s->to_dst_file)) {\n- migrate_set_state(&s->state, current_active_state,\n- MIGRATION_STATUS_FAILED);\n- trace_migration_thread_file_err();\n+ /*\n+ * Try to detect any kind of failures, and see whether we\n+ * should stop the migration now.\n+ */\n+ thr_error = migration_detect_error(s);\n+ if (thr_error == MIG_THR_ERR_FATAL) {\n+ /* Stop migration */\n break;\n+ } else if (thr_error == MIG_THR_ERR_RECOVERED) {\n+ /*\n+ * Just recovered from a e.g. network failure, reset all\n+ * the local variables. This is important to avoid\n+ * breaking transferred_bytes and bandwidth calculation\n+ */\n+ initial_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);\n+ initial_bytes = 0;\n }\n+\n current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);\n if (current_time >= initial_time + BUFFER_DELAY) {\n uint64_t transferred_bytes = qemu_ftell(s->to_dst_file) -\ndiff --git a/migration/migration.h b/migration/migration.h\nindex 70e3094..0c957c9 100644\n--- a/migration/migration.h\n+++ b/migration/migration.h\n@@ -149,6 +149,9 @@ struct MigrationState\n bool send_configuration;\n /* Whether we send section footer during migration */\n bool send_section_footer;\n+\n+ /* Needed by postcopy-pause state */\n+ QemuSemaphore postcopy_pause_sem;\n };\n \n void migrate_set_state(int *state, int old_state, int new_state);\ndiff --git a/migration/trace-events b/migration/trace-events\nindex d2910a6..907564b 100644\n--- a/migration/trace-events\n+++ b/migration/trace-events\n@@ -98,6 +98,7 @@ migration_thread_setup_complete(void) \"\"\n open_return_path_on_source(void) \"\"\n open_return_path_on_source_continue(void) \"\"\n postcopy_start(void) \"\"\n+postcopy_pause_continued(void) \"\"\n postcopy_start_set_run(void) \"\"\n source_return_path_thread_bad_end(void) \"\"\n source_return_path_thread_end(void) \"\"\n", "prefixes": [ "RFC", "v2", "09/33" ] }