From nobody Thu May 2 01:03:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1679918874; cv=none; d=zohomail.com; s=zohoarc; b=Lfw3b1cMRe4UPvcD0kNuEPl+hetV/Kh67Hk30bEx2YUwgtklu0Z2Kqdk3VzjKIQQqadpFFpWmK8fmwFAknSnyUoS3Pv5KEFLGoJYDpaX4rPbAliWfa5U4DB24zCR7b9fp+ADmZzjDarbtV1Yp6w0fpPWA/NsdasM/30x0ZV4d1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679918874; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bjWnn+P2F4UIQBvYug5RXtHRshQXgShqa949XZWiG9w=; b=EuIupThKjiq9FP4rKz0fcwhuMKWsAX5l+kelPfbW87dmAnwBHSuXYibZTQJlJY8lJOfpdsCSlFeFB6muaU2X2CU50767aGMjcKiMgtfV2Vp+8mrEz6BxtU8YxmVVf5Ti24zN5b3cPFQEruZHag5QaEDpD3UtynABLXgayDRwOOs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679918874363317.9629805778235; Mon, 27 Mar 2023 05:07:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgld4-0003rc-Go; Mon, 27 Mar 2023 08:07:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgld2-0003qu-EV for qemu-devel@nongnu.org; Mon, 27 Mar 2023 08:07:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgld0-00069m-DG for qemu-devel@nongnu.org; Mon, 27 Mar 2023 08:07:12 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32RBUVcw022121; Mon, 27 Mar 2023 12:06:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pjb42pvj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 12:06:57 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32RC4QbI012693; Mon, 27 Mar 2023 12:05:34 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pjb42pshy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 12:05:33 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32QNnE96015876; Mon, 27 Mar 2023 12:04:03 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3phr7ftcy0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 12:04:02 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32RC3xk025887258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Mar 2023 12:03:59 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E76A2004B; Mon, 27 Mar 2023 12:03:59 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A2602006A; Mon, 27 Mar 2023 12:03:59 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 27 Mar 2023 12:03:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=bjWnn+P2F4UIQBvYug5RXtHRshQXgShqa949XZWiG9w=; b=EbdMpY21YSr+tL/D3rs9QIF8+u6T/pP9OEcxB4Eps49JoY930YItR6bJWM/g9oEEKkFq FBO1yw/BqYp/NugBzcQK/EFpLIDk8ynfiCflyz/RIoBVW8Ym0YDyMP3XW8typidbyY+Q gEqZsK7ZhAdLQJpkFQphEAM1fbfaY9szXHXPHK6DTqAb9FMAa8Bd+tu6y11BrEV6x4Oh cglv900UZrxKJeKhwQU/GMKljE9qqOn7BL/vRFRpmAE0Can2hiH7aoVJGX62HVPZYSoK Y1KwCp9/7bn+7wSL7NGsjNJcKZQBBDDr0hTTpKUQ9bTYdt8Zx8H/zNYL0c3Ckz2Mt2A8 wQ== From: Claudio Imbrenda To: pbonzini@redhat.com Cc: qemu-devel@nongnu.org, david@redhat.com, thuth@redhat.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, fiuczy@linux.ibm.com, pasic@linux.ibm.com, nsg@linux.ibm.com, berrange@redhat.com, alex.bennee@linaro.org, armbru@redhat.com Subject: [PATCH v4 1/1] util/async-teardown: wire up query-command-line-options Date: Mon, 27 Mar 2023 14:03:57 +0200 Message-Id: <20230327120357.34743-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230327120357.34743-1-imbrenda@linux.ibm.com> References: <20230327120357.34743-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: sw8VBglM260GJIFSK888y8Jl85biHmV3 X-Proofpoint-GUID: P9T6wdOowdpIMsQ_s_0rkA7zbktRfOlB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-24_11,2023-03-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 bulkscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270094 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=imbrenda@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1679918876492100001 Content-Type: text/plain; charset="utf-8" The recently introduced -async-teardown commandline option was not wired up properly and did not show up in the output of the QMP command query-command-line-options. This means that libvirt had no way to discover whether the feature was supported. This patch fixes the issue by replacing the -async-teardown option with a new -teardown option with a new async=3Don|off parameter. The new option is correctly wired up so that it appears in the output of query-command-line-options. Reported-by: Boris Fiuczynski Fixes: c891c24b1a ("os-posix: asynchronous teardown for shutdown on Linux") Signed-off-by: Claudio Imbrenda --- os-posix.c | 15 +++++++++++++-- qemu-options.hx | 33 +++++++++++++++++++-------------- util/async-teardown.c | 21 +++++++++++++++++++++ 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/os-posix.c b/os-posix.c index 5adc69f560..c1ca7b1cb3 100644 --- a/os-posix.c +++ b/os-posix.c @@ -36,6 +36,8 @@ #include "qemu/log.h" #include "sysemu/runstate.h" #include "qemu/cutils.h" +#include "qemu/config-file.h" +#include "qemu/option.h" =20 #ifdef CONFIG_LINUX #include @@ -132,6 +134,8 @@ static bool os_parse_runas_uid_gid(const char *optarg) */ int os_parse_cmd_args(int index, const char *optarg) { + QemuOpts *opts; + switch (index) { case QEMU_OPTION_runas: user_pwd =3D getpwnam(optarg); @@ -152,8 +156,15 @@ int os_parse_cmd_args(int index, const char *optarg) daemonize =3D 1; break; #if defined(CONFIG_LINUX) - case QEMU_OPTION_asyncteardown: - init_async_teardown(); + case QEMU_OPTION_teardown: + opts =3D qemu_opts_parse_noisily(qemu_find_opts("teardown"), + optarg, false); + if (!opts) { + exit(1); + } + if (qemu_opt_get_bool(opts, "async", false)) { + init_async_teardown(); + } break; #endif default: diff --git a/qemu-options.hx b/qemu-options.hx index d42f60fb91..6a69b84f3c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4763,23 +4763,28 @@ DEF("qtest", HAS_ARG, QEMU_OPTION_qtest, "", QEMU_A= RCH_ALL) DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL) =20 #ifdef __linux__ -DEF("async-teardown", 0, QEMU_OPTION_asyncteardown, - "-async-teardown enable asynchronous teardown\n", +DEF("teardown", HAS_ARG, QEMU_OPTION_teardown, + "-teardown async[=3Don|off]\n" + " process teardown options\n" + " async=3Don enables asynchronous teardown\n" + , QEMU_ARCH_ALL) -#endif SRST -``-async-teardown`` - Enable asynchronous teardown. A new process called "cleanup/" - will be created at startup sharing the address space with the main qemu - process, using clone. It will wait for the main qemu process to - terminate completely, and then exit. - This allows qemu to terminate very quickly even if the guest was - huge, leaving the teardown of the address space to the cleanup - process. Since the cleanup process shares the same cgroups as the - main qemu process, accounting is performed correctly. This only - works if the cleanup process is not forcefully killed with SIGKILL - before the main qemu process has terminated completely. +``-teardown`` + Set process teardown options. + + ``async=3Don`` enables asynchronous teardown. A new process called + "cleanup/" will be created at startup sharing the address + space with the main QEMU process, using clone. It will wait for the + main QEMU process to terminate completely, and then exit. This allows + QEMU to terminate very quickly even if the guest was huge, leaving the + teardown of the address space to the cleanup process. Since the cleanup + process shares the same cgroups as the main QEMU process, accounting is + performed correctly. This only works if the cleanup process is not + forcefully killed with SIGKILL before the main QEMU process has + terminated completely. ERST +#endif =20 DEF("msg", HAS_ARG, QEMU_OPTION_msg, "-msg [timestamp[=3Don|off]][,guest-name=3D[on|off]]\n" diff --git a/util/async-teardown.c b/util/async-teardown.c index 62cdeb0f20..4a5dbce958 100644 --- a/util/async-teardown.c +++ b/util/async-teardown.c @@ -12,6 +12,9 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/config-file.h" +#include "qemu/option.h" +#include "qemu/module.h" #include #include #include @@ -144,3 +147,21 @@ void init_async_teardown(void) clone(async_teardown_fn, new_stack_for_clone(), CLONE_VM, NULL); sigprocmask(SIG_SETMASK, &old_signals, NULL); } + +static QemuOptsList qemu_teardown_opts =3D { + .name =3D "teardown", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_teardown_opts.head), + .desc =3D { + { + .name =3D "async", + .type =3D QEMU_OPT_BOOL, + }, + { /* end of list */ } + }, +}; + +static void register_teardown(void) +{ + qemu_add_opts(&qemu_teardown_opts); +} +opts_init(register_teardown); --=20 2.39.2