From patchwork Mon Feb 5 23:08:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 869621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zb3SN0T45z9sBW for ; Tue, 6 Feb 2018 10:19:00 +1100 (AEDT) Received: from localhost ([::1]:49095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiq2M-0001Ba-3t for incoming@patchwork.ozlabs.org; Mon, 05 Feb 2018 18:18:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiptK-0001vF-CD for qemu-devel@nongnu.org; Mon, 05 Feb 2018 18:09:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiptJ-0007Gq-JH for qemu-devel@nongnu.org; Mon, 05 Feb 2018 18:09:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiptJ-0007GR-Dv for qemu-devel@nongnu.org; Mon, 05 Feb 2018 18:09:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C511081DE7; Mon, 5 Feb 2018 23:09:36 +0000 (UTC) Received: from localhost (ovpn-116-12.gru2.redhat.com [10.97.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5987560C4D; Mon, 5 Feb 2018 23:09:36 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 21:08:53 -0200 Message-Id: <20180205230900.11344-15-ehabkost@redhat.com> In-Reply-To: <20180205230900.11344-1-ehabkost@redhat.com> References: <20180205230900.11344-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Feb 2018 23:09:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/21] qemu.py: always cleanup on 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: Amador Pahim , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Amador Pahim Currently we only cleanup on shutdown() if the VM is running. To make sure we will always cleanup, this patch makes the self._load_io_log() and the self._post_shutdown() to always be called on shutdown(), regardless the VM running state. Reviewed-by: Fam Zheng Reviewed-by: Eduardo Habkost Signed-off-by: Amador Pahim Message-Id: <20180122205033.24893-4-apahim@redhat.com> Signed-off-by: Eduardo Habkost --- scripts/qemu.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index 0333d1e7fa..52cf09eebd 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -163,8 +163,9 @@ class QEMUMachine(object): return self._popen.pid def _load_io_log(self): - with open(self._qemu_log_path, "r") as iolog: - self._iolog = iolog.read() + if self._qemu_log_path is not None: + with open(self._qemu_log_path, "r") as iolog: + self._iolog = iolog.read() def _base_args(self): if isinstance(self._monitor_address, tuple): @@ -257,8 +258,8 @@ class QEMUMachine(object): self._popen.kill() self._popen.wait() - self._load_io_log() - self._post_shutdown() + self._load_io_log() + self._post_shutdown() exitcode = self.exitcode() if exitcode is not None and exitcode < 0: