From nobody Sat Feb 7 06:55:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1561671421; cv=none; d=zoho.com; s=zohoarc; b=OV2LJkHB/TeUh151z6Gd9gzJWU1+wqMrH9PDCR1JnAVES6zPkWSLEpMTeHzQ42sWOgrpFc0b84zAW22RvQUp184DJhAyUKuHQWg+Fkc9cNdLKJMoJUxM8pKWIus+rBZbplZImNrEHB0BWlkcwbDxj29UgV3j9aZ2vBkBTamj3TY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561671421; h=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:ARC-Authentication-Results; bh=l5sBH3Xq3HoEHGbhYZHbkHZGzpwVjidnbP+zPUqmfRQ=; b=m1cIluICkfHxDRwOxhk8hf9nJuW0hMRB+LHXQC3O5j/TSzqM6YCcCofZujp97u2G1P0G7V/edLsFoBxZJ6S4A3t11OqGt3hGJa7WDcc46KpEMoNdJ3pLKjIaTOITbRw4I8R0ZT42Ly2wE2PECd5BlvZTSSGUErsVELodE9j7pTI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561671421763151.3011801633105; Thu, 27 Jun 2019 14:37:01 -0700 (PDT) Received: from localhost ([::1]:54848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgc4Y-0001ay-FG for importer@patchew.org; Thu, 27 Jun 2019 17:36:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60021) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgbwl-00058X-7T for qemu-devel@nongnu.org; Thu, 27 Jun 2019 17:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgbwk-0007nV-2x for qemu-devel@nongnu.org; Thu, 27 Jun 2019 17:28:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgbwh-0007kb-Dd; Thu, 27 Jun 2019 17:28:43 -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 mx1.redhat.com (Postfix) with ESMTPS id 5D2603082A8F; Thu, 27 Jun 2019 21:28:28 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-47.bos.redhat.com [10.18.17.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 558DE5D9E2; Thu, 27 Jun 2019 21:28:26 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Thu, 27 Jun 2019 17:28:15 -0400 Message-Id: <20190627212816.27298-3-jsnow@redhat.com> In-Reply-To: <20190627212816.27298-1-jsnow@redhat.com> References: <20190627212816.27298-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 27 Jun 2019 21:28:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH v2 2/3] machine.py: minor delinting 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 , Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Max Reitz , John Snow , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since we're out in a new module, do a quick cursory pass of some of the more obvious style issues. Signed-off-by: John Snow --- python/qemu/machine.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index a8a311b035..49445e675b 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -1,5 +1,10 @@ -# QEMU library -# +""" +QEMU machine module: + +The machine module primarily provides the QEMUMachine class, +which provides facilities for managing the lifetime of a QEMU VM. +""" + # Copyright (C) 2015-2016 Red Hat Inc. # Copyright (C) 2012 IBM Corp. # @@ -16,7 +21,6 @@ import errno import logging import os import subprocess -import re import shutil import socket import tempfile @@ -119,8 +123,10 @@ class QEMUMachine(object): self.shutdown() return False =20 - # This can be used to add an unused monitor instance. def add_monitor_null(self): + """ + This can be used to add an unused monitor instance. + """ self._args.append('-monitor') self._args.append('null') =20 @@ -143,10 +149,13 @@ class QEMUMachine(object): self._args.append(','.join(options)) return self =20 - # Exactly one of fd and file_path must be given. - # (If it is file_path, the helper will open that file and pass its - # own fd) def send_fd_scm(self, fd=3DNone, file_path=3DNone): + """ + Send an fd or file_path to socket_scm_helper. + + Exactly one of fd and file_path must be given. + If it is file_path, the helper will open that file and pass its ow= n fd. + """ # In iotest.py, the qmp should always use unix socket. assert self._qmp.is_scm_available() if self._socket_scm_helper is None: @@ -194,14 +203,17 @@ class QEMUMachine(object): raise =20 def is_running(self): + """Returns true if the VM is running.""" return self._popen is not None and self._popen.poll() is None =20 def exitcode(self): + """Returns the exit code if possible, or None.""" if self._popen is None: return None return self._popen.poll() =20 def get_pid(self): + """Returns the PID of the running process, or None.""" if not self.is_running(): return None return self._popen.pid @@ -339,7 +351,7 @@ class QEMUMachine(object): command =3D ' '.join(self._qemu_full_args) else: command =3D '' - LOG.warn(msg, -exitcode, command) + LOG.warning(msg, -exitcode, command) =20 self._launched =3D False =20 @@ -373,7 +385,7 @@ class QEMUMachine(object): """ Poll for one queued QMP events and return it """ - if len(self._events) > 0: + if self._events: return self._events.pop(0) return self._qmp.pull_event(wait=3Dwait) =20 @@ -441,8 +453,7 @@ class QEMUMachine(object): """ def _match(event): for name, match in events: - if (event['event'] =3D=3D name and - self.event_match(event, match)): + if event['event'] =3D=3D name and self.event_match(event, = match): return True return False =20 --=20 2.21.0