From patchwork Fri Aug 6 21:43:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A17A9C4338F for ; Fri, 6 Aug 2021 22:20:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E862161179 for ; Fri, 6 Aug 2021 22:20:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E862161179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8CO-0000eM-SJ for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:20:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85m-0007DR-87 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:26 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:29052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85k-0004CU-7Z for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:25 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MC34n023309; Fri, 6 Aug 2021 22:13:18 GMT 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 : content-type : mime-version; s=corp-2021-07-09; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=CYvgj4KQN92gjsMPzHklftDBQwrcXQiNiGzPxvdiy6hLFfSL2tSu7pU09DfXnUyBGqy8 4zlXXVEUnRxlpqSY1Yk0HX1rFhx0PzKcohqXuVwJ9OIYmyawHxH80+k3jR1ghAI2mTuU rsd5wdRf3Ql6PUL9iC0t/TyFTHjZfmC6qGUxDMyTRu1JrqzqinZE+Xlm5ta4NZSCzv4j Mk7GikC6eJ94PTvG7COVTmoayhWUPGmxgJIoRMy/RvowQ58fx3A2R2bh/E8+lUCU4i0R PRhRZ2xR2yTiZl/la2LshacLvaNAKFOR6hsLP1a9I8fxc37YOxdrciI6U66YxnTC6YHA 6w== 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 : content-type : mime-version; s=corp-2020-01-29; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=ea+HGRKZ8jHMZGcU6T4qf+HIEwoG/wNjoXKcZ/fuUIH7ocVG4LNtUSH9Hp07Fpcr68Vc GNvkjmUqvUGKONs1Ei9bHpdlVGHKrspc2xlT7DkVee81GWPggx3qMNq3TWtzsn0vKU3j wHS6GuKETRqq/Mp07WFny105AU04h3hECcYAtB2lIsQE+UeEh8qeTuYpcm/atRCr3l2O sdFEtPBraKG96TZPebLvSM8m2LWRa9Zr2rFkTg9dNWl6YJEu1OdBMRX2+orM55VlvChW E9wJW3ot1JXAldwcByI2vFgldEjtnvKGJD2wN+c7FutO1zTU9vcTZWn1EIOhHqUd8nyh ww== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8vy3t4xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:18 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBejb032608; Fri, 6 Aug 2021 22:13:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by aserp3030.oracle.com with ESMTP id 3a78db75me-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TibgtvvXMYYw7iTjRlrmF8FJiVxoo2k+OhYE84t/61fYMwBS0K8iJQpaZK9AMAZKWbaFdeeRS1O43HLU+a+BGpHkl6++6CJMsZq6RuTwH3DOnS3uFkMXT7y9EU6XPSB5QpYZjGUC4DExzshuQNC7wUaYm1NjzSimuUdcRDdRgxZTgwsoU0ShtwA6HXB/FQUR2zBBMybCfO56rrI54oMyvFdFZucAeigY6tfVONPEtTBtApBnNdNuNZy95Ep2vI/FJ2UL1OeqNR6JyhPDcU1MLkYxAcXnydilYcSoZE85TLMenWZFq1H1G70VkIyaUbGhveUlIv2Vl3awS8fzneZlog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=lZNE6Iw1cfQtBwcc0tYm+oAQhlQ0uAjVzigN0iaPlo+4/nLR3wSrSm6s0Se+SxHkG4ZvcrwNS5Z5ErVUzMtKppKRauE5jm0WIvcQfZH+LIWSDNUZfTIMsDnhTpZPEp1x2RtC+uRYfJgv0WYNEUJYeI7qFhJfJRkfL8Q8n85rHp38yOBtD/znldxAhUEk7qFc32DQzgPB5G+zRHA9Ys2ys2x/YsAMssIQt5aoO8hxFYFCw+Ppx1bRwzcibDDHr5e3BvYnyIUizuIvaWzqAjbgpNfDTPbzJ5isAKBoceJ1RD/DTogtkRxPCdaiz7GKY8QwcSrsibklgxzP2WVkf6tzpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=nxAjB78n+DRFidVRNzOjAs9TjEl/sPkKaMH5RvUFhSGCAyRrbltSgIyv5aNg6oMraS3+CPPsPsjd181mYe79Kxwg+nuxwljCgJbk6n10ParWMsRywUp7Q4ZIjRw6Q/K46+hyrWY+uDJH2oJVsghbBw3R1PuAkq9gLpJoZQ1hInc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:15 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:15 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 12/27] vl: helper to request re-exec Date: Fri, 6 Aug 2021 14:43:46 -0700 Message-Id: <1628286241-217457-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81a811e6-386d-49cf-06c8-08d959276309 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q+MpO8HO4VZL8Qi6kge9flT7z/yNg44oIFMmRX853/lRLx6sPzQAAFoQz6K8Q6SvXFCDfZ+SfZTNYIPGnYY4TTgPjv6+SNZJJpXXO1FT0ZbxWMylHFtilk1ZLd/hhaC7ql3W31weeKCZjWDWjvmW/p0vGXlfZ8qziC87OcitorB78BEOuhBPWbvyVRwoFQ33namUkURKWZlx8sYJ2iirT+lTjQnne2ZEtB80PcHHGY8r6D+qUrh9ur7s/rd7kQKXSlxUhE/UIrwZKhJrZK1wgofJFaH8vrl7NjhmjzX/4eXhV8nf7OvDE+vhZGqnC8NvBGu648sHdC2cblWbyE0JGxu5JSLoWv0clcyWaSRYVl0/j8x4+p9FlVoPN1S5sv/Ar3U7N2c+JTl5Nw99g4Jue5jXP7IgggGJTLBHXatbPx1fUOF7wWLELlFYD2S1YDFL5GKbR57v/2aqtU5GP4K8IdPCFxbV+wMEYS4UPWVtQE+I1b0DturUdqyBr1jFyZ6NHFksm7M0g3EeRYKaPO5eRhm62ynIDCD32UqgVqG/4PYGcBl4o6Ls0DjWVFcwYN/xeb22/IrkdyaArL9d9oYfkiN+9OTGjZU/ajN9h6j16otzF+F4khLiO535RgIJv33I4bUWn8yA298KKmVIUnrI/cwl7kVPQmKurBRjiiRjtrg80aLgclSnJYtCjV/Mc7g6putePWQUo1gX01U3nYEu6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z4Pzlpuurjei3XzFkF3gUvHd/1lZf8slLdGMvxznSRrfwEobNvL0LcExarA8uoSnrEtE3d3BHbrPhxChOyBJUC4Q9wblga4ZRUO7l0LB1TFK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Sobdi1B61S8D3rMoOol7fnbPeQnOXRTIAYeb0RzqvPnQG64eFohZQU/Tqge6w9sCIoIbVoSzxQazUH1dXTUCiy4vWshI1sKPltGwE1ViaLOjOx1IvfUXSvtIMdHHt7sZ4vqmI5Xtd2zMk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81a811e6-386d-49cf-06c8-08d959276309 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:15.1277 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cugwOKP+AXz2ifDB8lAdMkcFGey92jUFtKm55rDG6my3jq3YEKv7qEpOGWpwCUvRAytOnmg2wzB1qVwYYdU1jZpzTueW5snsVHEpt9QxowU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: abwyZAdrL4PcAlP-ZdC448AhvHr8x5rf X-Proofpoint-ORIG-GUID: abwyZAdrL4PcAlP-ZdC448AhvHr8x5rf Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.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_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a qemu_system_exec_request() hook that causes the main loop to exit and re-exec qemu using the specified arguments. Signed-off-by: Steve Sistare --- include/sysemu/runstate.h | 1 + softmmu/runstate.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index b655c7b..198211b 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -57,6 +57,7 @@ void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); void qemu_register_wakeup_support(void); void qemu_system_shutdown_request(ShutdownCause reason); +void qemu_system_exec_request(const strList *args); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); void qemu_register_shutdown_notifier(Notifier *notifier); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 3d344c9..309a4bf 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -38,6 +38,7 @@ #include "monitor/monitor.h" #include "net/net.h" #include "net/vhost_net.h" +#include "qapi/util.h" #include "qapi/error.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-events-run-state.h" @@ -355,6 +356,7 @@ static NotifierList wakeup_notifiers = static NotifierList shutdown_notifiers = NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE); +static char **exec_argv; ShutdownCause qemu_shutdown_requested_get(void) { @@ -371,6 +373,11 @@ static int qemu_shutdown_requested(void) return qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); } +static int qemu_exec_requested(void) +{ + return exec_argv != NULL; +} + static void qemu_kill_report(void) { if (!qtest_driver() && shutdown_signal) { @@ -641,6 +648,13 @@ void qemu_system_shutdown_request(ShutdownCause reason) qemu_notify_event(); } +void qemu_system_exec_request(const strList *args) +{ + exec_argv = strv_from_strList(args); + shutdown_requested = 1; + qemu_notify_event(); +} + static void qemu_system_powerdown(void) { qapi_event_send_powerdown(); @@ -689,6 +703,13 @@ static bool main_loop_should_exit(void) } request = qemu_shutdown_requested(); if (request) { + + if (qemu_exec_requested()) { + execvp(exec_argv[0], exec_argv); + error_report("execvp %s failed: %s", exec_argv[0], strerror(errno)); + g_strfreev(exec_argv); + exec_argv = NULL; + } qemu_kill_report(); qemu_system_shutdown(request); if (shutdown_action == SHUTDOWN_ACTION_PAUSE) {