From nobody Fri Nov 7 03:53:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545473345533345.0756932979409; Sat, 22 Dec 2018 02:09:05 -0800 (PST) Received: from localhost ([::1]:59826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaeDQ-0003Fp-23 for importer@patchew.org; Sat, 22 Dec 2018 05:09:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gadw6-0006PQ-QX for qemu-devel@nongnu.org; Sat, 22 Dec 2018 04:51:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gadw6-0006Xb-1a for qemu-devel@nongnu.org; Sat, 22 Dec 2018 04:51:10 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gadw5-0006X9-RX for qemu-devel@nongnu.org; Sat, 22 Dec 2018 04:51:09 -0500 Received: by mail-wm1-x342.google.com with SMTP id p6so7871999wmc.1 for ; Sat, 22 Dec 2018 01:51:09 -0800 (PST) Received: from localhost.localdomain ([176.228.155.165]) by smtp.gmail.com with ESMTPSA id s3sm9557371wmj.23.2018.12.22.01.51.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Dec 2018 01:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Zs5lAAC9I5AFJ51KWhpHS+IjB3oEO/vIRsOJCDh7iU=; b=KbqKpYR74LYtptgZ1/yFZHI1EHofJj2P91Si5/Uwxenrv8dya2deH+vDD1JEn+Q4fe EDuB/g7jZwjdDSW9NL6EJZ7pZeFc5Ec8QSR/1b3VJPGCfV5YDdFjeil+wLL/OrfcSNEE bkzNgmqVCS0HV8MkzGw0PijeCbhdEnsVJLiLBXqIaxOsYYrpmFx39WrfqffKDGWnoGhH y6dCFUyAI97FDfFu7sQqDkhm2h13lAt3dun74nk/KDMy3+6dD/EA3BxnBYUgjd242iV0 9lA7rgdLs3TcZ4MsRfccvgvAKhC78x+d1O5PMAfhKDdfDoOgA7n5/kmxy480VELVxEnU NLfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Zs5lAAC9I5AFJ51KWhpHS+IjB3oEO/vIRsOJCDh7iU=; b=mx6Yo+fD/NLCRwF8dHDlJTGaSeW5yAH/8wI3fhww4Ew8vDmk5ixw+PkJaDBw/IYPxh 7s0T70JtHCeOnhSLumlUVMdenmqhHl2/wfPVIleOopS38l0/iu5gQIYubXHs9w9p8Kn3 GZl1D9kOG6pybOzvth4U8on8+9tJNvSUmdisGCZ4fG8gmz5u51/PNjH1/9MLd8x6WXMV RHTxLRbyCFnnOU/cjmov52zDvdo0JASWA/NIjcmSmd6lM5pCWj97lnsy6dliCWH+P0My mostE8DuCe/CeKK0y1e8CMJWXK0F+C62qpAdPjT1hisrh6Y6S0IL0odVBYc4jPmYGlwd PI+w== X-Gm-Message-State: AJcUukfPbGbe9GOHJyNznyaix0qsWqQ/soD3Nszwu6QnBdN5Vmhd1oFP /XnOKvZUuMdq7pA3xkvgj4wURpvo X-Google-Smtp-Source: AFSGD/Wvm8mXrM6+lh4foSuHiXpwZrEuyPqNvJzPRGAeDrKjXowBZsMv9xx3c/CqIiRMIa5LP469Sw== X-Received: by 2002:a1c:81ca:: with SMTP id c193mr6292869wmd.66.1545472268683; Sat, 22 Dec 2018 01:51:08 -0800 (PST) From: Marcel Apfelbaum To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sat, 22 Dec 2018 11:50:25 +0200 Message-Id: <20181222095036.29743-21-marcel.apfelbaum@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181222095036.29743-1-marcel.apfelbaum@gmail.com> References: <20181222095036.29743-1-marcel.apfelbaum@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH PULL 20/31] vl: Introduce shutdown_notifiers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuval.shaia@oracle.com, pjp@fedoraproject.org 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" From: Yuval Shaia Notifier will be used for signaling shutdown event to inform system is shutdown. This will allow devices and other component to run some cleanup code needed before VM is shutdown. Signed-off-by: Yuval Shaia Reviewed-by: Cornelia Huck Signed-off-by: Marcel Apfelbaum --- include/sysemu/sysemu.h | 1 + vl.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index c8efdeb376..e0d15da937 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -62,6 +62,7 @@ void qemu_register_wakeup_support(void); void qemu_system_shutdown_request(ShutdownCause reason); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); +void qemu_register_shutdown_notifier(Notifier *notifier); void qemu_system_debug_request(void); void qemu_system_vmstop_request(RunState reason); void qemu_system_vmstop_request_prepare(void); diff --git a/vl.c b/vl.c index 46ebf813b3..8353d3c718 100644 --- a/vl.c +++ b/vl.c @@ -1577,6 +1577,8 @@ static NotifierList suspend_notifiers =3D NOTIFIER_LIST_INITIALIZER(suspend_notifiers); static NotifierList wakeup_notifiers =3D NOTIFIER_LIST_INITIALIZER(wakeup_notifiers); +static NotifierList shutdown_notifiers =3D + NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); static uint32_t wakeup_reason_mask =3D ~(1 << QEMU_WAKEUP_REASON_NONE); =20 ShutdownCause qemu_shutdown_requested_get(void) @@ -1828,6 +1830,12 @@ static void qemu_system_powerdown(void) notifier_list_notify(&powerdown_notifiers, NULL); } =20 +static void qemu_system_shutdown(ShutdownCause cause) +{ + qapi_event_send_shutdown(shutdown_caused_by_guest(cause), cause); + notifier_list_notify(&shutdown_notifiers, &cause); +} + void qemu_system_powerdown_request(void) { trace_qemu_system_powerdown_request(); @@ -1840,6 +1848,11 @@ void qemu_register_powerdown_notifier(Notifier *noti= fier) notifier_list_add(&powerdown_notifiers, notifier); } =20 +void qemu_register_shutdown_notifier(Notifier *notifier) +{ + notifier_list_add(&shutdown_notifiers, notifier); +} + void qemu_system_debug_request(void) { debug_requested =3D 1; @@ -1867,7 +1880,7 @@ static bool main_loop_should_exit(void) request =3D qemu_shutdown_requested(); if (request) { qemu_kill_report(); - qapi_event_send_shutdown(shutdown_caused_by_guest(request), reques= t); + qemu_system_shutdown(request); if (no_shutdown) { vm_stop(RUN_STATE_SHUTDOWN); } else { --=20 2.17.1