From patchwork Mon Jun 24 13:43:26 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: 167584 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4262945ilk; Mon, 24 Jun 2019 06:56:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3y7BtU/NEblVUUydZm444sKWTMIpRzgnf6kWf11hsBEx+TpNEiBPUox3sJYEW7rMaMPWA X-Received: by 2002:a50:a56b:: with SMTP id z40mr113256451edb.99.1561384583879; Mon, 24 Jun 2019 06:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561384583; cv=none; d=google.com; s=arc-20160816; b=a2mpTmYP4l9WAPDV7ihZHUCCoDPPKpkkQu9TZ1OZ0X5x1v6QQDBwECjA6qlGfBYlmS riQtUHWASHoFuRpfTwJJbFFtf9yH3n/ATnERJ48vO9Qc+JRzFLc7KkeJieLGEuD/li+3 scOIm6XRTkBxJ/1FUIZLx7DIYRZhGjM6jh3TAeK8/uK8FrzwiTCxKqRLwh8rRmLf/4pB RKtTJ6QY/8Ay8R5FL9zO8z47Vuu9ef/+8QHc/0E3+BYuEUrhixvPFW9aJ7E3iX3zqiT3 AV+pvNgskMti4SUF4zlkaJuPqaFbhsWQTWgucjHZdVi03JlI2UwmHc35LY6D7SI/usEe oLHg== 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=BBiBWMHXigNW/eAwUhEz7VujTp1CJQa4AIKszYpazcU=; b=sUyb7PFYVqh00Qwr4cmlYutlIvfGqHBurRO+Nzw+/993aNLZwDLzTj+7Oj/Y8k8pBa KuezpHcE0U/JdnT6nyO6vQxl7z+AqHxrm3FhBMye1G03FCKdedJdkX7u2JkEDTL3iv4P fM9MSMWOa2pT32vZmpiYS3J8af1IVxHs7W++rneco+ilBPSEeyXBrCWzaYIaHcZbJyjw L/kthGLlXdqW+P+kDC8r2IYCtgtqJ+FZ3zZyWfB9hCjGVX+87OtCQvsOV5arBQCUsohN t3kADf2l/IlXnYIjk+hcPgpYvBhyOcEIH5Q+6FEBeBLi4WD6eeucebCG/eoJupwXyK+F SnnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="q3YH62h/"; 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 l29si9580801edd.330.2019.06.24.06.56.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2019 06:56:23 -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="q3YH62h/"; 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 ([::1]:51372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfPSI-0001Bh-Tg for patch@linaro.org; Mon, 24 Jun 2019 09:56:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41562) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfPGI-0006iy-DS for qemu-devel@nongnu.org; Mon, 24 Jun 2019 09:44:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfPGG-0007gJ-Qa for qemu-devel@nongnu.org; Mon, 24 Jun 2019 09:43:58 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:34481) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfPGG-0007Ph-Fu for qemu-devel@nongnu.org; Mon, 24 Jun 2019 09:43:56 -0400 Received: by mail-wm1-x32e.google.com with SMTP id w9so6397wmd.1 for ; Mon, 24 Jun 2019 06:43:45 -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=BBiBWMHXigNW/eAwUhEz7VujTp1CJQa4AIKszYpazcU=; b=q3YH62h/w752HZ54J+NrTZ9fRDFtw3iQAin8CdHAUxsdOgzE69NHyLlP+zCR7gdcda +qgaWN+F+7GTcfF5poyCrDegHuBA5rCG1PXpR42WFZs6OCalj2opQ7w74RwYYYi2l/gO LugnhhdYhtcTP+3MN7pC3S2OIN1EhfcKplGgo6GPgaFszyzsPSs0gJhwIXlXIjStPa0p 9/0KRKiH76+0NwqaIh3TwNp9y+OjbGpfwa9Hmr/FgYhd6O1lD4yx37o0AdqHJ/k/C6Me zuYQrpuZAISOrxsLUxW5qC/Yic53Jz3b8OwD1h5lGpl8PZkvQxcCkOLuxfreG9Lr/A0h yqiQ== 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=BBiBWMHXigNW/eAwUhEz7VujTp1CJQa4AIKszYpazcU=; b=i7+naUuYnlWYWVREtgemlgFHLJX472mekRnCoxCuZowVuIRTRbPjFh6WlAF132FS3C didUQtdHN5PRcphVnLzE4XmgHeOq10Ypbg9p8JPOQqYgRI0kjvpJhgZoc+chkOH1+TYH 5PP5uvT5aMyF61LmvKkfxdM19n5qY9g6+aCH+nqoRE7JFzhCYfg/XdXfFRk1Caw/epXa DlDoXiLPhf4HtPPf2EQ+MBf87mR5PdpI4OOmiSfwn7CRYju5TzE8D8iM08Sp74QgYH7C baL6ts/Zxe2yXB9KEKLx7R4mvfK1fFDbGT1gTVzoJiipvBzKuPQzXAh8XJpvG0KBzaXI +bEg== X-Gm-Message-State: APjAAAXn/BksNfNFZZ42HYWBj4PB37OXh/bfruKzdaP29ZJBuKekn66J BWbruXKxIqQmc95Bqnui/TxsHEHof44= X-Received: by 2002:a1c:4b1a:: with SMTP id y26mr16112566wma.105.1561383824395; Mon, 24 Jun 2019 06:43:44 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w67sm11468568wma.24.2019.06.24.06.43.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 06:43:41 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 328A21FF98; Mon, 24 Jun 2019 14:43:38 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 24 Jun 2019 14:43:26 +0100 Message-Id: <20190624134337.10532-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624134337.10532-1-alex.bennee@linaro.org> References: <20190624134337.10532-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::32e Subject: [Qemu-devel] [PULL 08/19] 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: <20190617043858.8290-5-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