Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217386/?format=api
{ "id": 2217386, "url": "http://patchwork.ozlabs.org/api/patches/2217386/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260328121215.159532-1-vikingtc4@gmail.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": "<20260328121215.159532-1-vikingtc4@gmail.com>", "list_archive_url": null, "date": "2026-03-28T12:12:14", "name": "migration: fix QIOChannelFile leak on error in file_connect_outgoing", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "5b469e523ef2ad96b62edb2e77400a8a04409bf0", "submitter": { "id": 92831, "url": "http://patchwork.ozlabs.org/api/people/92831/?format=api", "name": "Trieu Huynh", "email": "vikingtc4@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260328121215.159532-1-vikingtc4@gmail.com/mbox/", "series": [ { "id": 497865, "url": "http://patchwork.ozlabs.org/api/series/497865/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497865", "date": "2026-03-28T12:12:14", "name": "migration: fix QIOChannelFile leak on error in file_connect_outgoing", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/497865/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217386/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217386/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 (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=ZRE+Dp6B;\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)" ], "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 4fjbyF5wqxz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 28 Mar 2026 23:13:24 +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 1w6SWv-0000MF-LU; Sat, 28 Mar 2026 08:12:42 -0400", "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 <vikingtc4@gmail.com>)\n id 1w6SWf-0000Kt-W9\n for qemu-devel@nongnu.org; Sat, 28 Mar 2026 08:12:26 -0400", "from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <vikingtc4@gmail.com>)\n id 1w6SWe-00022n-3l\n for qemu-devel@nongnu.org; Sat, 28 Mar 2026 08:12:25 -0400", "by mail-pj1-x1031.google.com with SMTP id\n 98e67ed59e1d1-35d9749c26dso248578a91.2\n for <qemu-devel@nongnu.org>; Sat, 28 Mar 2026 05:12:23 -0700 (PDT)", "from trieu2-huynh-trieuhpn-ubuntu24.bee-live.svc.cluster.local\n ([27.122.242.65]) by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-35d94d289f5sm2611535a91.5.2026.03.28.05.12.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 28 Mar 2026 05:12:21 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774699942; x=1775304742; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=P94kZ6gNvJnQQgGZCSXhoFOZYrayE3/o+VsQAx7U6uA=;\n b=ZRE+Dp6Bo3CD0/0wxNCLGBceW6FupFTpS/iQ91JfOiPMzN6rnmTGs9fz59r/RnS1Sl\n nNUEgejWNB1WbC5brfmtHMhyNnBlOArUReOq1SrkgrCRcDQjnZzrv0oUje2JT2LSrxRC\n bd2z1zCaKw9j3AYQ1fKAJkLUwUaUWgQ/C7yI4kQstYjbTt+kf+SwTT0Tu4GrWwn3tsOS\n ajg7rJJRRpEZHRJd3h123mU0ocEw9CQxgxjVJa4nmNa081sfg3e3zDyynfQQZlckd31o\n jSb/ooPTI2ctsb3xk+stvCap45whYsQJMMLwWyOpe+ltw1GZo3NRqnRATDck/HZbDsp6\n KRbw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774699942; x=1775304742;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=P94kZ6gNvJnQQgGZCSXhoFOZYrayE3/o+VsQAx7U6uA=;\n b=W/hEWuOSO9gX9bugGI4pGM8ryh5pqrSzSZx6gLbct2WkvsZ7D1FUOixdw0meabIwq5\n ak6ruyS8Ya5a9k5zF5JqQUVtguAAEbVeP3hWJwy8gfCILspUyVq4o0GJmSNIUsAmxLGn\n oVyi6dVUflSWVYQ/bsgAgB4CWiqcsV4OgJFtONKOyOsi26A9E+3Clm/7g9YRhcC+QobN\n OlOuOjB891xoOA8NtIcOArQ3xd8y0sxKwIYwkQqr/oIhM+KxU1JageQ/W3gfcvNaQO3o\n uxxI5M9jC+ttJ/mspPAmSgpqAfN/HDZaOAUqEwmrO34vbrI5uaquGrWCddaNaLFEt9g8\n Hukg==", "X-Gm-Message-State": "AOJu0YyMrDEyqA0B7q56JfsWKjp3zYX5z+veYvhFZrSJXYQIooJu11gH\n rAWU2SgUNo6zmE1WTjvqLAsVUNEp9UTAciwhbhF3eVBOFgMI01N4jjBXmakZJGer", "X-Gm-Gg": "ATEYQzwP1E92CLI6MyBrZaNqsktee2cFxpPUnyTTKhkHT/EUv1dMTKoGJBSGRM630CU\n 9zxM//KC96QlCh2QCbRAEQTwlz/m0H2GhPO+xVYLc1p73jxJ1DvZ5NLFeOf2ZaezCPwfaiLJkeV\n HGwvGrIqLuc9lvL/AoRRIs58jvnnvWe9rkCSXLyDzQnHSiEIonAOUaaRwDpyURF22wGqDIIDPZq\n L/A2RQa9jRsa93u/ZzotFYrZP8wkg0CXJij/27RExXhKQKg1ujihuIIDjhaB239Lmakru0gsruT\n nnQyeu3PJObw4Oqe1HorCMIoB6S+AxSP+U4zyW9irjyAr3hl2S8RYjhr3S79Lzr48VuLp4VoKd5\n hAxycwpx9p+UD46SKTmdAkXLwcFKrWU+Gp2SJrah+We+wCuB8ijjHp08zWasIx4AHnicssRLLau\n mtYVmkmp6JZe4tqYU3Oxa9M9NYc+PkEGDJbgv9xepENn/jgzsTLlkGyIkTlcx4hmDgrOK975MN/\n 97pHIFToXzZ3a3tWbY5", "X-Received": "by 2002:a17:90a:d44c:b0:35b:e844:3bf with SMTP id\n 98e67ed59e1d1-35c300bec56mr5848803a91.29.1774699941747;\n Sat, 28 Mar 2026 05:12:21 -0700 (PDT)", "From": "Trieu Huynh <vikingtc4@gmail.com>", "To": "qemu-devel@nongnu.org", "Cc": "Trieu Huynh <vikingtc4@gmail.com>, Peter Xu <peterx@redhat.com>,\n Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>,\n Paolo Bonzini <pbonzini@redhat.com>", "Subject": "[PATCH] migration: fix QIOChannelFile leak on error in\n file_connect_outgoing", "Date": "Sat, 28 Mar 2026 21:12:14 +0900", "Message-ID": "<20260328121215.159532-1-vikingtc4@gmail.com>", "X-Mailer": "git-send-email 2.43.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2607:f8b0:4864:20::1031;\n envelope-from=vikingtc4@gmail.com; helo=mail-pj1-x1031.google.com", "X-Spam_score_int": "-17", "X-Spam_score": "-1.8", "X-Spam_bar": "-", "X-Spam_report": "(-1.8 / 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 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, 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 development <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": "Commit 03a680c978 changed g_autoptr(QIOChannelFile) to a plain pointer\nbut failed to restore the necessary object_unref() calls on error paths.\nPreviously, these were handled implicitly by the g_autoptr cleanup\nmechanism.\n\nTwo error paths currently leak the QIOChannelFile object and its\nunderlying file descriptor:\n\n 1. When ftruncate() fails (e.g., on character or block devices).\n 2. When qio_channel_io_seek() fails after the channel is created.\n\nIn environments that retry migration automatically (e.g., libvirt),\nthese FDs accumulate until QEMU hits RLIMIT_NOFILE and fails with\nEMFILE (Too many open files).\n\nAdd the missing object_unref() calls to both error paths to ensure\nresources are properly released.\n\nSigned-off-by: Trieu Huynh <vikingtc4@gmail.com>\n---\n migration/file.c | 2 ++\n tests/qtest/migration/file-tests.c | 48 ++++++++++++++++++++++++++++++\n 2 files changed, 50 insertions(+)", "diff": "diff --git a/migration/file.c b/migration/file.c\nindex 5618aced49..962b4b3a1b 100644\n--- a/migration/file.c\n+++ b/migration/file.c\n@@ -112,6 +112,7 @@ QIOChannel *file_connect_outgoing(MigrationState *s,\n error_setg_errno(errp, errno,\n \"failed to truncate migration file to offset %\" PRIx64,\n offset);\n+ object_unref(OBJECT(fioc));\n goto out;\n }\n \n@@ -119,6 +120,7 @@ QIOChannel *file_connect_outgoing(MigrationState *s,\n \n ioc = QIO_CHANNEL(fioc);\n if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) {\n+ object_unref(OBJECT(fioc));\n ioc = NULL;\n goto out;\n }\ndiff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/file-tests.c\nindex 5d1b861cf6..fef172068f 100644\n--- a/tests/qtest/migration/file-tests.c\n+++ b/tests/qtest/migration/file-tests.c\n@@ -20,6 +20,51 @@\n \n static char *tmpfs;\n \n+static int count_proc_fds(pid_t pid)\n+{\n+ g_autofree char *fddir = g_strdup_printf(\"/proc/%d/fd\", (int)pid);\n+ GDir *dir = g_dir_open(fddir, 0, NULL);\n+ int count = 0;\n+\n+ if (!dir) {\n+ return -1;\n+ }\n+ while (g_dir_read_name(dir)) {\n+ count++;\n+ }\n+ g_dir_close(dir);\n+ return count;\n+}\n+\n+static void test_file_connect_outgoing_fd_leak(char *name, MigrateCommon *args)\n+{\n+ QTestState *from, *to;\n+ int fd_before, fd_after;\n+ const int retries = 5;\n+ int i;\n+ if (!g_file_test(\"/dev/full\", G_FILE_TEST_EXISTS)) {\n+ g_test_skip(\"/dev/full not available\");\n+ return;\n+ }\n+\n+ args->listen_uri = \"defer\";\n+ if (migrate_start(&from, &to, args->listen_uri, &args->start)) {\n+ return;\n+ }\n+\n+ fd_before = count_proc_fds(qtest_pid(from));\n+ g_assert_cmpint(fd_before, >, 0);\n+ for (i = 0; i < retries; i++) {\n+ migrate_qmp_fail(from, \"file:/dev/full\", NULL, \"{}\");\n+ migration_event_wait(from, \"failed\");\n+ }\n+\n+ fd_after = count_proc_fds(qtest_pid(from));\n+ g_assert_cmpint(fd_after, >, 0);\n+ g_assert_cmpint(fd_after, ==, fd_before);\n+ migrate_end(from, to, false);\n+}\n+\n static void test_precopy_file(char *name, MigrateCommon *args)\n {\n g_autofree char *uri = g_strdup_printf(\"file:%s/%s\", tmpfs,\n@@ -314,6 +359,9 @@ void migration_test_add_file(MigrationTestEnv *env)\n migration_test_add(\"/migration/precopy/file/offset/bad\",\n test_precopy_file_offset_bad);\n \n+ migration_test_add(\"/migration/precopy/file/connect-outgoing-fd-leak\",\n+ test_file_connect_outgoing_fd_leak);\n+\n migration_test_add(\"/migration/precopy/file/mapped-ram\",\n test_precopy_file_mapped_ram);\n migration_test_add(\"/migration/precopy/file/mapped-ram/live\",\n", "prefixes": [] }