From nobody Mon Feb 9 09:52:38 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558356996; cv=none; d=zoho.com; s=zohoarc; b=FSXoC4vpdpN1NAQoTdjFWZlLn1nB4cSgg+pNw7FCalm/V8RsBQPA5ekgcbWUIuD8rOK9FiIY0er9epH/dGbSqKskeXXvsdGpyRGWvIcKq5r/D0DVtOVEIwe3ftYGS1hC5CDKxNnHuVGPs6Qhr+H1XBpnrvabYIxu+ruEFq5cRhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558356996; 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:ARC-Authentication-Results; bh=kGtifQI1ydKAbpA7mi6ence9kBt0S63P39yRvF3QQuQ=; b=KiVb62aObyjYMa4J+zjbpt/K3m+r7Xvc2ToTQ5zb4PCnOj1hWKokItIPNszXBHa/wEguNH66BLEFqco9wPcNMVwJS34f7pF6AMnXKtyIpuxvthA56/L/gletVf5vChjWN5qzZuox8feWszcS8XGsqjWWpC82M7+lzbm/N5CWGv8= ARC-Authentication-Results: i=1; mx.zoho.com; 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; 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 155835699628068.59589218557483; Mon, 20 May 2019 05:56:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:35166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hShq7-0000Ig-BG for importer@patchew.org; Mon, 20 May 2019 08:56:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hShhd-0002SC-T1 for qemu-devel@nongnu.org; Mon, 20 May 2019 08:47:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hShha-00060G-7V for qemu-devel@nongnu.org; Mon, 20 May 2019 08:47:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hShhV-0005vK-4U for qemu-devel@nongnu.org; Mon, 20 May 2019 08:47:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA01030842B3; Mon, 20 May 2019 12:47:28 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33B775DE81; Mon, 20 May 2019 12:47:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 238F31753D; Mon, 20 May 2019 14:47:17 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 20 May 2019 14:47:08 +0200 Message-Id: <20190520124716.30472-7-kraxel@redhat.com> In-Reply-To: <20190520124716.30472-1-kraxel@redhat.com> References: <20190520124716.30472-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 20 May 2019 12:47:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 06/14] tests/vm: proper guest shutdown 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: Fam Zheng , Ed Maste , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kamil Rytarowski , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Li-Wen Hsu , Brad Smith Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When not running in snapshot mode ask the guest to poweroff and wait for this to finish instead of simply quitting qemu, so the guest can flush pending updates to disk. Signed-off-by: Gerd Hoffmann Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/vm/basevm.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 878f1a7a32b8..465c7b80d011 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -51,6 +51,8 @@ class BaseVM(object): name =3D "#base" # The guest architecture, to be overridden by subclasses arch =3D "#arch" + # command to halt the guest, can be overridden by subclasses + poweroff =3D "poweroff" def __init__(self, debug=3DFalse, vcpus=3DNone): self._guest =3D None self._tmpdir =3D os.path.realpath(tempfile.mkdtemp(prefix=3D"vm-te= st-", @@ -201,6 +203,10 @@ class BaseVM(object): def wait(self): self._guest.wait() =20 + def graceful_shutdown(self): + self.ssh_root(self.poweroff) + self._guest.wait() + def qmp(self, *args, **kwargs): return self._guest.qmp(*args, **kwargs) =20 @@ -277,11 +283,13 @@ def main(vmcls): traceback.print_exc() return 2 =20 - if args.interactive: - if vm.ssh(*cmd) =3D=3D 0: - return 0 + exitcode =3D 0 + if vm.ssh(*cmd) !=3D 0: + exitcode =3D 3 + if exitcode !=3D 0 and args.interactive: vm.ssh() - return 3 - else: - if vm.ssh(*cmd) !=3D 0: - return 3 + + if not args.snapshot: + vm.graceful_shutdown() + + return exitcode --=20 2.18.1