Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2231296/?format=api
{ "id": 2231296, "url": "http://patchwork.ozlabs.org/api/patches/2231296/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430132418.275842-2-hector.cao@canonical.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": "<20260430132418.275842-2-hector.cao@canonical.com>", "list_archive_url": null, "date": "2026-04-30T13:24:18", "name": "[v2,1/1] module: fix early stop for load module function", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "77c1cf108fa9baee62351e6eae42cd4d789a0716", "submitter": { "id": 89665, "url": "http://patchwork.ozlabs.org/api/people/89665/?format=api", "name": "Hector Cao", "email": "hector.cao@canonical.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430132418.275842-2-hector.cao@canonical.com/mbox/", "series": [ { "id": 502312, "url": "http://patchwork.ozlabs.org/api/series/502312/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502312", "date": "2026-04-30T13:24:17", "name": "module: fix early stop for load module function", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/502312/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2231296/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2231296/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 (4096-bit key;\n unprotected) header.d=canonical.com header.i=@canonical.com\n header.a=rsa-sha256 header.s=20251003 header.b=W5Sd5Ode;\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=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.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 4g5xGg4lzdz1yJr\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 00:23:07 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wISGN-00040S-2E; Thu, 30 Apr 2026 10:21:11 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <hector.cao@canonical.com>)\n id 1wIRNT-0002jN-Ov\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 09:24:27 -0400", "from smtp-relay-canonical-0.canonical.com ([185.125.188.120])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <hector.cao@canonical.com>)\n id 1wIRNR-0008C7-El\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 09:24:27 -0400", "from localhost.localdomain (1.general.hector.uk.vpn\n [10.172.192.134])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 8E93F415CF;\n Thu, 30 Apr 2026 13:24:22 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com;\n s=20251003; t=1777555462;\n bh=24GRoT+i2ParXbW0fE7bgd7xwUnLMs1Zxrc3DSYrFEA=;\n h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n MIME-Version;\n b=W5Sd5OdeYoMNUtnS6WB5d/7/fjYKfKQASRwkACxI3a1Mv1LsjtIlnVB5WGvbRgx5M\n zBUxT2EfDr4KA673os7qgeRsBnxoKRQoafo+/mtAi4e5e6KuKFOxeTEP5KURIP8Jnb\n yWW4PvulqSvNi5D9UufLfJ814GV57Rfvju55dUis7ZtqrV8xEFYvacqQ7XLk8IUTsu\n q8+kOem+QMjgdWLQKgaEdGvs2oK7h5zRFrw5zlIZoLfm4RD3TiWySwoNKL4/0yj2ck\n c0Tfb+ocKRRoomKNNl45OdtvXVhwG/xbF0dtP2p2+g98/QFYhf0r1tFQ2vBN5fIkEH\n O4TjJdxYbdIeDeLnN6VvPgLtRKNXKeEtej1btvCYA/YH6LZ8ZQwGNPR6j4uYhDn/Mc\n mAcGtcPWYGXeXZo//7wTKzamK52XUknV2La/LqYjQ/F7NN+IVjtV9w3Xo+gyocqGra\n QWmQKb1SuCnfix6DB5bQpVQdFgOvguxN8edqWUHrq55Kc3zQn1xpv97c7ydUP9cac3\n N4eBBXX0T0/TGF1EPUPGXuK4xCCGr+rDjNAZKI9Y/PmXznkL9cc63MRUYJ8Ax4j3KH\n H9n1bXMT8RbyJ6lsZ5gw2vEmG91OhKoVtx4+HOEFUgXWT8GxQejHTbe1oO80KEbICW\n WMErn+383nOYh8ylalOfJhbI=", "From": "Hector Cao <hector.cao@canonical.com>", "To": "qemu-devel@nongnu.org", "Cc": "cfontana@suse.de, richard.henderson@linaro.org, pbonzini@redhat.com,\n gabriel.hartmann@netways.de", "Subject": "[PATCH v2 1/1] module: fix early stop for load module function", "Date": "Thu, 30 Apr 2026 15:24:18 +0200", "Message-ID": "<20260430132418.275842-2-hector.cao@canonical.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260430132418.275842-1-hector.cao@canonical.com>", "References": "<20260430132418.275842-1-hector.cao@canonical.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=185.125.188.120;\n envelope-from=hector.cao@canonical.com;\n helo=smtp-relay-canonical-0.canonical.com", "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, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_MED=-2.3, 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 c551fb0b53d regressed module-loading behavior.\nHistorically, when loading from one module directory failed,\nQEMU continued searching the remaining directories. That commit\nmade QEMU stop if a matching file was found but could not be\nloaded (for example, due to a build mismatch).\n\nAs a result, QEMU can fail to load the correct module, typically\nwhen the build option module-upgrades is enabled and at upgrades\nmultiple module directories exist.\n\nIn addition to the regression on the behavior, this commit introduces\nalso a leak in the function module_load_dso() that does not remove\nthe entries from the list dso_init_list when the the module load\nfails for build mismatch.\n\nThis commit has 2 folds:\n - restores the correct legacy behavior + set rv to -1 in case\n of load failure for one found module.\n - fix the memory leak in module_load_dso()\n\nFixes: c551fb0b53d (\"module: add Error arguments to module_load and module_load_qom\")\nSigned-off-by: Hector Cao <hector.cao@canonical.com>\n---\n util/module.c | 51 ++++++++++++++++++++++++++++++++++-----------------\n 1 file changed, 34 insertions(+), 17 deletions(-)", "diff": "diff --git a/util/module.c b/util/module.c\nindex 09dc43f51eb..435b34e354f 100644\n--- a/util/module.c\n+++ b/util/module.c\n@@ -184,6 +184,11 @@ static bool module_load_dso(const char *fname, bool export_symbols,\n \"Only modules from the same build can be loaded.\\n\");\n }\n g_module_close(g_module);\n+ /* Clean up any dso init entries added during DSO initialization */\n+ QTAILQ_FOREACH_SAFE(e, &dso_init_list, node, next) {\n+ QTAILQ_REMOVE(&dso_init_list, e, node);\n+ g_free(e);\n+ }\n return false;\n }\n \n@@ -279,29 +284,41 @@ int module_load(const char *prefix, const char *name, Error **errp)\n }\n }\n \n- for (i = 0; i < n_dirs; i++) {\n+ /*\n+ * Try to load module in given folders until we load it successfully or no\n+ * more to look.\n+ * If no module can be loaded successfully, errp is set to the last encountered error\n+ */\n+ rv = 0;\n+ for (i = 0; (i < n_dirs) && (rv != 1); i++) {\n char *fname = g_strdup_printf(\"%s/%s%s\",\n dirs[i], module_name, CONFIG_HOST_DSOSUF);\n int ret = access(fname, F_OK);\n- if (ret != 0 && (errno == ENOENT || errno == ENOTDIR)) {\n- /*\n- * if we don't find the module in this dir, try the next one.\n- * If we don't find it in any dir, that can be fine too: user\n- * did not install the module. We will return 0 in this case\n- * with no error set.\n- */\n- g_free(fname);\n- continue;\n- } else if (ret != 0) {\n- /* most common is EACCES here */\n- error_setg_errno(errp, errno, \"error trying to access %s\", fname);\n- } else if (module_load_dso(fname, export_symbols, errp)) {\n- rv = 1; /* module successfully loaded */\n+ if (ret == 0) {\n+ if (module_load_dso(fname, export_symbols, errp)) {\n+ /* module successfully loaded */\n+ rv = 1;\n+ } else {\n+ /* fail to load a module */\n+ rv = -1;\n+ }\n+ } else {\n+ /* The file exists but cannot be accessed -> report an error and continue */\n+ if ((errno != ENOENT) && (errno != ENOTDIR)) {\n+ /* most common is EACCES here */\n+ error_setg_errno(errp, errno, \"error trying to access %s\", fname);\n+ rv = -1;\n+ }\n }\n+\n g_free(fname);\n- goto out;\n+\n+ /* If we have more to look at, report the current error */\n+ if ((i < n_dirs - 1) && (rv != 1) && errp && *errp) {\n+ error_report_err(*errp);\n+ *errp = NULL;\n+ }\n }\n- rv = 0; /* module not found */\n \n out:\n if (rv <= 0) {\n", "prefixes": [ "v2", "1/1" ] }