From nobody Tue Nov 18 10:36:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1609863193; cv=none; d=zohomail.com; s=zohoarc; b=KU8uIqeMm0bShpajMOdJDerAhMXf3NvRq6FnGpBYKOKN2jRcu+BlIrEpq58LiZB1se/RI97/NNI+dnuT5Ac+25L4pSLKWGVmG3MWbf7CalORkmWFuqNy3Mk2+yJFOnOLYmza+lD22rXwsD2YhrBkm+7ylqtu85BqOJiUrD7NmIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609863193; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=OjVXc7WTAXRG/aeXGkEMVmWgqm8aa65uYxqI5U9rDZc=; b=k6f84wvytQPh0f1Mc71NSXs9Gsew/bHXqsIDYw4VuIvXRCvL8OKtAZUEdl9nN60N5i0+L+tIJWGAFgN6Pd06wbw4poQr5WNo0iM0EWxWb9f2ygbpRcFG1VwdBw+ZrrRRPgsaZc4SRhimTtj1UrRrhAk8L9C79LLke0KdMxwSZFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1609863193981649.2852111603099; Tue, 5 Jan 2021 08:13:13 -0800 (PST) Received: from localhost ([::1]:45738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwoxM-0001CQ-Ni for importer@patchew.org; Tue, 05 Jan 2021 11:13:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwotY-0003vz-Mc for qemu-devel@nongnu.org; Tue, 05 Jan 2021 11:09:16 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:39204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwotU-0003nt-JP for qemu-devel@nongnu.org; Tue, 05 Jan 2021 11:09:16 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 105Fsv9Z031211; Tue, 5 Jan 2021 16:09:07 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 35tgsksg3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 05 Jan 2021 16:09:07 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 105FtLBt175897; Tue, 5 Jan 2021 16:09:06 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 35vct61vmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Jan 2021 16:09:06 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 105G95Fw018512; Tue, 5 Jan 2021 16:09:05 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jan 2021 08:09:04 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=OjVXc7WTAXRG/aeXGkEMVmWgqm8aa65uYxqI5U9rDZc=; b=KykcG2/yy5XoOnlGfuJkQVf7hmeKSaUxPA1F/zvo9P/FOpsCtwvEbueDmXaWzYPGbLxc p8kjo5X4yp6+oLmmurftxQyEb40KJGLnhchQUrvxRaWwdJ8/eZdxcDdlCMN3LrIm+v/1 79yq5Myc4FosWil2VbhqtNpDACKwfINnBC7aIckkRj+3XwWkZInGE5RfiB5+XOXtilXh CPI5Q1CwBTGM8TcTW5mu6TlhV0HfA6W991MULbOZbFVAv3ikAuX1FKHZUE1qCFg1boOF 1rPzVNi4ENbdqeWXQ49NItIoSWJjPi1Z89eEb8UJWSGo7HTHErxZ63iy2UpNHwAymTjC VQ== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V2 06/22] vl: add helper to request re-exec Date: Tue, 5 Jan 2021 07:41:54 -0800 Message-Id: <1609861330-129855-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1609861330-129855-1-git-send-email-steven.sistare@oracle.com> References: <1609861330-129855-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9855 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101050099 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9855 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101050099 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=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.252, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a qemu_exec_requested() hook that causes the main loop to exit and re-exec qemu using the same initial arguments. If /usr/bin/qemu-exec exists, exec that instead. This is an optional site-specific trampoline that may alter the environment before exec'ing the qemu binary. Signed-off-by: Steve Sistare --- include/sysemu/sysemu.h | 1 + softmmu/vl.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 408eb56..2ab9f95 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -17,6 +17,7 @@ extern bool memfd_alloc; =20 void qemu_add_data_dir(const char *path); =20 +void qemu_system_exec_request(void); void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index 5668e2b..d395e80 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -165,6 +165,7 @@ uint8_t *boot_splash_filedata; int only_migratable; /* turn it off unless user states otherwise */ bool wakeup_suspend_enabled; bool memfd_alloc; +static char **argv_main; =20 int icount_align_option; =20 @@ -1294,6 +1295,7 @@ static ShutdownCause reset_requested; static ShutdownCause shutdown_requested; static int shutdown_signal; static pid_t shutdown_pid; +static int exec_requested; static int powerdown_requested; static int debug_requested; static int suspend_requested; @@ -1324,6 +1326,11 @@ static int qemu_shutdown_requested(void) return atomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); } =20 +static int qemu_exec_requested(void) +{ + return atomic_xchg(&exec_requested, 0); +} + static void qemu_kill_report(void) { if (!qtest_driver() && shutdown_signal) { @@ -1570,6 +1577,13 @@ void qemu_system_shutdown_request(ShutdownCause reas= on) qemu_notify_event(); } =20 +void qemu_system_exec_request(void) +{ + shutdown_requested =3D 1; + exec_requested =3D 1; + qemu_notify_event(); +} + static void qemu_system_powerdown(void) { qapi_event_send_powerdown(); @@ -1605,6 +1619,16 @@ void qemu_system_debug_request(void) qemu_notify_event(); } =20 +static void qemu_exec(void) +{ + const char *helper =3D "/usr/bin/qemu-exec"; + const char *bin =3D !access(helper, X_OK) ? helper : argv_main[0]; + + execvp(bin, argv_main); + error_report("execvp failed, errno %d.", errno); + exit(1); +} + static bool main_loop_should_exit(void) { RunState r; @@ -1625,6 +1649,11 @@ static bool main_loop_should_exit(void) } request =3D qemu_shutdown_requested(); if (request) { + + if (qemu_exec_requested()) { + qemu_exec(); + /* not reached */ + } qemu_kill_report(); qemu_system_shutdown(request); if (no_shutdown) { @@ -2872,6 +2901,7 @@ void qemu_init(int argc, char **argv, char **envp) =20 os_set_line_buffering(); =20 + argv_main =3D argv; error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); =20 --=20 1.8.3.1