{"id":2075175,"url":"http://patchwork.ozlabs.org/api/patches/2075175/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/5bad5a7ee50b6e3e18cf97ac07837988b25ad07f.1745295397.git.ktokunaga.mail@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","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":"<5bad5a7ee50b6e3e18cf97ac07837988b25ad07f.1745295397.git.ktokunaga.mail@gmail.com>","list_archive_url":null,"date":"2025-04-22T05:27:18","name":"[v2,14/20] include/qemu/osdep.h: Add Emscripten-specific OS dependencies","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e60c610ee98a3b96e9342e03f16314cafb10924d","submitter":{"id":90637,"url":"http://patchwork.ozlabs.org/api/people/90637/?format=json","name":"Kohei Tokunaga","email":"ktokunaga.mail@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/5bad5a7ee50b6e3e18cf97ac07837988b25ad07f.1745295397.git.ktokunaga.mail@gmail.com/mbox/","series":[{"id":453631,"url":"http://patchwork.ozlabs.org/api/series/453631/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=453631","date":"2025-04-22T05:27:04","name":"Enable QEMU TCI to run 32bit guests on browsers","version":2,"mbox":"http://patchwork.ozlabs.org/series/453631/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2075175/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2075175/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=20230601 header.b=S0q12Uw3;\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 4ZhWGh5pdhz1yJW\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 22 Apr 2025 15:37:48 +1000 (AEST)","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 1u76FK-0006Iu-SJ; Tue, 22 Apr 2025 01:32:39 -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 <ktokunaga.mail@gmail.com>)\n id 1u76Ci-0002Qr-F4; Tue, 22 Apr 2025 01:29:59 -0400","from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <ktokunaga.mail@gmail.com>)\n id 1u76Cf-0007wH-Ug; Tue, 22 Apr 2025 01:29:55 -0400","by mail-pg1-x532.google.com with SMTP id\n 41be03b00d2f7-af590aea813so5318969a12.0;\n Mon, 21 Apr 2025 22:29:52 -0700 (PDT)","from localhost.localdomain ([240d:1a:3b6:8b00:e142:4a4f:1ebb:3ca4])\n by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-22c50eb4483sm75692085ad.118.2025.04.21.22.29.43\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 21 Apr 2025 22:29:49 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1745299791; x=1745904591; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=mPwJWv1XdL1SZLXg2WZ4ZVDBFmolVnjhl88zidFmCfI=;\n b=S0q12Uw3sD2gWe6x/fHe2SeNoWGwRVSN8YdlYX51J0MPGYLpa8WwTwlg6Ml4W4M263\n YuNkFl+oa5dJsG8kktTstt3eZmxjywhxq+ktnCu+f5wup2w0RoM3aH/LzO8jIJ9YphM4\n K8unxA8LABdFKUurc6icfInkHQxQJxPidLoHw2NAORj4xyG8JXeEecgGFPjBY3gIIHxd\n sHUUDPF+DZyx5ZBgYS3+PT9qWFInIUQ6ZADYft8eC/kPSnAnl6oZtxRl5iAJc4jnOqse\n X/wO6syHmRMM0chGxYQpVsHIx2nOWXHEDjNXNnEJTYPjLC+AREvNUGF5Xdb58ungjskl\n Ew0A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1745299791; x=1745904591;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=mPwJWv1XdL1SZLXg2WZ4ZVDBFmolVnjhl88zidFmCfI=;\n b=Qg/1VzDWrOsrB+Kkn6u0bcelVAWetQ49baf0nn9mJmzr0TM6+JlAVX1Jj1RVWgsxtH\n Q3BlxLo/snCwXEIoR5MmhV71oqKYq3mNoczAQ9gTD+6VO/9p3zRg6+miaKr19gd6i6Vv\n Tg9tlnl7CXRjyWRDi2E7faLA7j77m5rBZxZa8Az3j5NR7nMdVdnntYZuWZ4vYNkpFErX\n QDV1YEOkeZdD/p8zDrTDeecWp2XWh6VuBaPqTA8gB+1zsuYmHM1WQBNTIrC/lwRihIy3\n weFcnawpV2TmBBZrKL4qMl0nKQkFx2FOjFf4NXh4Zdn19dj6GS8uZ2b5fWA9rc5p+3LS\n I4jQ==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUXKNedXZpG4LIcm6oNUZCzq1YgNO9dR+x6BVeCVLMFYc4lwAc2QjsGcZGMVw5BebrVv6kfwWihAFKBEg==@nongnu.org,\n AJvYcCUbPs6t9OShnvjgnlLaD+Eer7bVvjUbdU53kVtxrXjuOitH+yTteXKO1cMTSqQaKhncZ+D7DddP+Q==@nongnu.org,\n AJvYcCV0wDkLNFPE2sDVfUrT6KyG4VEbEcqFFMg0NHQW45hGQDZZhMN0fHW6ADP9yIFZkescAkPmS0M04pRZRA==@nongnu.org,\n AJvYcCVjUsF0JrVDBGGzwVOqrBN9TGondc/d2AsV9vdMqh08ql92KtAvdnZ4gTS+MurnwqBdyqF57G33FXQ=@nongnu.org","X-Gm-Message-State":"AOJu0YxYX5s6xtPyaE8/7gn1Yw8MkhO65/vYmUZHQxeOvisW5KrCwVDi\n 3JbZI5HIkOp5YRNLNzPh+8gE4XTGKUqBFGwAVcLAsEAaRXJekcbTIKa6rCR/","X-Gm-Gg":"ASbGncu89VQv2JzYi1ndnv6yZnrnIHszXyD6AsQXtKodE3r7H9+arhVqjygHC71vx/r\n qib8brGaFXmpvpgClukFDkCed0hR6sIRHnNANwLzHgQlkxMoNU+XpyUGTr0BsS1fuHXDcDAH5d9\n kdVDRkz4oZmJVUd+CBM2dF2YjibQLc7H477nStMD8rQZoD+ZPWtTs637ZnFvLD7f3ECKAF6XpUJ\n YqXarzQQnUCQZFG6RCnfWuJTfCL4y09KV2cpmQI/V6K9YUKsL3leQpihs8o9z37PClkXl/8kKlw\n 2XiG2VoHMGbDBbpJQOC2cHrd085MScNI32rr+fSl0j+loQlIl2tsTYhjQRE=","X-Google-Smtp-Source":"\n AGHT+IFWgOdnfzbxh+RFwzENK0J0t5tRSDmDBnU3UXjP+CGN99+rxRf7Y1bXIP0QFV+SCqBDTzPFfg==","X-Received":"by 2002:a17:902:d04b:b0:21f:40de:ae4e with SMTP id\n d9443c01a7336-22c53e3b254mr155646575ad.9.1745299790588;\n Mon, 21 Apr 2025 22:29:50 -0700 (PDT)","From":"Kohei Tokunaga <ktokunaga.mail@gmail.com>","To":"qemu-devel@nongnu.org","Cc":"=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>, =?utf-8?q?Philipp?=\n\t=?utf-8?q?e_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n Thomas Huth <thuth@redhat.com>, Kevin Wolf <kwolf@redhat.com>,\n Hanna Reitz <hreitz@redhat.com>, Kohei Tokunaga <ktokunaga.mail@gmail.com>,\n Paolo Bonzini <pbonzini@redhat.com>, Alexandre Iooss <erdnaxe@crans.org>,\n Mahmoud Mandour <ma.mandourr@gmail.com>,\n Pierrick Bouvier <pierrick.bouvier@linaro.org>,\n Pavel Pisa <pisa@cmp.felk.cvut.cz>,\n Francisco Iglesias <francisco.iglesias@amd.com>,\n Vikram Garhwal <vikram.garhwal@bytedance.com>,\n Jason Wang <jasowang@redhat.com>,\n =?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\t=?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Eduardo Habkost <eduardo@habkost.net>, Peter Xu <peterx@redhat.com>,\n David Hildenbrand <david@redhat.com>,\n Peter Maydell <peter.maydell@linaro.org>, Zhao Liu <zhao1.liu@intel.com>,\n Nicholas Piggin <npiggin@gmail.com>,\n Daniel Henrique Barboza <danielhb413@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Ilya Leoshkevich <iii@linux.ibm.com>, Stefan Hajnoczi <stefanha@redhat.com>,\n qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,\n qemu-s390x@nongnu.org","Subject":"[PATCH v2 14/20] include/qemu/osdep.h: Add Emscripten-specific OS\n dependencies","Date":"Tue, 22 Apr 2025 14:27:18 +0900","Message-Id":"\n <5bad5a7ee50b6e3e18cf97ac07837988b25ad07f.1745295397.git.ktokunaga.mail@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<cover.1745295397.git.ktokunaga.mail@gmail.com>","References":"<cover.1745295397.git.ktokunaga.mail@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::532;\n envelope-from=ktokunaga.mail@gmail.com; helo=mail-pg1-x532.google.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 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, 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-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":"On emscripten, some implementations in os-posix.c can't be used such as\ndaemonizing and changing user. This commit introduces os-wasm.c and\nos-wasm.h which are forked from os-posix.c and os-posix.h and patched for\ntargetting Emscripten.\n\nSigned-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>\n---\n MAINTAINERS              |   6 ++\n include/qemu/osdep.h     |   8 ++-\n include/system/os-wasm.h | 104 ++++++++++++++++++++++++++++++++++\n os-wasm.c                | 119 +++++++++++++++++++++++++++++++++++++++\n 4 files changed, 235 insertions(+), 2 deletions(-)\n create mode 100644 include/system/os-wasm.h\n create mode 100644 os-wasm.c\n\nV2:\n- Moved the change that was incorrectly applied to os-posix.h into os-wasm.h\n- Split the MAINTAINERS file change that adds os-wasm.c and os-wasm.h from\n  the previous 19th patch into this commit.","diff":"diff --git a/MAINTAINERS b/MAINTAINERS\nindex d54b5578f8..c7a20ac8d7 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -619,6 +619,12 @@ F: .gitlab-ci.d/cirrus/macos-*\n F: */*.m\n F: scripts/entitlement.sh\n \n+WebAssembly\n+M: Kohei Tokunaga <ktokunaga.mail@gmail.com>\n+S: Maintained\n+F: include/system/os-wasm.h\n+F: os-wasm.c\n+\n Alpha Machines\n --------------\n M: Richard Henderson <richard.henderson@linaro.org>\ndiff --git a/include/qemu/osdep.h b/include/qemu/osdep.h\nindex 4397a90680..96fe51bc39 100644\n--- a/include/qemu/osdep.h\n+++ b/include/qemu/osdep.h\n@@ -8,7 +8,7 @@\n  * To avoid getting into possible circular include dependencies, this\n  * file should not include any other QEMU headers, with the exceptions\n  * of config-host.h, config-target.h, qemu/compiler.h,\n- * system/os-posix.h, system/os-win32.h, glib-compat.h and\n+ * system/os-posix.h, system/os-win32.h, system/os-wasm.h, glib-compat.h and\n  * qemu/typedefs.h, all of which are doing a similar job to this file\n  * and are under similar constraints.\n  *\n@@ -164,10 +164,14 @@ QEMU_EXTERN_C int daemon(int, int);\n #include \"system/os-win32.h\"\n #endif\n \n-#ifdef CONFIG_POSIX\n+#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)\n #include \"system/os-posix.h\"\n #endif\n \n+#if defined(EMSCRIPTEN)\n+#include \"system/os-wasm.h\"\n+#endif\n+\n #ifdef __cplusplus\n extern \"C\" {\n #endif\ndiff --git a/include/system/os-wasm.h b/include/system/os-wasm.h\nnew file mode 100644\nindex 0000000000..3abb3aaa03\n--- /dev/null\n+++ b/include/system/os-wasm.h\n@@ -0,0 +1,104 @@\n+/* SPDX-License-Identifier: MIT */\n+/*\n+ * posix specific declarations forked from os-posix.h, removing functions not\n+ * working on Emscripten\n+ *\n+ * Copyright (c) 2003-2008 Fabrice Bellard\n+ * Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com>\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+\n+#ifndef QEMU_OS_WASM_H\n+#define QEMU_OS_WASM_H\n+\n+#include <sys/mman.h>\n+#include <sys/socket.h>\n+#include <netinet/in.h>\n+#include <netinet/tcp.h>\n+#include <arpa/inet.h>\n+#include <netdb.h>\n+#include <sys/un.h>\n+\n+#ifdef CONFIG_SYSMACROS\n+#include <sys/sysmacros.h>\n+#endif\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+void os_set_line_buffering(void);\n+void os_setup_early_signal_handling(void);\n+void os_set_proc_name(const char *s);\n+void os_setup_signal_handling(void);\n+void os_setup_limits(void);\n+void os_setup_post(void);\n+int os_mlock(bool on_fault);\n+static inline int os_set_daemonize(bool d)\n+{\n+    return -1;\n+};\n+bool is_daemonized(void);\n+static inline void os_daemonize(void) {}\n+\n+/**\n+ * qemu_alloc_stack:\n+ * @sz: pointer to a size_t holding the requested usable stack size\n+ *\n+ * Allocate memory that can be used as a stack, for instance for\n+ * coroutines. If the memory cannot be allocated, this function\n+ * will abort (like g_malloc()). This function also inserts an\n+ * additional guard page to catch a potential stack overflow.\n+ * Note that the memory required for the guard page and alignment\n+ * and minimal stack size restrictions will increase the value of sz.\n+ *\n+ * The allocated stack must be freed with qemu_free_stack().\n+ *\n+ * Returns: pointer to (the lowest address of) the stack memory.\n+ */\n+void *qemu_alloc_stack(size_t *sz);\n+\n+/**\n+ * qemu_free_stack:\n+ * @stack: stack to free\n+ * @sz: size of stack in bytes\n+ *\n+ * Free a stack allocated via qemu_alloc_stack(). Note that sz must\n+ * be exactly the adjusted stack size returned by qemu_alloc_stack.\n+ */\n+void qemu_free_stack(void *stack, size_t sz);\n+\n+/* POSIX and Mingw32 differ in the name of the stdio lock functions.  */\n+\n+static inline void qemu_flockfile(FILE *f)\n+{\n+    flockfile(f);\n+}\n+\n+static inline void qemu_funlockfile(FILE *f)\n+{\n+    funlockfile(f);\n+}\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif\ndiff --git a/os-wasm.c b/os-wasm.c\nnew file mode 100644\nindex 0000000000..d240c180c5\n--- /dev/null\n+++ b/os-wasm.c\n@@ -0,0 +1,119 @@\n+/* SPDX-License-Identifier: MIT */\n+/*\n+ * os-wasm.c\n+ * Forked from os-posix.c, removing functions not working on Emscripten\n+ *\n+ * Copyright (c) 2003-2008 Fabrice Bellard\n+ * Copyright (c) 2010 Red Hat, Inc.\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+\n+#include \"qemu/osdep.h\"\n+#include <sys/resource.h>\n+#include <sys/wait.h>\n+#include <pwd.h>\n+#include <grp.h>\n+#include <libgen.h>\n+\n+#include \"qemu/error-report.h\"\n+#include \"qemu/log.h\"\n+#include \"system/runstate.h\"\n+#include \"qemu/cutils.h\"\n+\n+void os_setup_post(void){}\n+void os_set_line_buffering(void)\n+{\n+    setvbuf(stdout, NULL, _IOLBF, 0);\n+}\n+void os_setup_early_signal_handling(void)\n+{\n+    struct sigaction act;\n+    sigfillset(&act.sa_mask);\n+    act.sa_flags = 0;\n+    act.sa_handler = SIG_IGN;\n+    sigaction(SIGPIPE, &act, NULL);\n+}\n+void os_set_proc_name(const char *s)\n+{\n+    error_report(\"Change of process name not supported by your OS\");\n+    exit(1);\n+}\n+static void termsig_handler(int signal, siginfo_t *info, void *c)\n+{\n+    qemu_system_killed(info->si_signo, info->si_pid);\n+}\n+\n+void os_setup_signal_handling(void)\n+{\n+    struct sigaction act;\n+\n+    memset(&act, 0, sizeof(act));\n+    act.sa_sigaction = termsig_handler;\n+    act.sa_flags = SA_SIGINFO;\n+    sigaction(SIGINT,  &act, NULL);\n+    sigaction(SIGHUP,  &act, NULL);\n+    sigaction(SIGTERM, &act, NULL);\n+}\n+void os_setup_limits(void)\n+{\n+    struct rlimit nofile;\n+\n+    if (getrlimit(RLIMIT_NOFILE, &nofile) < 0) {\n+        warn_report(\"unable to query NOFILE limit: %s\", strerror(errno));\n+        return;\n+    }\n+\n+    if (nofile.rlim_cur == nofile.rlim_max) {\n+        return;\n+    }\n+\n+    nofile.rlim_cur = nofile.rlim_max;\n+\n+    if (setrlimit(RLIMIT_NOFILE, &nofile) < 0) {\n+        warn_report(\"unable to set NOFILE limit: %s\", strerror(errno));\n+        return;\n+    }\n+}\n+int os_mlock(bool on_fault)\n+{\n+#ifdef HAVE_MLOCKALL\n+    int ret = 0;\n+    int flags = MCL_CURRENT | MCL_FUTURE;\n+\n+    if (on_fault) {\n+#ifdef HAVE_MLOCK_ONFAULT\n+        flags |= MCL_ONFAULT;\n+#else\n+        error_report(\"mlockall: on_fault not supported\");\n+        return -EINVAL;\n+#endif\n+    }\n+\n+    ret = mlockall(flags);\n+    if (ret < 0) {\n+        error_report(\"mlockall: %s\", strerror(errno));\n+    }\n+\n+    return ret;\n+#else\n+    (void)on_fault;\n+    return -ENOSYS;\n+#endif\n+}\n","prefixes":["v2","14/20"]}