From nobody Fri May 17 04:49:42 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=1620856120; cv=none; d=zohomail.com; s=zohoarc; b=PfurzJYfwUWQeulF7ScTo3DostoZ0CUd9ILOqxe3Bfi70C/Wwpt6SCin/W+qmsj/otuWn3gL169x5HTwmConbBcMGf4WtICBQX7838yV44872oq/ghKfWuK9h+EtMyCmZ0X6I8iQPrYMklakIidXVOXTbUJxV0+QzirDRglASdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856120; 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=j8nl0jcQO0S+XN6BD6lJAQ64y3jRqRoyQhzvjh6JnPs=; b=idfVl2BrcYtRhNu6By5XflrvN2ZICJO3oc7t1B6+Rc7fhrmN2fgVif2W/J0+dyvkrkhpxDMSWjLzcwliy8HXefYdi0gwEq1lHVda4Ap6C/1K37XcHI0PInvuKaGiCsbtdPeV5ETdJWa2qM+yJNVdGN6b0zEplc5GFoJhgR4yodk= 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 1620856120303289.41243885017013; Wed, 12 May 2021 14:48:40 -0700 (PDT) Received: from localhost ([::1]:59360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwid-0003S9-3D for importer@patchew.org; Wed, 12 May 2021 17:48:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgu-0000ky-SW for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgs-0007eA-5v for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:52 -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-546-BNDC15DqMxifDqkeiXa0mg-1; Wed, 12 May 2021 17:46:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADAD2FC9B; Wed, 12 May 2021 21:46:46 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FB715D6AC; Wed, 12 May 2021 21:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856009; 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=j8nl0jcQO0S+XN6BD6lJAQ64y3jRqRoyQhzvjh6JnPs=; b=gfo/ddSdZyibhoIVRpvzZLAw9osjMdFLhnHOBI02/YgpMZtjgAYpQ0dSsO4UC72jYKdwiW y6vWXRmPqSM7VRhepbUbkQH6wnysR2P+l7SoKvSp7ffsfYQNyWIiYnkMmJhr4LKe4cSK3K md6VAOl0li33bu2EUNIaSgPFo+ve+iQ= X-MC-Unique: BNDC15DqMxifDqkeiXa0mg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 01/10] python/console_socket: avoid one-letter variable Date: Wed, 12 May 2021 17:46:33 -0400 Message-Id: <20210512214642.2803189-2-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" Fixes pylint warnings. Signed-off-by: John Snow Reviewed-by: Cleber Rosa Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/console_socket.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/qemu/console_socket.py b/python/qemu/console_socket.py index ac21130e446..87237bebef7 100644 --- a/python/qemu/console_socket.py +++ b/python/qemu/console_socket.py @@ -46,11 +46,11 @@ def __init__(self, address: str, file: Optional[str] = =3D None, self._drain_thread =3D self._thread_start() =20 def __repr__(self) -> str: - s =3D super().__repr__() - s =3D s.rstrip(">") - s =3D "%s, logfile=3D%s, drain_thread=3D%s>" % (s, self._logfile, - self._drain_thread) - return s + tmp =3D super().__repr__() + tmp =3D tmp.rstrip(">") + tmp =3D "%s, logfile=3D%s, drain_thread=3D%s>" % (tmp, self._logf= ile, + self._drain_thread) + return tmp =20 def _drain_fn(self) -> None: """Drains the socket and runs while the socket is open.""" --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856356; cv=none; d=zohomail.com; s=zohoarc; b=W1cvh/TywZyemJ7hvqwDmcW8aOGTDtYuSXRAUWqYvcgTXjFaBQDabcn/SGZOSrHPYerURIasNTdd5IAxqvxARLwSG8qvXXzHa1VpJhf2+WZs697K4edXdZTiZ5EV418eOWnGN+LM8n8HKIf1mzK3g8xJQzyfOJw4HvOvUe3Q61s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856356; 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=Nsge9hZ9d41TehIGTBqpE3cG89Y7dT1ymp6CQUptFp4=; b=gXrFPIL2s5HkTWcCmUvcYlZ3ktNINNBtiSMr+ltItIuGIUD8PrFsko0QczKU7s1eK2+YYt+nomT87X+897+6Gpn2CvpGknG6Swewz8aiZvisMZku37zKpZUcrX0xVyl/tpnmbNrB4ag0NaTIBhqJl5Yf2P0l4UF+bKnUsBOlAGk= 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 1620856356374890.8934203077729; Wed, 12 May 2021 14:52:36 -0700 (PDT) Received: from localhost ([::1]:45194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwmR-0004Zz-Bb for importer@patchew.org; Wed, 12 May 2021 17:52:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwhD-0000yn-BI for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh3-0007lh-Bi for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:11 -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-499-EiSPTf91MiOoIZvg2d6qQg-1; Wed, 12 May 2021 17:46:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DD68FC8C; Wed, 12 May 2021 21:46:48 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02BC05D6AC; Wed, 12 May 2021 21:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856019; 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=Nsge9hZ9d41TehIGTBqpE3cG89Y7dT1ymp6CQUptFp4=; b=hbJ3Yc9yfwvdqXV7HdbtIwBqYLut06+i6ARk74gU2es1CAaTQf/mi7Gny6MG+vvrEixz91 /a+KlZRFoEjHBHSLxUaraWFLs6hww/vVUpkb0e4GPsIJ+QpxGtcqC1qUrE9nYRRYX8Edoc Gdfkfp8Qx0qy0hL6Ak6yz0YNhU+jBd0= X-MC-Unique: EiSPTf91MiOoIZvg2d6qQg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 02/10] python/machine: use subprocess.DEVNULL instead of open(os.path.devnull) Date: Wed, 12 May 2021 17:46:34 -0400 Message-Id: <20210512214642.2803189-3-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" One less file resource to manage, and it helps quiet some pylint >=3D 2.8.0 warnings about not using a with-context manager for the open call. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 6e44bda337e..41f51bd27d0 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -223,9 +223,8 @@ def send_fd_scm(self, fd: Optional[int] =3D None, assert fd is not None fd_param.append(str(fd)) =20 - devnull =3D open(os.path.devnull, 'rb') proc =3D subprocess.Popen( - fd_param, stdin=3Ddevnull, stdout=3Dsubprocess.PIPE, + fd_param, stdin=3Dsubprocess.DEVNULL, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT, close_fds=3DFalse ) output =3D proc.communicate()[0] @@ -393,7 +392,6 @@ def _launch(self) -> None: """ Launch the VM and establish a QMP connection """ - devnull =3D open(os.path.devnull, 'rb') self._pre_launch() self._qemu_full_args =3D tuple( chain(self._wrapper, @@ -403,7 +401,7 @@ def _launch(self) -> None: ) LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args)) self._popen =3D subprocess.Popen(self._qemu_full_args, - stdin=3Ddevnull, + stdin=3Dsubprocess.DEVNULL, stdout=3Dself._qemu_log_file, stderr=3Dsubprocess.STDOUT, shell=3DFalse, --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856330; cv=none; d=zohomail.com; s=zohoarc; b=jRovOdh7QeU9WFjnrNBtU470a+ogbwlw7pRvldV4+6tbzL83q4G9j7k3L+sh08ic41TKVgv2bbXsPR65lItUh6ApftVneGy8Dre83W8enL37f8TZwERB3bXJTqcz4mFtUoQd36nnM99U1O5mS/bw6D+7KbHefffMx7aAs6cKIYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856330; 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=q+n4WeStCk9DHrLUSIwDiLlWUE6zkA9YSqLHpnur8GE=; b=lu8ZuWnoOX6AvrGcPt7uL8DniFXb2Byoh3qh9L/nflQ6cfNNP0xdvBuD99Z6PrMst8TzAhVgZXvlL4Njf9Ji+yDPHicV/ZHfaUSTBW8sIXnasjhLzLlyrpgOfBCf94Cci6M4mpW/nsnGQba9IpuPpIfdUD9vWgHdS/cjjyHltTY= 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 1620856330333943.3721245305649; Wed, 12 May 2021 14:52:10 -0700 (PDT) Received: from localhost ([::1]:43468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwm1-0003Nx-98 for importer@patchew.org; Wed, 12 May 2021 17:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgy-0000nB-Im for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgx-0007hj-82 for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:56 -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-560-F3FDLRx1OJeL8brL_aAKWw-1; Wed, 12 May 2021 17:46:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07018FC8E; Wed, 12 May 2021 21:46:49 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32F485D6AC; Wed, 12 May 2021 21:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856014; 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=q+n4WeStCk9DHrLUSIwDiLlWUE6zkA9YSqLHpnur8GE=; b=JcJX5VVoFj4WAuA9rIb7td1PV2rslu3quLm3eH/rh64l7G98TeXj+mE8uCpgbLLqsYSEJ7 Qf1Ong+QC4iGTsxdlOgByGIc3NdYcBauisIUYWGqywfum2KztQa7YORgLJtj/7uiTcnN1V cqo8bBzgw6PaUz+tlSs5Jb+iSDmrS5M= X-MC-Unique: F3FDLRx1OJeL8brL_aAKWw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 03/10] python/machine: use subprocess.run instead of subprocess.Popen Date: Wed, 12 May 2021 17:46:35 -0400 Message-Id: <20210512214642.2803189-4-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" use run() instead of Popen() -- to assert to pylint that we are not forgetting to close a long-running program. Signed-off-by: John Snow --- python/qemu/machine.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 41f51bd27d0..c13ff9b32bf 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -223,13 +223,16 @@ def send_fd_scm(self, fd: Optional[int] =3D None, assert fd is not None fd_param.append(str(fd)) =20 - proc =3D subprocess.Popen( - fd_param, stdin=3Dsubprocess.DEVNULL, stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT, close_fds=3DFalse + proc =3D subprocess.run( + fd_param, + stdin=3Dsubprocess.DEVNULL, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, + check=3DTrue, + close_fds=3DFalse, ) - output =3D proc.communicate()[0] - if output: - LOG.debug(output) + if proc.stdout: + LOG.debug(proc.stdout) =20 return proc.returncode =20 --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856121; cv=none; d=zohomail.com; s=zohoarc; b=fWsGwvwHRMDj/bRx/xJkz7XX4clNp+vo1KPZI76pOTWoTnNwH80W1/NjrjqSw58qZoe0NFkGLSeEojhOR8HpBz2565z0CkYfe6Ih9o66WQRreyf5TJISFWkUDZAP38vc0szpKAr+XxyjqOQzYGYZAy6FlVgDJYWmDGb8ErVsRDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856121; 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=uBvBDPav6xvmQm82GofvgIrCGu6g8/LKkdDHgtH1lZ8=; b=grHdGiIhzKvs4p9R1K3wyZ4gUD5wROaVMSEEys2P38s76lJh73VUa2o97OVg5Cm8efS6kV1u/fYWJvwAlj5Gs3JmE+PZFk2APmNgT21ef8EexOSl6peASVlF1aXO1YjmKeolZ6mGBPxBiY4opUgCIwc4vAK/MlxRZyhRaQxiBp0= 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 1620856121203703.5512457283015; Wed, 12 May 2021 14:48:41 -0700 (PDT) Received: from localhost ([::1]:59458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwid-0003WQ-UR for importer@patchew.org; Wed, 12 May 2021 17:48:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgz-0000nr-Ql for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgv-0007ge-4m for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:57 -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-120-fjxI_zlvNLu5WQuxp95gBw-1; Wed, 12 May 2021 17:46:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F33548015F7; Wed, 12 May 2021 21:46:49 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DC4B5D6AC; Wed, 12 May 2021 21:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856012; 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=uBvBDPav6xvmQm82GofvgIrCGu6g8/LKkdDHgtH1lZ8=; b=LhxYkthbm6qccY2FNwpbnmiLD1U5d4SlWVpYV4N/NhHNbG5fvxLbH9WrKW4+0JiJXdx7Ur k67Kjie3d61PAdqvwE5/qbUUFOdHv+uFWkUkXrmSaqQAI4P/pOil8STPwaVMLivQ75u4OM xz6r8hAyaNCEuOuodRWo+LI+KbBvt0E= X-MC-Unique: fjxI_zlvNLu5WQuxp95gBw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 04/10] python/console_socket: Add a pylint ignore Date: Wed, 12 May 2021 17:46:36 -0400 Message-Id: <20210512214642.2803189-5-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" We manage cleaning up this resource ourselves. Pylint should shush. Signed-off-by: John Snow --- python/qemu/console_socket.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/qemu/console_socket.py b/python/qemu/console_socket.py index 87237bebef7..8c4ff598ad7 100644 --- a/python/qemu/console_socket.py +++ b/python/qemu/console_socket.py @@ -39,6 +39,7 @@ def __init__(self, address: str, file: Optional[str] =3D = None, self.connect(address) self._logfile =3D None if file: + # pylint: disable=3Dconsider-using-with self._logfile =3D open(file, "bw") self._open =3D True self._drain_thread =3D None --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856217; cv=none; d=zohomail.com; s=zohoarc; b=STJrmOI2B08yHqgfMIJSVgOMrYiWYoAE8myYwoMIPZSyIJK9+FUWIuO9+2zn7UBHBAdD/c+9bm3AH3Yrwl8gUgG8L9r6HEejn+FZIWvshtCyDseEI/AsyNWpoSKhy6Amh8idKSU+XmkZOXdiE3ah5FZ/wY9ojoX2VkiBwKG0W7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856217; 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=PRoXjpL1COvPFgYOg27IMS77Yp8odkYELVhLzf88+3w=; b=nqyhudORpjNYMkja125TXBFHMrm4qmBk0uBm1z2WsgzyjVZ1IIuvcqWbsLcgYqSc+1YNlbmuiXtV47Yge0gR+Iw8SVSY6HRZc5NBYPUjFjeS2WFthZumuHjQmqQdGNlrm2zdWMYoAcSC1uuHu2SfKK3bjdydtI9uKjyVqwTlpj0= 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 1620856217416186.99149402689625; Wed, 12 May 2021 14:50:17 -0700 (PDT) Received: from localhost ([::1]:39234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwkC-0000Rl-Ct for importer@patchew.org; Wed, 12 May 2021 17:50:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgx-0000mc-Pn for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgw-0007hF-2M for qemu-devel@nongnu.org; Wed, 12 May 2021 17:46:55 -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-586-coVwtcv7N42KBqvkTBtcqw-1; Wed, 12 May 2021 17:46:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA72E107ACE8; Wed, 12 May 2021 21:46:50 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26D0E5D6AC; Wed, 12 May 2021 21:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856013; 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=PRoXjpL1COvPFgYOg27IMS77Yp8odkYELVhLzf88+3w=; b=gnoX3EuUtB9lSxpED4Wkcmc64wES0pjjNXnerSmnG/DIwdQTDqbo8U3GGQxWAjTQsPHRaX 11OyLd4ZlqnyoMZ4p4EWR/5qfSuLkAIQQAlGP/2ms4c8uv96UtPsCGHJU3BhzlOJWnU8Va 8+0q2R6lqvG54E0iScRoLmf3kuc25zw= X-MC-Unique: coVwtcv7N42KBqvkTBtcqw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 05/10] python/machine: Disable pylint warning for open() in _pre_launch Date: Wed, 12 May 2021 17:46:37 -0400 Message-Id: <20210512214642.2803189-6-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" Shift the open() call later so that the pylint pragma applies *only* to that one open() call. Add a note that suggests why this is safe: the resource is unconditionally cleaned up in _post_shutdown(). _post_shutdown is called after failed launches (see launch()), and unconditionally after every call to shutdown(), and therefore also on __exit__. Signed-off-by: John Snow Reviewed-by: Wainer dos Santos Moschetta --- python/qemu/machine.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index c13ff9b32bf..8f86303b48f 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -308,7 +308,6 @@ def _pre_launch(self) -> None: self._temp_dir =3D tempfile.mkdtemp(prefix=3D"qemu-machine-", dir=3Dself._test_dir) self._qemu_log_path =3D os.path.join(self._temp_dir, self._name + = ".log") - self._qemu_log_file =3D open(self._qemu_log_path, 'wb') =20 if self._console_set: self._remove_files.append(self._console_address) @@ -323,6 +322,11 @@ def _pre_launch(self) -> None: nickname=3Dself._name ) =20 + # NOTE: Make sure any opened resources are *definitely* freed in + # _post_shutdown()! + # pylint: disable=3Dconsider-using-with + self._qemu_log_file =3D open(self._qemu_log_path, 'wb') + def _post_launch(self) -> None: if self._qmp_connection: self._qmp.accept() --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856122; cv=none; d=zohomail.com; s=zohoarc; b=ahdjUwm2kJ9HWCVOHk0XU5A7vGFhB9Tdhw1qXBVS7eQsUrKi+CUXv82HVWjbNe5605wWhMNaEMDw7rjr9Y4pKJV21tVhL33YJtTcpyTuyR35EBuOZl/NtvUERWwOHKulBNmAoMW2AuDtHIr92jQM7qE+sCQNO/nw5lBUPR77lrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856122; 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=gY/lg29u2XDcIt+R2WUeT2vPrSCoSPMwfa90MHVVtL8=; b=DLsLHy98TQZi2dx36SEQ67V7Q+HiVFc86SPPS+ypdnv/I5ugd8PB/tB2QMOfejdlbjabJ19nfOcKYodiqQ1GhM7+pDrKKmaO0oW8YY9UQrzZ2DbRULP3itaDaZMCMrvVNy8z+0nEQQ8/b6/AfE2uL+PSG131yDOUVqsl6tCpeyM= 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 1620856122752116.42730897903596; Wed, 12 May 2021 14:48:42 -0700 (PDT) Received: from localhost ([::1]:59650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwif-0003dq-OE for importer@patchew.org; Wed, 12 May 2021 17:48:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh7-0000tN-Bg for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgx-0007ih-OY for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:03 -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-123-5LNvwarHMzahg6nFfdZ2_w-1; Wed, 12 May 2021 17:46:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D08F8015A8; Wed, 12 May 2021 21:46:52 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F6DE6267D; Wed, 12 May 2021 21:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856015; 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=gY/lg29u2XDcIt+R2WUeT2vPrSCoSPMwfa90MHVVtL8=; b=L9Z7J7zBVroKcDnrs/kBjIWtKXDQwjU8vIrA93EL3fglY4xivMnTdIxGdSnQdJoCD3m0Ob aTKXzjBcvVry13tP+kStR6c4KrLa/X1oq0p1KMGkHbrxxczDIOfADSQvy5q8POZ/kkfveL ekDATbOUD2KA1vxW01eilR/v0ovt3JY= X-MC-Unique: 5LNvwarHMzahg6nFfdZ2_w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 06/10] python/machine: disable warning for Popen in _launch() Date: Wed, 12 May 2021 17:46:38 -0400 Message-Id: <20210512214642.2803189-7-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" We handle this resource rather meticulously in shutdown/kill/wait/__exit__ et al, through the laborious mechanisms in _do_shutdown(). Quiet this pylint warning here. Signed-off-by: John Snow --- python/qemu/machine.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 8f86303b48f..0df5b2f386f 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -407,6 +407,9 @@ def _launch(self) -> None: self._args) ) LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args)) + + # Cleaning up of this subprocess is guaranteed by _do_shutdown. + # pylint: disable=3Dconsider-using-with self._popen =3D subprocess.Popen(self._qemu_full_args, stdin=3Dsubprocess.DEVNULL, stdout=3Dself._qemu_log_file, --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856210; cv=none; d=zohomail.com; s=zohoarc; b=aJt419plY5tJ0fMnSy9hMUz6QIAe/UGkaTEbUyjK77Ffo54HamjxzLYOSArDmi8HYKGp8Mgi3dXCkmYJUrmdxtAay1gW4ZLMB/pF436YvV5kKpZNXI31/wP0owPUFVjNVwgXz7rTtyUSprTAF2ET1jeqMu3n1b/op8XLvvonYZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856210; 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=WcxvslPiqRtDScsP2tpRXLNfLV3/rncXdVX3EotBdLs=; b=BHeEq3F7RdEWuwWPd63X7TuSN6gvkrknNtBuM+mQTfSOTD45k2ApRusXwitdslmzcvcyX7QjFpXgfKkj7lHFSVJUd8xJ541XwTFVhsu5xZona3Uo5cBMJEW54FksFupBKVXlTcH8eZmLcfEfkAeCnkXribFUEKtIfVRgz8z6eRE= 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 16208562108881020.3981299579597; Wed, 12 May 2021 14:50:10 -0700 (PDT) Received: from localhost ([::1]:38910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwk5-0000DX-Im for importer@patchew.org; Wed, 12 May 2021 17:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh5-0000rZ-GM for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwgz-0007kI-JR for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:03 -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-167-XGqIXiNRM7qLCFcdqvB75w-1; Wed, 12 May 2021 17:46:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E932107ACE3; Wed, 12 May 2021 21:46:53 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 796195D6AC; Wed, 12 May 2021 21:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856017; 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=WcxvslPiqRtDScsP2tpRXLNfLV3/rncXdVX3EotBdLs=; b=FUUMN+xRyI9Pa1wdte3XBAQRlEhryziic9gR4wemOwkKTvIFYu110RTyVWVrlYErvCYYuF zEf8gH/7+gWZc7JqDms5dg8Q5K2JqxSsCWk/TBB+fMT43uud9a6a1+EBw+S+ZAeIlOP7kT QFiz7Q7G7126Pb5rma+Q6RotM4GQ3Is= X-MC-Unique: XGqIXiNRM7qLCFcdqvB75w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 07/10] iotests: use subprocess.run where possible Date: Wed, 12 May 2021 17:46:39 -0400 Message-Id: <20210512214642.2803189-8-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" pylint 2.8.x adds warnings whenever we use Popen calls without using 'with', so it's desirable to convert synchronous calls to run() invocations where applicable. (Though, this trades one pylint warning for another due to a pylint bug, which I've silenced with a pragma and a link to the bug.) Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5af01828951..46deb7f4dd4 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -113,15 +113,16 @@ def qemu_tool_pipe_and_status(tool: str, args: Sequen= ce[str], Run a tool and return both its output and its exit code """ stderr =3D subprocess.STDOUT if connect_stderr else None - subp =3D subprocess.Popen(args, - stdout=3Dsubprocess.PIPE, - stderr=3Dstderr, - universal_newlines=3DTrue) - output =3D subp.communicate()[0] - if subp.returncode < 0: + res =3D subprocess.run(args, + stdout=3Dsubprocess.PIPE, + stderr=3Dstderr, + universal_newlines=3DTrue, + check=3DFalse) + output =3D res.stdout + if res.returncode < 0: cmd =3D ' '.join(args) - sys.stderr.write(f'{tool} received signal {-subp.returncode}: {cmd= }\n') - return (output, subp.returncode) + sys.stderr.write(f'{tool} received signal {-res.returncode}: {cmd}= \n') + return (output, res.returncode) =20 def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: """ @@ -1153,6 +1154,8 @@ def _verify_virtio_scsi_pci_or_ccw() -> None: =20 =20 def supports_quorum(): + # https://github.com/PyCQA/astroid/issues/689 + # pylint: disable=3Dunsupported-membership-test return 'quorum' in qemu_img_pipe('--help') =20 def verify_quorum(): --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856540; cv=none; d=zohomail.com; s=zohoarc; b=c50oNw41MSugcwnh+8KGUeo2XAH8XdsNDRJdyQ64tUGgsG3NaoqE9qL83JBBJL7XxT3frO8ECEnLd57nwlds+G/g9DGEavlRPRMIgZcYnZJbIX41sEzGgRaGFcbS4wb1v3svWasvxguAuF4P1O3IH91DY7UoknQxXJvl1XDOhNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856540; 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=YKa8TCfZgfw5MWHSTGTyGWahiPPJ7QhhwwwNSGsNGsM=; b=PvOw9DuQIglnzee01r63ycOI9LX+j1FAs6TSm6+OixbeMQI/jStj5WMfb9bOpKn+tR11w4GTooLBycJtAzi1tuqscsb2ei/qgPRQyxY204GyPXdvlP7N9b1M69+snKmDJHEc/6nqVmVHuYBIV8MogBdodWb2zQuKOw0T+OWQqOo= 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 1620856540111755.8453284721735; Wed, 12 May 2021 14:55:40 -0700 (PDT) Received: from localhost ([::1]:51472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwpP-0000VS-35 for importer@patchew.org; Wed, 12 May 2021 17:55:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwhE-0000zE-Tk for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh1-0007kr-H7 for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:12 -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-270-EImDde1YOg2-d6BCYNLHRA-1; Wed, 12 May 2021 17:46:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49AC91854E2A; Wed, 12 May 2021 21:46:54 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 777AD5D6AC; Wed, 12 May 2021 21:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856018; 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=YKa8TCfZgfw5MWHSTGTyGWahiPPJ7QhhwwwNSGsNGsM=; b=BrhUd4XocL+eFmFDGa+xTxVbTeYOqZKrRc1T5en+KIvGwhjEUmuyPwsy9I70cR03tBoEDc 4JGwLle5qYV7X4mtHh9ogDk2YYQc34yd88wCnSCgN9mHDPvBSxl0PTOQkAm+gbvEh97v3Y 52aV3HWCNs6LvjppJB5k4AHBKczh/oA= X-MC-Unique: EImDde1YOg2-d6BCYNLHRA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 08/10] iotests: use 'with open()' where applicable Date: Wed, 12 May 2021 17:46:40 -0400 Message-Id: <20210512214642.2803189-9-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" More pylint 2.8.x warning hushing: use open's context manager where it's applicable to do so to avoid a warning. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/iotests.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 46deb7f4dd4..5d5ec40429b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -335,13 +335,12 @@ def compare_images(img1, img2, fmt1=3Dimgfmt, fmt2=3D= imgfmt): =20 def create_image(name, size): '''Create a fully-allocated raw image with sector markers''' - file =3D open(name, 'wb') - i =3D 0 - while i < size: - sector =3D struct.pack('>l504xl', i // 512, i // 512) - file.write(sector) - i =3D i + 512 - file.close() + with open(name, 'wb') as outfile: + i =3D 0 + while i < size: + sector =3D struct.pack('>l504xl', i // 512, i // 512) + outfile.write(sector) + i =3D i + 512 =20 def image_size(img): '''Return image's virtual size''' --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856432; cv=none; d=zohomail.com; s=zohoarc; b=ExR3zzvPV6SvjTNsjepjRUlIeEJ4aYyPkYvNJ+KHfoJwHndN/R5i5onCXV+58OnemP04yJX813lsrECUDs7ILunc1hp5I/ZtERNiw0YVaRD3pz0hniLNU9clbCM9Dry/Lya1h0785aCqeb9ovqebivh0VQnkGhH30IGBA8sNuD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856432; 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=4sFJv/DkragtqymWK3EGQqPEsOtYvbU9qn3Y2L90W4c=; b=DYV08vbyl7KfQQDzVBs9H5rmMbGPX5gxYA8m319hdxShC3t0e7DHW/PuFpif99x7b1+/RohgNN/geu4SEri0F1m8tpVzXcdXAblS+oR6Pf9C3HAOb0mvuVOWDQex6rF2KGf3+Ksiw5BlER2xONW/AMnNzG5vx1C8HibQrlxYQds= 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 162085643243338.9865542113115; Wed, 12 May 2021 14:53:52 -0700 (PDT) Received: from localhost ([::1]:47728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwnf-0006IT-6n for importer@patchew.org; Wed, 12 May 2021 17:53:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh7-0000tT-BF for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh1-0007kb-EF for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:03 -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-357-5T9mPvooO-Gd5snqZw3o8w-1; Wed, 12 May 2021 17:46:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FC80107ACCA; Wed, 12 May 2021 21:46:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 705955D6AC; Wed, 12 May 2021 21:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856017; 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=4sFJv/DkragtqymWK3EGQqPEsOtYvbU9qn3Y2L90W4c=; b=Xi4cAUWeQu5jMVL15ubTU+Jr1/ujE9LvBz9etGPM6PyQrmAoF1JF+Oj4VC4iVOy8Nj2k4Q KmM3Cpv0jabp27wSYfN7yF/SPzMiwfpnD0Y4JGPdXAo/IxubYvy+HEKVuMb+TKNHXKmOZi xnNI1PfFhBWe/iS5pfD2t8gmA92DmQs= X-MC-Unique: 5T9mPvooO-Gd5snqZw3o8w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 09/10] iotests: silence spurious consider-using-with warnings Date: Wed, 12 May 2021 17:46:41 -0400 Message-Id: <20210512214642.2803189-10-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" In a few cases, we can't use 'with ...' because they belong to long-running classes that need those items to stay open at the end of the block. We're handling it, so tell pylint to shush. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 2 +- tests/qemu-iotests/testrunner.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5d5ec40429b..e09c991b84e 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -311,7 +311,7 @@ def qemu_nbd_popen(*args): cmd.extend(args) =20 log('Start NBD server') - p =3D subprocess.Popen(cmd) + p =3D subprocess.Popen(cmd) # pylint: disable=3Dconsider-using-with try: while not os.path.exists(pid_file): if p.poll() is not None: diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunn= er.py index 1fc61fcaa34..34fb551c01b 100644 --- a/tests/qemu-iotests/testrunner.py +++ b/tests/qemu-iotests/testrunner.py @@ -258,6 +258,7 @@ def do_run_test(self, test: str) -> TestResult: =20 t0 =3D time.time() with f_bad.open('w', encoding=3D"utf-8") as f: + # pylint: disable=3Dconsider-using-with proc =3D subprocess.Popen(args, cwd=3Dstr(f_test.parent), env= =3Denv, stdout=3Df, stderr=3Dsubprocess.STDOUT) try: --=20 2.30.2 From nobody Fri May 17 04:49:42 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=1620856617; cv=none; d=zohomail.com; s=zohoarc; b=CcMB8++me/xq9+7shlwTUAAT2ykV30Sf9EYbYF7u6HHCmTVuVRaNmNQNyBzow2laH+GP6CbVP6ai8cewCDZ095e1EhfcqnysQuqI0nFE5zP0dTPsFECyLe09agi9iigDWHuHRA+bUBd8dua1SMVBKmAVYn3mveLKp2gpVnMApeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620856617; 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=Oeno9likNB+jpO1aJh2/LCxbzeq2feGwPvH+914tnno=; b=e7d3LXQsv8oU9lv1xixnUBP7m4N8TWaQ/a2TsGBgbCSwXvKC0EaMKV532MFOhBDdeNqS8/dgMitVGeLprX//J9WmkDiSWwCnUfqPwKzwAWE61iOUYcLURrE1XxAXs86QC6j0W/IyXhgXjqUm5KoyG2QM1bTyJlMmm9rfYsZdxA4= 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 1620856617614621.76005648581; Wed, 12 May 2021 14:56:57 -0700 (PDT) Received: from localhost ([::1]:54434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgwqe-0002aj-IG for importer@patchew.org; Wed, 12 May 2021 17:56:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwhF-0000zF-0e for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgwh3-0007lE-9u for qemu-devel@nongnu.org; Wed, 12 May 2021 17:47:12 -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-471-limscjvROkSsmDcgZ5kbPQ-1; Wed, 12 May 2021 17:46:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 455E6107ACE3; Wed, 12 May 2021 21:46:56 +0000 (UTC) Received: from scv.redhat.com (ovpn-117-64.rdu2.redhat.com [10.10.117.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 677395D6AC; Wed, 12 May 2021 21:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620856019; 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=Oeno9likNB+jpO1aJh2/LCxbzeq2feGwPvH+914tnno=; b=HV3dS4gLzLSmsNX7G+GpGaqsRXfGO9mzGKMSmjRmxDucfhhOl4Yxy18RTe/4mGF6o6EULZ gZw1YqQppWEt0SWw9bLhliNU3LCd/S1T8o1px2GV9v46x7FPf3U4gGuBiKt+FzoBEL2Usf En/boKFH5SjGS9ZWq38IOiE/EDxMySc= X-MC-Unique: limscjvROkSsmDcgZ5kbPQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH 10/10] iotests: ensure that QemuIoInteractive definitely closes Date: Wed, 12 May 2021 17:46:42 -0400 Message-Id: <20210512214642.2803189-11-jsnow@redhat.com> In-Reply-To: <20210512214642.2803189-1-jsnow@redhat.com> References: <20210512214642.2803189-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Cleber Rosa , John Snow 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" More on the lines of quieting pylint 2.8.x, though to make it obvious that we definitely handle the cleanup here, I elected to bolster the close() method here. 1. Check for the process having terminated early more rigorously by checking poll() directly. 2. Change the prompt read into an assertion. 3. Ensure that the final communicate() call *definitely* closes the socket, adding a timeout and a final kill just in case. Signed-off-by: John Snow --- tests/qemu-iotests/iotests.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index e09c991b84e..12e876fa67d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -238,20 +238,27 @@ def qemu_io_silent_check(*args): class QemuIoInteractive: def __init__(self, *args): self.args =3D qemu_io_args_no_fmt + list(args) + + # Resource cleaned up via close() + # pylint: disable=3Dconsider-using-with self._p =3D subprocess.Popen(self.args, stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT, universal_newlines=3DTrue) + if self._p.poll(): + # Failed to start. + out =3D self._p.stdout.read() + raise subprocess.SubprocessError(out, self._p.poll()) + + # Eat the first prompt out =3D self._p.stdout.read(9) - if out !=3D 'qemu-io> ': - # Most probably qemu-io just failed to start. - # Let's collect the whole output and exit. - out +=3D self._p.stdout.read() - self._p.wait(timeout=3D1) - raise ValueError(out) + assert out =3D=3D 'qemu-io> ', "Did not understand qemu-io prompt" =20 def close(self): - self._p.communicate('q\n') + try: + self._p.communicate('q\n', timeout=3D5) + except subprocess.TimeoutExpired: + self._p.kill() =20 def _read_output(self): pattern =3D 'qemu-io> ' --=20 2.30.2