get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/807522/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 807522,
    "url": "http://patchwork.ozlabs.org/api/patches/807522/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1504081950-2528-33-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-33-git-send-email-peterx@redhat.com>",
    "list_archive_url": null,
    "date": "2017-08-30T08:32:29",
    "name": "[RFC,v2,32/33] migration: allow migrate_incoming for paused VM",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "3efbd300c794be68fde2f536ef75f993ad961b76",
    "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-33-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/807522/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807522/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-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx04.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 3xhztR4CZmz9t2Q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 18:58:07 +1000 (AEST)",
            "from localhost ([::1]:49130 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 1dmyp3-0003tI-AH\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 04:58:05 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:35514)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1dmyTY-0001FE-7B\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:57 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1dmyTX-0004lf-3j\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:52 -0400",
            "from mx1.redhat.com ([209.132.183.28]:43892)\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 1dmyTW-0004ki-R7\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:51 -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 CBD058046A;\n\tWed, 30 Aug 2017 08:35:49 +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 6833184792;\n\tWed, 30 Aug 2017 08:35:44 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com CBD058046A",
        "From": "Peter Xu <peterx@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Wed, 30 Aug 2017 16:32:29 +0800",
        "Message-Id": "<1504081950-2528-33-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.28]);\n\tWed, 30 Aug 2017 08:35:49 +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 32/33] migration: allow migrate_incoming for\n\tpaused VM",
        "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": "migrate_incoming command is previously only used when we were providing\n\"-incoming defer\" in the command line, to defer the incoming migration\nchannel creation.\n\nHowever there is similar requirement when we are paused during postcopy\nmigration. The old incoming channel might have been destroyed already.\nWe may need another new channel for the recovery to happen.\n\nThis patch leveraged the same interface, but allows the user to specify\nincoming migration channel even for paused postcopy.\n\nMeanwhile, now migration listening ports are always detached manually\nusing the tag, rather than using return values of dispatchers.\n\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n migration/exec.c      |  2 +-\n migration/fd.c        |  2 +-\n migration/migration.c | 39 +++++++++++++++++++++++++++++----------\n migration/socket.c    |  2 +-\n 4 files changed, 32 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/migration/exec.c b/migration/exec.c\nindex ef1fb4c..26fc37d 100644\n--- a/migration/exec.c\n+++ b/migration/exec.c\n@@ -49,7 +49,7 @@ static gboolean exec_accept_incoming_migration(QIOChannel *ioc,\n {\n     migration_channel_process_incoming(ioc);\n     object_unref(OBJECT(ioc));\n-    return FALSE; /* unregister */\n+    return TRUE; /* keep it registered */\n }\n \n /*\ndiff --git a/migration/fd.c b/migration/fd.c\nindex e9a548c..7d0aefa 100644\n--- a/migration/fd.c\n+++ b/migration/fd.c\n@@ -49,7 +49,7 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc,\n {\n     migration_channel_process_incoming(ioc);\n     object_unref(OBJECT(ioc));\n-    return FALSE; /* unregister */\n+    return TRUE; /* keep it registered */\n }\n \n /*\ndiff --git a/migration/migration.c b/migration/migration.c\nindex daf356b..5812478 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -175,6 +175,17 @@ void migration_incoming_state_destroy(void)\n     qemu_event_destroy(&mis->main_thread_load_event);\n }\n \n+static bool migrate_incoming_detach_listen(MigrationIncomingState *mis)\n+{\n+    if (mis->listen_task_tag) {\n+        /* Never fail */\n+        g_source_remove(mis->listen_task_tag);\n+        mis->listen_task_tag = 0;\n+        return true;\n+    }\n+    return false;\n+}\n+\n static void migrate_generate_event(int new_state)\n {\n     if (migrate_use_events()) {\n@@ -432,10 +443,9 @@ void migration_fd_process_incoming(QEMUFile *f)\n \n     /*\n      * When reach here, we should not need the listening port any\n-     * more. We'll detach the listening task soon, let's reset the\n-     * listen task tag.\n+     * more.  Detach the listening port explicitly.\n      */\n-    mis->listen_task_tag = 0;\n+    migrate_incoming_detach_listen(mis);\n }\n \n /*\n@@ -1291,14 +1301,25 @@ void migrate_del_blocker(Error *reason)\n void qmp_migrate_incoming(const char *uri, Error **errp)\n {\n     Error *local_err = NULL;\n-    static bool once = true;\n+    MigrationIncomingState *mis = migration_incoming_get_current();\n \n-    if (!deferred_incoming) {\n-        error_setg(errp, \"For use with '-incoming defer'\");\n+    if (!deferred_incoming &&\n+        mis->state != MIGRATION_STATUS_POSTCOPY_PAUSED) {\n+        error_setg(errp, \"For use with '-incoming defer'\"\n+                   \" or PAUSED postcopy migration only.\");\n         return;\n     }\n-    if (!once) {\n-        error_setg(errp, \"The incoming migration has already been started\");\n+\n+    /*\n+     * Destroy existing listening task if exist. Logically this should\n+     * not really happen at all (for either deferred migration or\n+     * postcopy migration, we should both detached the listening\n+     * task). So raise an error but still we safely detach it.\n+     */\n+    if (migrate_incoming_detach_listen(mis)) {\n+        error_report(\"%s: detected existing listen channel, \"\n+                     \"while it should not exist\", __func__);\n+        /* Continue */\n     }\n \n     qemu_start_incoming_migration(uri, &local_err);\n@@ -1307,8 +1328,6 @@ void qmp_migrate_incoming(const char *uri, Error **errp)\n         error_propagate(errp, local_err);\n         return;\n     }\n-\n-    once = false;\n }\n \n bool migration_is_blocked(Error **errp)\ndiff --git a/migration/socket.c b/migration/socket.c\nindex 6ee51ef..e3e453f 100644\n--- a/migration/socket.c\n+++ b/migration/socket.c\n@@ -154,7 +154,7 @@ static gboolean socket_accept_incoming_migration(QIOChannel *ioc,\n out:\n     /* Close listening socket as its no longer needed */\n     qio_channel_close(ioc, NULL);\n-    return FALSE; /* unregister */\n+    return TRUE; /* keep it registered */\n }\n \n \n",
    "prefixes": [
        "RFC",
        "v2",
        "32/33"
    ]
}