From nobody Thu May 16 17:10:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1590704612; cv=none; d=zohomail.com; s=zohoarc; b=iryNxrIyandRN5LdLZU5liaU5/hqXTWgry+Gt0Dey7ezc2zPDeUB+RGTzq1ck8evw0Kv0BZAcz7i2sFJfFqv1YbfYaHI/ViRNRAzDRFc3Ac2eLQZTZOp9/wtbaAzr5fGu+f/ORN2bOS/DJvcxuvbQpQk5A2AEQpFqoG2JpyIBak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590704612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/AbJ9wUwnkTOKUcHN+ez0/X3K8UeS4tPYQIww476n9I=; b=EJotEBMxPzsR8B40eQWdYgjPeqGfZeoAL/ZTMbzo6u5cSQAGPEsTSlSyfCabni5MVwS8C7FDTgqRHSv7QMXIungFxlTTVLsAr5RU4MSBCvyJsCtMuqsWTLdWi+6T0eceZSO5LslsyPO1i7ZhBDdUMcUJz12EGRokisAi5uDmjLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1590704612473966.1274850813068; Thu, 28 May 2020 15:23:32 -0700 (PDT) Received: from localhost ([::1]:37306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeQvz-0002Ve-1Z for importer@patchew.org; Thu, 28 May 2020 18:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeQuA-0000MU-GC for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45858 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jeQu8-0004gC-32 for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-sEwiPGZ_PzaChWtTxSI6BQ-1; Thu, 28 May 2020 18:21:33 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 367E81085933 for ; Thu, 28 May 2020 22:21:32 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-142.rdu2.redhat.com [10.10.112.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C5CA5D9CD; Thu, 28 May 2020 22:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590704495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/AbJ9wUwnkTOKUcHN+ez0/X3K8UeS4tPYQIww476n9I=; b=Gb20MqkKofHHodTPdjpDutEi8PoH89U3hy77BtMXBeCKXbIB173VmgnhxLsm8fHb+L2LQs P6sRo9UTDRF6BZ2xr9vohzgbi7dfmt39gi5IqW8JVTmhIx1bGvqwpJD8YBb/6gKhCbOvd9 XyGtMvv66l9x9dFbGL+v337gaXQ7oSA= X-MC-Unique: sEwiPGZ_PzaChWtTxSI6BQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 1/4] scripts/qmp: Fix shebang and imports Date: Thu, 28 May 2020 18:21:26 -0400 Message-Id: <20200528222129.23826-2-jsnow@redhat.com> In-Reply-To: <20200528222129.23826-1-jsnow@redhat.com> References: <20200528222129.23826-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=jsnow@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 17:46:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: John Snow , Cleber Rosa , philmd@redhat.com, Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" There's more wrong with these scripts; They are in various stages of disrepair. That's beyond the scope of this current patchset. This just mechanically corrects the imports and the shebangs, as part of ensuring that the python/qemu/lib refactoring didn't break anything needlessly. Signed-off-by: John Snow --- scripts/qmp/qmp | 4 +++- scripts/qmp/qom-fuse | 4 +++- scripts/qmp/qom-get | 6 ++++-- scripts/qmp/qom-list | 6 ++++-- scripts/qmp/qom-set | 6 ++++-- scripts/qmp/qom-tree | 6 ++++-- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp index 0625fc2abac..8e52e4a54de 100755 --- a/scripts/qmp/qmp +++ b/scripts/qmp/qmp @@ -11,7 +11,9 @@ # See the COPYING file in the top-level directory. =20 import sys, os -from qmp import QEMUMonitorProtocol + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import QEMUMonitorProtocol =20 def print_response(rsp, prefix=3D[]): if type(rsp) =3D=3D list: diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 6bada2c33d3..5fa6b3bf64d 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -15,7 +15,9 @@ import fuse, stat from fuse import Fuse import os, posix from errno import * -from qmp import QEMUMonitorProtocol + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import QEMUMonitorProtocol =20 fuse.fuse_python_api =3D (0, 2) =20 diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get index 007b4cd442e..666df718320 100755 --- a/scripts/qmp/qom-get +++ b/scripts/qmp/qom-get @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 ## # QEMU Object Model test tools # @@ -13,7 +13,9 @@ =20 import sys import os -from qmp import QEMUMonitorProtocol + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import QEMUMonitorProtocol =20 cmd, args =3D sys.argv[0], sys.argv[1:] socket_path =3D None diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list index 03bda3446b7..5074fd939f4 100755 --- a/scripts/qmp/qom-list +++ b/scripts/qmp/qom-list @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 ## # QEMU Object Model test tools # @@ -13,7 +13,9 @@ =20 import sys import os -from qmp import QEMUMonitorProtocol + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import QEMUMonitorProtocol =20 cmd, args =3D sys.argv[0], sys.argv[1:] socket_path =3D None diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set index c37fe78b000..240a78187f9 100755 --- a/scripts/qmp/qom-set +++ b/scripts/qmp/qom-set @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 ## # QEMU Object Model test tools # @@ -13,7 +13,9 @@ =20 import sys import os -from qmp import QEMUMonitorProtocol + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import QEMUMonitorProtocol =20 cmd, args =3D sys.argv[0], sys.argv[1:] socket_path =3D None diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree index 1c8acf61e79..25b0781323c 100755 --- a/scripts/qmp/qom-tree +++ b/scripts/qmp/qom-tree @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 ## # QEMU Object Model test tools # @@ -15,7 +15,9 @@ =20 import sys import os -from qmp import QEMUMonitorProtocol + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.qmp import QEMUMonitorProtocol =20 cmd, args =3D sys.argv[0], sys.argv[1:] socket_path =3D None --=20 2.21.3 From nobody Thu May 16 17:10:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1590704613; cv=none; d=zohomail.com; s=zohoarc; b=Qo+cBcIsc8/9zHKZnobXX1W6pMV8d/rFpBtFfQsSq9Xn9/MSFav4CC4ASpyQUM6XuNWYrW+7BmWZeZovFjnQbqmQDsz1ReSHvqjcATHWjQvmytWDV/YfOplwn3ndWda612XE1l2Xb3iwRDg59Xi1wdBzU0OVJj/Z0xcXZC9kbzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590704613; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZlKzXzaxKdIc00dT0HjE4rtei8SOeWDN3csi9Jn8sMg=; b=BUIgZN3XA+fJyxgokCo3zwgmJqqfrazEJL5YKap59WcjBA/W0fe5gb6dtfKrDZeT4clfN+bLEcS3xDJGhLEV+PKEmdiuPU3nvqGr+yj1zRXwq7387Q42l/jcGB1Ks9qMIPWqQiUZ6MzwwGZ8DAL+rerKDJJxEsZzk4QnicBOzUs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 15907046135822.1738172286410418; Thu, 28 May 2020 15:23:33 -0700 (PDT) Received: from localhost ([::1]:37364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeQvz-0002X0-L9 for importer@patchew.org; Thu, 28 May 2020 18:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeQuB-0000Ml-2a for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:40 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50199 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jeQuA-0004gm-58 for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-dQQcxKW8NtKwcSM9cw3S7w-1; Thu, 28 May 2020 18:21: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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C1F61005510 for ; Thu, 28 May 2020 22:21:34 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-142.rdu2.redhat.com [10.10.112.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 658875D9CD; Thu, 28 May 2020 22:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590704497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZlKzXzaxKdIc00dT0HjE4rtei8SOeWDN3csi9Jn8sMg=; b=L/eIXbhzBUfwusKsldO45mZIgTd4p2oohQ2xk7Zutj1Vf8t5h8yDpjkIAFlQVYjKjrGoiO Vo6ZbYBKpsNwG4cKbjeVY9TRD1sZY6g9J9QMwLUp9tZEJcLMCXNU+mgszU/V1gQgDdqvJ8 wM/edz0IdSibzM4uYv1TzhfUfnWQGlQ= X-MC-Unique: dQQcxKW8NtKwcSM9cw3S7w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 2/4] python/machine.py: remove bare except Date: Thu, 28 May 2020 18:21:27 -0400 Message-Id: <20200528222129.23826-3-jsnow@redhat.com> In-Reply-To: <20200528222129.23826-1-jsnow@redhat.com> References: <20200528222129.23826-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 17:42:57 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: John Snow , Cleber Rosa , philmd@redhat.com, Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Catch only the timeout error; if there are other problems, allow the stack trace to be visible. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index b9a98e2c862..e3ea5235713 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -342,7 +342,26 @@ def wait(self): self._load_io_log() self._post_shutdown() =20 - def shutdown(self, has_quit=3DFalse): + def _issue_shutdown(self, has_quit: bool =3D False) -> None: + """ + Shutdown the VM. + """ + if not self.is_running(): + return + + if self._qmp is not None: + if not has_quit: + self._qmp.cmd('quit') + self._qmp.close() + + try: + self._popen.wait(timeout=3D3) + except subprocess.TimeoutExpired: + self._popen.kill() + + self._popen.wait() + + def shutdown(self, has_quit: bool =3D False) -> None: """ Terminate the VM and clean up """ @@ -353,17 +372,7 @@ def shutdown(self, has_quit=3DFalse): self._console_socket.close() self._console_socket =3D None =20 - if self.is_running(): - if self._qmp: - try: - if not has_quit: - self._qmp.cmd('quit') - self._qmp.close() - self._popen.wait(timeout=3D3) - except: - self._popen.kill() - self._popen.wait() - + self._issue_shutdown(has_quit) self._load_io_log() self._post_shutdown() =20 --=20 2.21.3 From nobody Thu May 16 17:10:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1590704821; cv=none; d=zohomail.com; s=zohoarc; b=Yd4ESrVbkPCnCIo0bpD9gK15FMCYe92I58fR56gggXx6OpXtoRse+GMGgc/L+62K3RU5XYx5iaRc41GcyR+B2RTGxBAt0SUDU/AxqQ1uZCG+zwBofGHNdRCKhYK1LgvPkRB2HVe3zbAe69pbE2ZLH1CUevZJaLu1dLAWRm5ubkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590704821; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f/Sx5BuiUlNWTdj3wmMkIrPNFech+S0eO6Jy8W5tmI8=; b=QNVoroNg8lpGIvR7+UkhAaMrd1UlyqhBmA46Lj1FzTyXAHoGSj+B5qUdjxHVpCNNxBFvOH26OYwDPIy+ahN5TlhbvIeD+UG3ssg0XnqyYQi2oDKjRYq1sTsh5zUwlIY09LX71aIjkTR2YGRWKpWVAuAWAOVqzJvbfHyv75YoLe4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1590704821700208.62224136426096; Thu, 28 May 2020 15:27:01 -0700 (PDT) Received: from localhost ([::1]:45946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeQzM-0007Tr-GD for importer@patchew.org; Thu, 28 May 2020 18:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeQuD-0000NB-0b for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:41 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22135 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jeQuB-0004gw-Bl for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-wkdaG7VSPPKscGydJdTQsg-1; Thu, 28 May 2020 18:21:36 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71623EC1AA for ; Thu, 28 May 2020 22:21:35 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-142.rdu2.redhat.com [10.10.112.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AE5A5D9CD; Thu, 28 May 2020 22:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590704498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/Sx5BuiUlNWTdj3wmMkIrPNFech+S0eO6Jy8W5tmI8=; b=awbWqFLwUrWuGqm6YF1Wgtb3eQmpNYlSi6I5JIAg2/TvVljn5od/72GCpGcu6BmO7bpPyz +hAnvPo+qJqAhkH5tZ5aCe3CpShLvi1nm/iZNL8ZA93xPA3ZnL2VyVt4mJ5qycq7sqic5y gdc3Dvmou+ZcnbeZHvU9E9i09yB6A84= X-MC-Unique: wkdaG7VSPPKscGydJdTQsg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 3/4] python/qemu: delint and add pylintrc Date: Thu, 28 May 2020 18:21:28 -0400 Message-Id: <20200528222129.23826-4-jsnow@redhat.com> In-Reply-To: <20200528222129.23826-1-jsnow@redhat.com> References: <20200528222129.23826-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 17:57:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: John Snow , Cleber Rosa , philmd@redhat.com, Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Bring our these files up to speed with pylint 2.5.0. Add a pylintrc file to formalize which pylint subset we are targeting. The similarity ignore is there to suppress similarity reports across imports, which for typing constants, are going to trigger this report erroneously. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 6 ++--- python/qemu/pylintrc | 58 ++++++++++++++++++++++++++++++++++++++++++ python/qemu/qtest.py | 42 +++++++++++++++++++----------- 3 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 python/qemu/pylintrc diff --git a/python/qemu/machine.py b/python/qemu/machine.py index e3ea5235713..c79fc8fb89a 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -58,7 +58,7 @@ def __init__(self, reply): self.reply =3D reply =20 =20 -class QEMUMachine(object): +class QEMUMachine: """ A QEMU VM =20 @@ -242,7 +242,7 @@ def _base_args(self): 'chardev=3Dmon,mode=3Dcontrol']) if self._machine is not None: args.extend(['-machine', self._machine]) - for i in range(self._console_index): + for _ in range(self._console_index): args.extend(['-serial', 'null']) if self._console_set: self._console_address =3D os.path.join(self._sock_dir, @@ -383,7 +383,7 @@ def shutdown(self, has_quit: bool =3D False) -> None: command =3D ' '.join(self._qemu_full_args) else: command =3D '' - LOG.warning(msg, -exitcode, command) + LOG.warning(msg, -int(exitcode), command) =20 self._launched =3D False =20 diff --git a/python/qemu/pylintrc b/python/qemu/pylintrc new file mode 100644 index 00000000000..5d6ae7367d8 --- /dev/null +++ b/python/qemu/pylintrc @@ -0,0 +1,58 @@ +[MASTER] + +[MESSAGES CONTROL] + +# Disable the message, report, category or checker with the given id(s). Y= ou +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=3Dal= l" to +# disable everything first and then reenable specific checks. For example,= if +# you want to run only the similarities checker, you can use "--disable=3D= all +# --enable=3Dsimilarities". If you want to run only the classes checker, b= ut have +# no Warning level messages displayed, use "--disable=3Dall --enable=3Dcla= sses +# --disable=3DW". +disable=3Dtoo-many-arguments, + too-many-instance-attributes, + too-many-public-methods, + +[REPORTS] + +[REFACTORING] + +[MISCELLANEOUS] + +[LOGGING] + +[BASIC] + +# Good variable names which should always be accepted, separated by a comm= a. +good-names=3Di, + j, + k, + ex, + Run, + _, + fd, + +[VARIABLES] + +[STRING] + +[SPELLING] + +[FORMAT] + +[SIMILARITIES] + +# Ignore imports when computing similarities. +ignore-imports=3Dyes + +[TYPECHECK] + +[CLASSES] + +[IMPORTS] + +[DESIGN] + +[EXCEPTIONS] diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py index d24ad04256b..53d814c0641 100644 --- a/python/qemu/qtest.py +++ b/python/qemu/qtest.py @@ -1,5 +1,11 @@ -# QEMU qtest library -# +""" +QEMU qtest library + +qtest offers the QEMUQtestProtocol and QEMUQTestMachine classes, which +offer a connection to QEMU's qtest protocol socket, and a qtest-enabled +subclass of QEMUMachine, respectively. +""" + # Copyright (C) 2015 Red Hat Inc. # # Authors: @@ -17,19 +23,21 @@ from .machine import QEMUMachine =20 =20 -class QEMUQtestProtocol(object): +class QEMUQtestProtocol: + """ + QEMUQtestProtocol implements a connection to a qtest socket. + + :param address: QEMU address, can be either a unix socket path (string) + or a tuple in the form ( address, port ) for a TCP + connection + :param server: server mode, listens on the socket (bool) + :raise socket.error: on socket connection errors + + .. note:: + No conection is estabalished by __init__(), this is done + by the connect() or accept() methods. + """ def __init__(self, address, server=3DFalse): - """ - Create a QEMUQtestProtocol object. - - @param address: QEMU address, can be either a unix socket path (st= ring) - or a tuple in the form ( address, port ) for a TCP - connection - @param server: server mode, listens on the socket (bool) - @raise socket.error on socket connection errors - @note No connection is established, this is done by the connect() = or - accept() methods - """ self._address =3D address self._sock =3D self._get_sock() self._sockfile =3D None @@ -73,15 +81,19 @@ def cmd(self, qtest_cmd): return resp =20 def close(self): + """Close this socket.""" self._sock.close() self._sockfile.close() =20 def settimeout(self, timeout): + """Set a timeout, in seconds.""" self._sock.settimeout(timeout) =20 =20 class QEMUQtestMachine(QEMUMachine): - '''A QEMU VM''' + """ + A QEMU VM, with a qtest socket available. + """ =20 def __init__(self, binary, args=3DNone, name=3DNone, test_dir=3D"/var/= tmp", socket_scm_helper=3DNone, sock_dir=3DNone): --=20 2.21.3 From nobody Thu May 16 17:10:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1590704813; cv=none; d=zohomail.com; s=zohoarc; b=Wulw6anUo8tVB1oKeBgmLAb1H//T14LASwLSUJ4fvzYxAYGeNsHp+7tmfVp1Zs1LUTO13TkOWY8Vlnnlm00de/Bc/plYGzq46S4k5SvXgXSmkWBulNNxYFZQK0c7bJHKTnBNyfx22P9Ewzma2sItqxX470GY/SfJkpLRCUbMpmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590704813; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kADerSo5T/C2Vu5TCGYTMBx2gGJrKZfaOQSYZd/+cz0=; b=nhQfc/kx6rBDvgiFqX7QYb2/FhCPRwpobNIjPfeoGH2bmnQQMm5GO8FqPAb2OOSS9Xm/Gi4iPDRvtuW530ckVB3UJUK0xl4VXmRsF3i49ERKrunoHw2UxYsMXxDMd3WuoRcx6NoKQJRVpdfOfthnXBdYbGqFdX4AZCcxzxRsCs8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1590704813797509.8799529499755; Thu, 28 May 2020 15:26:53 -0700 (PDT) Received: from localhost ([::1]:45888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeQzD-0007Rj-T3 for importer@patchew.org; Thu, 28 May 2020 18:26:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeQuD-0000Q9-SG for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:41 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:46603 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jeQuC-0004hi-Q3 for qemu-devel@nongnu.org; Thu, 28 May 2020 18:21:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-uWySikmvMemS5C-Vzsu9HQ-1; Thu, 28 May 2020 18:21:37 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75D5F1005510 for ; Thu, 28 May 2020 22:21:36 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-142.rdu2.redhat.com [10.10.112.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0DE05D9CD; Thu, 28 May 2020 22:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590704500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kADerSo5T/C2Vu5TCGYTMBx2gGJrKZfaOQSYZd/+cz0=; b=FiAXhbSjZd0FLV/6h/BocNn6Usl2cMky5aghGgq29FYvKGzgOqP7H2RBp/uj+YdbaNBs0Q XSxvCdZ+JL7FU1MzPpKmBav2yI4CqGT5+/oYg4XQU3Y90mxBCzY8M9pqeHVYj1GVVcs6oI scD9O6O/V38pIIXQ1OHS6ixH7qmroMw= X-MC-Unique: uWySikmvMemS5C-Vzsu9HQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 4/4] python/qemu: delint; add flake8 config Date: Thu, 28 May 2020 18:21:29 -0400 Message-Id: <20200528222129.23826-5-jsnow@redhat.com> In-Reply-To: <20200528222129.23826-1-jsnow@redhat.com> References: <20200528222129.23826-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 17:42:57 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: John Snow , Cleber Rosa , philmd@redhat.com, Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Mostly, ignore the "no bare except" rule, because flake8 is not contextual and cannot determine if we re-raise. Pylint can, though, so always prefer pylint for that. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/.flake8 | 2 ++ python/qemu/accel.py | 9 ++++++--- python/qemu/machine.py | 13 +++++++++---- python/qemu/qmp.py | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 python/qemu/.flake8 diff --git a/python/qemu/.flake8 b/python/qemu/.flake8 new file mode 100644 index 00000000000..45d8146f3f5 --- /dev/null +++ b/python/qemu/.flake8 @@ -0,0 +1,2 @@ +[flake8] +extend-ignore =3D E722 # Pylint handles this, but smarter. \ No newline at end of file diff --git a/python/qemu/accel.py b/python/qemu/accel.py index 36ae85791ee..7fabe629208 100644 --- a/python/qemu/accel.py +++ b/python/qemu/accel.py @@ -23,11 +23,12 @@ # Mapping host architecture to any additional architectures it can # support which often includes its 32 bit cousin. ADDITIONAL_ARCHES =3D { - "x86_64" : "i386", - "aarch64" : "armhf", - "ppc64le" : "ppc64", + "x86_64": "i386", + "aarch64": "armhf", + "ppc64le": "ppc64", } =20 + def list_accel(qemu_bin): """ List accelerators enabled in the QEMU binary. @@ -47,6 +48,7 @@ def list_accel(qemu_bin): # Skip the first line which is the header. return [acc.strip() for acc in out.splitlines()[1:]] =20 + def kvm_available(target_arch=3DNone, qemu_bin=3DNone): """ Check if KVM is available using the following heuristic: @@ -69,6 +71,7 @@ def kvm_available(target_arch=3DNone, qemu_bin=3DNone): return False return True =20 + def tcg_available(qemu_bin): """ Check if TCG is available. diff --git a/python/qemu/machine.py b/python/qemu/machine.py index c79fc8fb89a..4b260fa2cb2 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -29,6 +29,7 @@ =20 LOG =3D logging.getLogger(__name__) =20 + class QEMUMachineError(Exception): """ Exception called when an error in QEMUMachine happens. @@ -62,7 +63,8 @@ class QEMUMachine: """ A QEMU VM =20 - Use this object as a context manager to ensure the QEMU process termin= ates:: + Use this object as a context manager to ensure + the QEMU process terminates:: =20 with VM(binary) as vm: ... @@ -188,8 +190,10 @@ def send_fd_scm(self, fd=3DNone, file_path=3DNone): fd_param.append(str(fd)) =20 devnull =3D open(os.path.devnull, 'rb') - proc =3D subprocess.Popen(fd_param, stdin=3Ddevnull, stdout=3Dsubp= rocess.PIPE, - stderr=3Dsubprocess.STDOUT, close_fds=3DFa= lse) + proc =3D subprocess.Popen( + fd_param, stdin=3Ddevnull, stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, close_fds=3DFalse + ) output =3D proc.communicate()[0] if output: LOG.debug(output) @@ -491,7 +495,8 @@ def event_wait(self, name, timeout=3D60.0, match=3DNone= ): =20 def events_wait(self, events, timeout=3D60.0): """ - events_wait waits for and returns a named event from QMP with a ti= meout. + events_wait waits for and returns a named event + from QMP with a timeout. =20 events: a sequence of (name, match_criteria) tuples. The match criteria are optional and may be None. diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index d6c9b2f4b12..6ae7693965a 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -168,8 +168,8 @@ def accept(self, timeout=3D15.0): =20 @param timeout: timeout in seconds (nonnegative float number, or None). The value passed will set the behavior of t= he - underneath QMP socket as described in [1]. Default= value - is set to 15.0. + underneath QMP socket as described in [1]. + Default value is set to 15.0. @return QMP greeting dict @raise OSError on socket connection errors @raise QMPConnectError if the greeting is not received --=20 2.21.3