From patchwork Thu May 30 10:15:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 165433 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp785417ili; Thu, 30 May 2019 03:38:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxU9H6XIm8X/7CPXYxdb/otv/eFyy0xfFhT7NSqLJKr60mSsoyJqI8uNxUC6fBxeWKDr8Oh X-Received: by 2002:ac8:48c8:: with SMTP id l8mr2652481qtr.20.1559212681416; Thu, 30 May 2019 03:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559212681; cv=none; d=google.com; s=arc-20160816; b=PzEFYhbyJ/Ya5udEbwLJHz03ZwnyaRnnhJ0KhxL4w08PS1a9PaQOF32iyblU2quFR/ BLQFI66GbKR7tGBgLwQzzV9Vw/xO7DPiEHrCmRJDWA6sa3bURXIsoMvME9UmN4Sbnt0r u4j08npHyzW1OGBnH5/dr+IpBo46XyL/3Pim0w2m6OP2oAixr0mxb9VRCyAefr8ItxeN fPlRui2RVPx2mz6VW2S/BDzCuLqpcBcKB+zubcqbbP7+tie+Fk3UyJAwk9M39qIKQK4K r/U37XpCTvRDQ8oAM6QQhJXqpNALjgkpcQEgMGhxplmlZeZWK0aLU/xWgnYNu+QGOSG3 silA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=9uHkcMcsE9fyEwD5PKdvI++8JESJlTBOyqyYuFuuSZE=; b=BlvzX4St2ejqbcva8X3hQVCTQbgTe5YetDStWfjSFazayyURfGPQw6JwBB56VL1yyS Iu6PQYwSkI7tt8lYNK9zRJ4GUinQFudpes/tVqCADyvea12VeZoxwYke3N5KwKV0ydgu 0Y4ivBdqP/UMxD7fT5Hs9cLt4IWlIe2VQWKAaw52A5FyQY3Vu1xPGM/Hf53P2MjRWkEy BqBJRJr2Bbyne3ebXcofgkN4UWBlWEcyDMezSnva3i7TW+mMWQMRJU4HFDGw9AxcGSty 6nuk8npm6dISjyH0+ZAoSXeg8aI4GIHjP8I7UGNvrthHVyPWDHJcTCc4R733bxZUReiy X62A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X1sEQNqZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q14si1420770qtq.305.2019.05.30.03.38.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 30 May 2019 03:38:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X1sEQNqZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:51152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWIRd-00033b-0h for patch@linaro.org; Thu, 30 May 2019 06:38:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWI6g-0002js-OO for qemu-devel@nongnu.org; Thu, 30 May 2019 06:16:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWI6f-0006eO-RV for qemu-devel@nongnu.org; Thu, 30 May 2019 06:16:22 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:39180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWI6f-0006dD-K0 for qemu-devel@nongnu.org; Thu, 30 May 2019 06:16:21 -0400 Received: by mail-wm1-x32f.google.com with SMTP id z23so3460006wma.4 for ; Thu, 30 May 2019 03:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9uHkcMcsE9fyEwD5PKdvI++8JESJlTBOyqyYuFuuSZE=; b=X1sEQNqZbd4mlCH6UlYXnKT8C5RngBph4LPyHKT0/zM7GR4nhpA75kDAL+Hms7IWCA LrOnEJ6LlbWNxqgyqqvyfyS2/DFzGpTD1PA4kWiA9DwJ46B76SBNb/1v6vjcyaQHzYS1 70Rc20sQy7y0EIWNLUDJ0nszdSw27mARIMVgSlLx/ZOeJf8KD8iL+SRmDLIwGRyqruo5 761cw5G/Kgaqx8qOr64v3MwwQblCnwTZi7qcV0qncZjr8L8NH2dxfySxr2jkLKwKh3Gt fEAoYbVu3zuixIMvgWGbsmPtQxil7MHDQ007hkIclLv10jqDwD6W0r8TAxpCg+b1YFqI u7Wg== 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:mime-version:content-transfer-encoding; bh=9uHkcMcsE9fyEwD5PKdvI++8JESJlTBOyqyYuFuuSZE=; b=ngmkxG520l0WXvNZPhQuljcQeEzK0m84pEj1xkT3ttreFNj+rMIuB3UlE1vqurexmr huVN9QpVtd1tHPtNCSOWOgk+XQo9+59Ggq+8tBGtm99BKcyw63OCWdqCB0zDmcJurCpg RJHtuvhEbRq6VLC36n8Q3MWdo3C6wTu8ahu6oTcK1qsI8AUt4ny6xBpsTD16brWkxvHl u9mFmxDe//BBswa3Ud4ANcv/oVcmL/4XeWhMgNt0yRtljUOTFqX9yybxDaocMYtz+gHJ HCh+e5r6euQGaaxY81iFtS9v5D0AL8dlYZGalzMvjXPVNuJjfXijMHDQPat2r2srBN+B TMxg== X-Gm-Message-State: APjAAAXyoLA/UxeZCz8mb3P9HsKEe6o5DFbytfLIDDLDzDNo/VVts30c cLEh1+ul7TZOEpQj1uyHhrjjlA== X-Received: by 2002:a1c:6154:: with SMTP id v81mr1648078wmb.92.1559211380553; Thu, 30 May 2019 03:16:20 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h90sm7066459wrh.15.2019.05.30.03.16.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 30 May 2019 03:16:18 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 86F201FFA6; Thu, 30 May 2019 11:16:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 30 May 2019 11:15:55 +0100 Message-Id: <20190530101603.22254-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190530101603.22254-1-alex.bennee@linaro.org> References: <20190530101603.22254-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32f Subject: [Qemu-devel] [PATCH v1 18/26] 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 , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann 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é Tested-by: Philippe Mathieu-Daudé Message-Id: <20190520124716.30472-7-kraxel@redhat.com> Signed-off-by: Alex Bennée --- tests/vm/basevm.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 395eefaec94..f27178f3c7c 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -51,6 +51,8 @@ class BaseVM(object): name = "#base" # The guest architecture, to be overridden by subclasses arch = "#arch" + # command to halt the guest, can be overridden by subclasses + poweroff = "poweroff" def __init__(self, debug=False, vcpus=None): self._guest = None self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-", @@ -202,6 +204,10 @@ class BaseVM(object): def wait(self): self._guest.wait() + def graceful_shutdown(self): + self.ssh_root(self.poweroff) + self._guest.wait() + def qmp(self, *args, **kwargs): return self._guest.qmp(*args, **kwargs) @@ -278,11 +284,13 @@ def main(vmcls): traceback.print_exc() return 2 - if args.interactive: - if vm.ssh(*cmd) == 0: - return 0 + exitcode = 0 + if vm.ssh(*cmd) != 0: + exitcode = 3 + if exitcode != 0 and args.interactive: vm.ssh() - return 3 - else: - if vm.ssh(*cmd) != 0: - return 3 + + if not args.snapshot: + vm.graceful_shutdown() + + return exitcode