get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2177610,
    "url": "http://patchwork.ozlabs.org/api/patches/2177610/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20251226211930.27565-24-farosas@suse.de/",
    "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": "<20251226211930.27565-24-farosas@suse.de>",
    "list_archive_url": null,
    "date": "2025-12-26T21:19:25",
    "name": "[RFC,23/25] migration: Move channel parsing to channel.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "352836dd869526082d7fc24ac99ec08c881adc03",
    "submitter": {
        "id": 85343,
        "url": "http://patchwork.ozlabs.org/api/people/85343/?format=api",
        "name": "Fabiano Rosas",
        "email": "farosas@suse.de"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20251226211930.27565-24-farosas@suse.de/mbox/",
    "series": [
        {
            "id": 486505,
            "url": "http://patchwork.ozlabs.org/api/series/486505/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=486505",
            "date": "2025-12-26T21:19:04",
            "name": "migration: Cleanup early connection code",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/486505/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2177610/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2177610/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@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=Gp9dP/fy;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=LSpAvitn;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=Gp9dP/fy;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=LSpAvitn;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)",
            "smtp-out1.suse.de;\n dkim=pass header.d=suse.de header.s=susede2_rsa header.b=\"Gp9dP/fy\";\n dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=LSpAvitn"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4ddJT16BK4z1y3s\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 27 Dec 2025 08:21:25 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vZFEb-0001a3-TO; Fri, 26 Dec 2025 16:20:29 -0500",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1vZFEZ-0001Ya-Sb\n for qemu-devel@nongnu.org; Fri, 26 Dec 2025 16:20:28 -0500",
            "from smtp-out1.suse.de ([195.135.223.130])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1vZFEY-00049K-16\n for qemu-devel@nongnu.org; Fri, 26 Dec 2025 16:20:27 -0500",
            "from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org\n [IPv6:2a07:de40:b281:104:10:150:64:97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 291C3336AB;\n Fri, 26 Dec 2025 21:20:13 +0000 (UTC)",
            "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1E7D93EA63;\n Fri, 26 Dec 2025 21:20:11 +0000 (UTC)",
            "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id WPfHMwv8TmnwJwAAD6G6ig\n (envelope-from <farosas@suse.de>); Fri, 26 Dec 2025 21:20:11 +0000"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1766784013;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CvDhQbE5OymhaWJ4FEWOmJTckfPb4O/dEFgWzep2NL0=;\n b=Gp9dP/fymVPrry4ezM1dE+6KT3WDW+NH6OSs9/WsNRPEKXNWzKamj8PeKho8G3w8mvsuAk\n CAuh5euV0Db6T711A6oyZHZgInut3dIwANJ7OPrfPKYvWWAIHtW/S4H0W9PBwfIygdl/zi\n SUTjTWwh0ZIQWqQRy3d9kkdjXB8g1Qs=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1766784013;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CvDhQbE5OymhaWJ4FEWOmJTckfPb4O/dEFgWzep2NL0=;\n b=LSpAvitnxQrNt7bOhwbatzwKZLxQLkhkf9U+rZOkL4YJn0fVSZKQFdMMfhgn0890frY6fh\n YCzKNS/q2Nfy/ACw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1766784013;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CvDhQbE5OymhaWJ4FEWOmJTckfPb4O/dEFgWzep2NL0=;\n b=Gp9dP/fymVPrry4ezM1dE+6KT3WDW+NH6OSs9/WsNRPEKXNWzKamj8PeKho8G3w8mvsuAk\n CAuh5euV0Db6T711A6oyZHZgInut3dIwANJ7OPrfPKYvWWAIHtW/S4H0W9PBwfIygdl/zi\n SUTjTWwh0ZIQWqQRy3d9kkdjXB8g1Qs=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1766784013;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CvDhQbE5OymhaWJ4FEWOmJTckfPb4O/dEFgWzep2NL0=;\n b=LSpAvitnxQrNt7bOhwbatzwKZLxQLkhkf9U+rZOkL4YJn0fVSZKQFdMMfhgn0890frY6fh\n YCzKNS/q2Nfy/ACw=="
        ],
        "From": "Fabiano Rosas <farosas@suse.de>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "peterx@redhat.com",
        "Subject": "[RFC PATCH 23/25] migration: Move channel parsing to channel.c",
        "Date": "Fri, 26 Dec 2025 18:19:25 -0300",
        "Message-ID": "<20251226211930.27565-24-farosas@suse.de>",
        "X-Mailer": "git-send-email 2.51.0",
        "In-Reply-To": "<20251226211930.27565-1-farosas@suse.de>",
        "References": "<20251226211930.27565-1-farosas@suse.de>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Spamd-Result": "default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000];\n R_MISSING_CHARSET(0.50)[];\n R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+];\n FUZZY_RATELIMITED(0.00)[rspamd.com];\n DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim,suse.de:mid];\n RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[];\n RCPT_COUNT_TWO(0.00)[2];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[];\n SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from];\n RCVD_TLS_ALL(0.00)[]; TO_DN_NONE(0.00)[];\n RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n DKIM_TRACE(0.00)[suse.de:+]",
        "X-Rspamd-Action": "no action",
        "X-Rspamd-Server": "rspamd2.dmz-prg2.suse.org",
        "X-Rspamd-Queue-Id": "291C3336AB",
        "X-Spam-Score": "-3.01",
        "Received-SPF": "pass client-ip=195.135.223.130; envelope-from=farosas@suse.de;\n helo=smtp-out1.suse.de",
        "X-Spam_score_int": "-43",
        "X-Spam_score": "-4.4",
        "X-Spam_bar": "----",
        "X-Spam_report": "(-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://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 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "Encapsulate the MigrationChannelList parsing in a new\nmigrate_channels_parse() located at channel.c.\n\nSigned-off-by: Fabiano Rosas <farosas@suse.de>\n---\n migration/channel.c   | 54 +++++++++++++++++++++++++++++++++++++++++++\n migration/channel.h   |  5 ++++\n migration/migration.c | 50 +++++++++++----------------------------\n 3 files changed, 73 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/migration/channel.c b/migration/channel.c\nindex ba9aa1c58b..8b43c3d983 100644\n--- a/migration/channel.c\n+++ b/migration/channel.c\n@@ -11,6 +11,7 @@\n  */\n \n #include \"qemu/osdep.h\"\n+#include \"qemu/cutils.h\"\n #include \"channel.h\"\n #include \"exec.h\"\n #include \"fd.h\"\n@@ -20,7 +21,9 @@\n #include \"migration.h\"\n #include \"multifd.h\"\n #include \"options.h\"\n+#include \"qapi/clone-visitor.h\"\n #include \"qapi/qapi-types-migration.h\"\n+#include \"qapi/qapi-visit-migration.h\"\n #include \"qapi/error.h\"\n #include \"qemu-file.h\"\n #include \"qemu/yank.h\"\n@@ -314,3 +317,54 @@ int migration_channel_read_peek(QIOChannel *ioc,\n \n     return 0;\n }\n+\n+bool migrate_channels_parse(MigrationChannelList *channels,\n+                            MigrationChannel **main_channelp,\n+                            MigrationChannel **cpr_channelp,\n+                            Error **errp)\n+{\n+    MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX] = { NULL };\n+    bool single_channel;\n+\n+    if (cpr_channelp) {\n+        single_channel = false;\n+    } else {\n+        single_channel = true;\n+    }\n+\n+    for ( ; channels; channels = channels->next) {\n+        MigrationChannelType type;\n+\n+        type = channels->value->channel_type;\n+        if (channelv[type]) {\n+            error_setg(errp, \"Channel list has more than one %s entry\",\n+                       MigrationChannelType_str(type));\n+            return false;\n+        }\n+        channelv[type] = channels->value;\n+\n+        if (single_channel) {\n+            if (channels->next) {\n+                error_setg(errp, \"Channel list must have only one entry, \"\n+                           \"for type 'main'\");\n+                return false;\n+            }\n+            break;\n+        }\n+    }\n+\n+    if (cpr_channelp) {\n+        *cpr_channelp = QAPI_CLONE(MigrationChannel,\n+                                   channelv[MIGRATION_CHANNEL_TYPE_CPR]);\n+    }\n+\n+    *main_channelp = QAPI_CLONE(MigrationChannel,\n+                                channelv[MIGRATION_CHANNEL_TYPE_MAIN]);\n+\n+    if (!(*main_channelp)->addr) {\n+        error_setg(errp, \"Channel list has no main entry\");\n+        return false;\n+    }\n+\n+    return true;\n+}\ndiff --git a/migration/channel.h b/migration/channel.h\nindex 86934fee38..b3276550b7 100644\n--- a/migration/channel.h\n+++ b/migration/channel.h\n@@ -51,4 +51,9 @@ static inline bool migration_connect_incoming(MigrationAddress *addr,\n {\n     return migration_connect(addr, false, errp);\n }\n+\n+bool migrate_channels_parse(MigrationChannelList *channels,\n+                            MigrationChannel **main_channelp,\n+                            MigrationChannel **cpr_channelp,\n+                            Error **errp);\n #endif\ndiff --git a/migration/migration.c b/migration/migration.c\nindex c11cd4ebf6..6064f1e5ea 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -741,8 +741,7 @@ static void qemu_setup_incoming_migration(const char *uri, bool has_channels,\n                                           MigrationChannelList *channels,\n                                           Error **errp)\n {\n-    g_autoptr(MigrationChannel) channel = NULL;\n-    MigrationAddress *addr = NULL;\n+    g_autoptr(MigrationChannel) main_ch = NULL;\n     MigrationIncomingState *mis = migration_incoming_get_current();\n \n     /*\n@@ -754,25 +753,20 @@ static void qemu_setup_incoming_migration(const char *uri, bool has_channels,\n     }\n \n     if (channels) {\n-        /* To verify that Migrate channel list has only item */\n-        if (channels->next) {\n-            error_setg(errp, \"Channel list must have only one entry, \"\n-                             \"for type 'main'\");\n+        if (!migrate_channels_parse(channels, &main_ch, NULL, errp)) {\n             return;\n         }\n-        addr = channels->value->addr;\n     }\n \n     if (uri) {\n         /* caller uses the old URI syntax */\n-        if (!migrate_uri_parse(uri, &channel, errp)) {\n+        if (!migrate_uri_parse(uri, &main_ch, errp)) {\n             return;\n         }\n-        addr = channel->addr;\n     }\n \n     /* transport mechanism not suitable for migration? */\n-    if (!migration_transport_compatible(addr, errp)) {\n+    if (!migration_transport_compatible(main_ch->addr, errp)) {\n         return;\n     }\n \n@@ -784,7 +778,7 @@ static void qemu_setup_incoming_migration(const char *uri, bool has_channels,\n         return;\n     }\n \n-    migration_connect_incoming(addr, errp);\n+    migration_connect_incoming(main_ch->addr, errp);\n \n     /* Close cpr socket to tell source that we are listening */\n     cpr_state_close();\n@@ -2127,10 +2121,8 @@ void qmp_migrate(const char *uri, bool has_channels,\n                  MigrationChannelList *channels, bool has_detach, bool detach,\n                  bool has_resume, bool resume, Error **errp)\n {\n-    g_autoptr(MigrationChannel) channel = NULL;\n-    MigrationAddress *addr = NULL;\n-    MigrationChannel *channelv[MIGRATION_CHANNEL_TYPE__MAX] = { NULL };\n-    MigrationChannel *cpr_channel = NULL;\n+    g_autoptr(MigrationChannel) main_ch = NULL;\n+    g_autoptr(MigrationChannel) cpr_ch = NULL;\n \n     /*\n      * Having preliminary checks for uri and channel\n@@ -2141,38 +2133,24 @@ void qmp_migrate(const char *uri, bool has_channels,\n     }\n \n     if (channels) {\n-        for ( ; channels; channels = channels->next) {\n-            MigrationChannelType type = channels->value->channel_type;\n-\n-            if (channelv[type]) {\n-                error_setg(errp, \"Channel list has more than one %s entry\",\n-                           MigrationChannelType_str(type));\n-                return;\n-            }\n-            channelv[type] = channels->value;\n-        }\n-        cpr_channel = channelv[MIGRATION_CHANNEL_TYPE_CPR];\n-        addr = channelv[MIGRATION_CHANNEL_TYPE_MAIN]->addr;\n-        if (!addr) {\n-            error_setg(errp, \"Channel list has no main entry\");\n+        if (!migrate_channels_parse(channels, &main_ch, &cpr_ch, errp)) {\n             return;\n         }\n     }\n \n     if (uri) {\n         /* caller uses the old URI syntax */\n-        if (!migrate_uri_parse(uri, &channel, errp)) {\n+        if (!migrate_uri_parse(uri, &main_ch, errp)) {\n             return;\n         }\n-        addr = channel->addr;\n     }\n \n     /* transport mechanism not suitable for migration? */\n-    if (!migration_transport_compatible(addr, errp)) {\n+    if (!migration_transport_compatible(main_ch->addr, errp)) {\n         return;\n     }\n \n-    if (migrate_mode() == MIG_MODE_CPR_TRANSFER && !cpr_channel) {\n+    if (migrate_mode() == MIG_MODE_CPR_TRANSFER && !cpr_ch) {\n         error_setg(errp, \"missing 'cpr' migration channel\");\n         return;\n     }\n@@ -2189,7 +2167,7 @@ void qmp_migrate(const char *uri, bool has_channels,\n      */\n     Error *local_err = NULL;\n \n-    if (!cpr_state_save(cpr_channel, &local_err)) {\n+    if (!cpr_state_save(cpr_ch, &local_err)) {\n         goto out;\n     }\n \n@@ -2205,10 +2183,10 @@ void qmp_migrate(const char *uri, bool has_channels,\n      */\n     if (migrate_mode() == MIG_MODE_CPR_TRANSFER) {\n         migrate_hup_add(cpr_state_ioc(), (GSourceFunc)qmp_migrate_finish_cb,\n-                        QAPI_CLONE(MigrationAddress, addr));\n+                        QAPI_CLONE(MigrationAddress, main_ch->addr));\n \n     } else {\n-        qmp_migrate_finish(addr, &local_err);\n+        qmp_migrate_finish(main_ch->addr, &local_err);\n     }\n \n out:\n",
    "prefixes": [
        "RFC",
        "23/25"
    ]
}