From nobody Sat Feb 7 10:44:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562020210; cv=none; d=zoho.com; s=zohoarc; b=m1LEeiBrkQNXw87Zfii3xSXb36ikUp1Z/8/urQMF/+367hl3/gEltErLhVauBp2XCpcmGPO8BpZ31UOWrWFPBwsqWHlzqk3VpVqqfykNjRPnt7FyyAJifm5Qq67enR9qWTL7/w8PlQF+SQYGpILjDuWj7q7YeI5QxsoCL/I39iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562020210; 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:ARC-Authentication-Results; bh=KB/Ge0k48BigL4abW2hBIu4KI5YiXHiXQQWUrTGfnzw=; b=Ik2yOk8m+CMnPpsoKm6chcl25pPxk/wj6ls57oVvztcT1ZfBCg4FRAXHSYoNf6Y/1yX3//C3L1ybDEZMUhFFr6J2a42MTYlXtb85Roi34+kNoLNkgEJwGRk81lQBwr2fVN0uND/lTTxefZuSttuYd9mxe0yMb5L1j9DCtjneJN0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562020210336996.7029050296161; Mon, 1 Jul 2019 15:30:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4032A30872EA; Mon, 1 Jul 2019 22:30:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A61422C; Mon, 1 Jul 2019 22:29:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 03E291806B19; Mon, 1 Jul 2019 22:29:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x61MTkr7031958 for ; Mon, 1 Jul 2019 18:29:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD7C51001B2E; Mon, 1 Jul 2019 22:29:46 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B650100033F; Mon, 1 Jul 2019 22:29:39 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Cleber Rosa Date: Mon, 1 Jul 2019 19:29:11 -0300 Message-Id: <20190701222912.4703-4-ehabkost@redhat.com> In-Reply-To: <20190701222912.4703-1-ehabkost@redhat.com> References: <20190701222912.4703-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Fam Zheng , Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, libvir-list@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Max Reitz , John Snow , Aleksandar Rikalo , Aleksandar Markovic , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno Subject: [libvirt] [PULL 3/4] machine.py: minor delinting X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 01 Jul 2019 22:30:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: John Snow 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 Message-Id: <20190627212816.27298-3-jsnow@redhat.com> Signed-off-by: Eduardo Habkost --- 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.18.0.rc1.1.g3f1ff2140 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list