From patchwork Fri Jun 7 09:05:16 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: 166088 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp390004ili; Fri, 7 Jun 2019 02:19:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzn/XANRwanGOZlgHnXwkgg6BeWif8y2nRrbImAI4BxPVphl+oVJmSxM1zdqkbZZx6vE/13 X-Received: by 2002:ac8:e05:: with SMTP id a5mr9930449qti.53.1559899165229; Fri, 07 Jun 2019 02:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559899165; cv=none; d=google.com; s=arc-20160816; b=a9hHOKjX2v96GyxEnYco3d9R36nhzkUyyfcjvKq4COnfrpBAB7s144wF6dej64nFgJ FTGS3NQwLly1P7Ocv1bHPSxWdDEGVn7NHNX9f4/ugz04IT+roTxsLktvoQWtfLrTAnhD SrWRkR60eUSKa3bKXPnH9S2m1tU6hxz1C8OPK9omEPrvHb5rjSpAbxk1VCbWf8CAguHk y5CKTIrecrlBhfALyEZpyA9FuBSu2T+BAIwtzqqsRfs+oyjri1TiSmRtmPU1rUgJ5bJj AzUqbSeROtN6X8bSFJJRmfy4lkdoq11XXWqNcMcIIo7r60kolu7KruzUTBUhQJ0jpZfL JC7A== 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=1dKkut+uCfwlAn3zScZi3hqAXXCijPCSIcimV4mZPU4=; b=mKEIOFKN+7rO7kdy9x+Z+VE//DqLSQQcWoDRZaWUFT+XW93bF/yC4+6TwAlp1StGJ2 keL6DfwyeRD4dWwjV4aG+TKh2yUwFHi+7HTt4dre221MSRExlEn28FO+1NmErLuCaTPH lyqECKEErSGn56xUyo38wkRUbaWElIRkg65gPGwkgvtlf+iaE1Afs9C+VPdXolnQZfQ+ f2zM2oh1LS9dEw0KCjExC+yz9rbsC5d6A0LqVLAwamQjQ94l226GTEWHx1MC/zM9GO7e 2/M9oV7vZcYPSxSfpGod/J2bTKDhZX3KEdxdh8K5D7yhxbNaJIM5dUQHjKjEd1Wxi/7U jNGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fQ21quUU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 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.47]) by mx.google.com with ESMTPS id r42si933335qtj.42.2019.06.07.02.19.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 02:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fQ21quUU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 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 ([::1]:47410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB1v-0006Vs-0l for patch@linaro.org; Fri, 07 Jun 2019 05:19:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39454) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZAp5-00049e-I7 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZAp3-0004bE-I9 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:07 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:39164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZAp1-0004Tt-N9 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:06:04 -0400 Received: by mail-wm1-x332.google.com with SMTP id z23so1125750wma.4 for ; Fri, 07 Jun 2019 02:06:03 -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=1dKkut+uCfwlAn3zScZi3hqAXXCijPCSIcimV4mZPU4=; b=fQ21quUUtSkH6czkTNF2HL8KksSz6YYwc8GIMCDUXjCPgqAFUiwFbZ9BICRDH1YB6J D1bjOB1iTrT5ntEM7XD/9K9zwWWqhVV+ND7ZwlQsVRK5KQqEbNQrZWIW/K86+OdK5XgF m8+WxuwXN0F+8lOxvPEoylggxPpqEafv/DkeesFSoGw+lLOK6W43olCYe0uSUGTUCDt4 LbZs+2UYdroMh5etp9WeQBCAh8g/1f2KQfzDQFHikggKnuF8v46OxoMAHoA+BTcW7nJK Etl4lwAFZN5SyaYN/EhgcKxznf88TItc4pUXBD2KgL5A/Xv5aMEY/kDq23pwEKCanN/T Z43g== 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=1dKkut+uCfwlAn3zScZi3hqAXXCijPCSIcimV4mZPU4=; b=e73fM+3pZKy+c+uYIrXiGp9s3sz0oNQu7gi1V2dYHUPZJEvdU8DKImDVrhdgDQt/Jn bppl29qEH4dJwgFgnAaKEztePIATqF0TZREP5EJCpwU/07JbuHOFZe/cBPBEvyDMiStX WLT0XrSvScdyZxxLtFidVGzXJt3nXjbK2oDJk0QBUv0Diu6M0os83PHQnUVnI3Vp1KKZ QHeW3RYVUbi5LvB6ea7WOC484aCJCcoSEZFuxb3hbmUtD3UyrFWE7b73m3P5M9ZpOypT 65s/6+P9wd4oUhAFuHA8gyZxVd2pxQDcT5Kmsy5Rk+y0UHJu9ihUmRt3mf3KvBSjBMfb YJhQ== X-Gm-Message-State: APjAAAV4KOcsyKOlti1sVk7hPu5PGvGzB05F07HwFgTPzjp8/O66nYf2 mZ1jY4TmyTBSaJciLIJnQ7RWdA== X-Received: by 2002:a7b:c144:: with SMTP id z4mr3028525wmi.50.1559898362395; Fri, 07 Jun 2019 02:06:02 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id o14sm1312338wrp.77.2019.06.07.02.05.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:05:58 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5C0FC1FFA3; Fri, 7 Jun 2019 10:05:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:16 +0100 Message-Id: <20190607090552.12434-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-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::332 Subject: [Qemu-devel] [PULL 17/52] tests/vm: proper guest shutdown 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: Fam Zheng , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Gerd Hoffmann , =?utf-8?q?Alex_Benn=C3=A9e?= 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 -- 2.20.1 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 395eefaec9..f27178f3c7 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