From nobody Mon Feb 9 23:18:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566373483; cv=none; d=zoho.com; s=zohoarc; b=g8+VUMbeZI6Ea0l49r/5eoO+uDdhyveRUhixDSlXvk6BfIuVhjoODHFArd0Ad+RYnQI9GSMItpWrpiKoj9UqJpTVh8RLd4A5UZhLxFDhUid2ySpBlIMZm6GTG0W4WDDFi+NqPFyQel7Ss6IspuRv4OqbzovWs0uihECHKbn/uvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566373483; 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:ARC-Authentication-Results; bh=JAOpE2dPiu7mQIeSPe+Ys+2/lT/xAIJpXdT4tF+xDUA=; b=gh+2EMC/acoCvGPEp8oDcK6A+NQiWIa/UDI/RKVRjFBzY8Y+pUP2X1LqokKrl52vyzumFP3IWwEMKtGQa2pRmRQkA6XNtsRVAa7vysoXj1BMSToWngOmNTqMQpMzGKhrqaB3FUoDUAqgXj1L0YKiyrW5qSOE4DbUQ1+COQcGVLI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566373483072858.7587345524385; Wed, 21 Aug 2019 00:44:43 -0700 (PDT) Received: from localhost ([::1]:44592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0LIP-0001U6-G7 for importer@patchew.org; Wed, 21 Aug 2019 03:44:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42574) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0L0p-0005BY-8X for qemu-devel@nongnu.org; Wed, 21 Aug 2019 03:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0L0o-0008Rl-6p for qemu-devel@nongnu.org; Wed, 21 Aug 2019 03:26:31 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:44673) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0L0n-00086s-0S; Wed, 21 Aug 2019 03:26:30 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46CzjD49d6z9sR7; Wed, 21 Aug 2019 17:25:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1566372352; bh=djbVlC8N25YL//fyM3PhmQf5jm2n/3eUfbuieIBOl9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQowfhqOTbcnlBwz5AOmRwL4l2heczzKI2Htz8slsYmJWeF9NqOJhOXOXUs58JJZt iVM7dOYyaDEEdooO/i6UxLWMJ5Tg2kjufFPPTRfzqvHBHVMiL3lEoAw5VyzSeGrHz/ jeGCc4qSpNhjh0Ubub/ZhfF9OIPosX/5O0G4rAvw= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 21 Aug 2019 17:25:29 +1000 Message-Id: <20190821072542.23090-30-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190821072542.23090-1-david@gibson.dropbear.id.au> References: <20190821072542.23090-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 29/42] machine: Add wakeup method to MachineClass 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: lvivier@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, Nicholas Piggin , groug@kaod.org, qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Waking from suspend is not logically a machine reset on all machines, particularly in the paravirtualized case rather than hardware emulated. The ppc spapr machine for example just invokes hypervisor to suspend, and expects that call to return with the machine in the same state (modulo some possible migration and reconfiguration details). Implement a machine ->wakeup method and use that if it exists. Signed-off-by: Nicholas Piggin Message-Id: <20190722053215.20808-2-npiggin@gmail.com> Acked-by: Paolo Bonzini Signed-off-by: David Gibson --- include/hw/boards.h | 1 + vl.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index aa35955f7f..60d69217b4 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -180,6 +180,7 @@ struct MachineClass { =20 void (*init)(MachineState *state); void (*reset)(MachineState *state); + void (*wakeup)(MachineState *state); void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **err= p); int (*kvm_type)(MachineState *machine, const char *arg); void (*smp_parse)(MachineState *ms, QemuOpts *opts); diff --git a/vl.c b/vl.c index edd5390110..09aa18cb35 100644 --- a/vl.c +++ b/vl.c @@ -1557,6 +1557,22 @@ void qemu_system_reset(ShutdownCause reason) cpu_synchronize_all_post_reset(); } =20 +/* + * Wake the VM after suspend. + */ +static void qemu_system_wakeup(void) +{ + MachineClass *mc; + + mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; + + if (mc && mc->wakeup) { + mc->wakeup(current_machine); + } else { + qemu_system_reset(SHUTDOWN_CAUSE_NONE); + } +} + void qemu_system_guest_panicked(GuestPanicInformation *info) { qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed"); @@ -1765,7 +1781,7 @@ static bool main_loop_should_exit(void) } if (qemu_wakeup_requested()) { pause_all_vcpus(); - qemu_system_reset(SHUTDOWN_CAUSE_NONE); + qemu_system_wakeup(); notifier_list_notify(&wakeup_notifiers, &wakeup_reason); wakeup_reason =3D QEMU_WAKEUP_REASON_NONE; resume_all_vcpus(); --=20 2.21.0