From nobody Fri Nov 14 15:19:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1762344715; cv=none; d=zohomail.com; s=zohoarc; b=fqHP3TQ3FUOsaRZW4Ue+5kkeTvbOWAQ2mrBDyTJC5sm5poYX6NhND3I50fPu+PTXxrY9Nuhla537ig6p5mr6mh2r/79/I1P152bP9Z26MIox0tsM8M/D2OloHEzNZEkdRCesrLa4zXr5pZc+ClrRGmXhtSD806CTEUsHnSPR1Kg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762344715; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Or1AQ8Vt42YOOBGKccWYFLF+48IAdRAE22GPCSD2pQ4=; b=d7clNBPr0XmgA0khKf+75imiTWQBObTelDQB53xiMQ5W/tpcItaL8wHPiyfoe/7dKJ47C+cP4wkSIkTQ4jQcvHGWfxHgLLeWKfzOwakZUL39IIYcRNu/dORo1TqEVxoE6ZreN/zvSvdQfzPEIMVSh0w/TkbzKj6SS2/dUsLTrXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762344715210583.538755577561; Wed, 5 Nov 2025 04:11:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vGcM0-0004gY-R1; Wed, 05 Nov 2025 07:11:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vGcL2-0004Zn-Po for qemu-devel@nongnu.org; Wed, 05 Nov 2025 07:10:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vGcKv-0007Nc-SP for qemu-devel@nongnu.org; Wed, 05 Nov 2025 07:10:03 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-206-eiqFnNhlMiieQyeq6xBGJw-1; Wed, 05 Nov 2025 07:09:56 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 63DEA1800447; Wed, 5 Nov 2025 12:09:55 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.33.72]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C020D1800451; Wed, 5 Nov 2025 12:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762344600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Or1AQ8Vt42YOOBGKccWYFLF+48IAdRAE22GPCSD2pQ4=; b=MiDhYiEzTW4AXXc9Lxn8m4mgVUU46ZEnvDbC548rqANJFuDZyR3KlL5V1ToyxV3QHgC+SH LtfE716UAoaMYfoYPd4XoBlaxGcsg9/6BmNbMm6P4obVj6ZyDcKF6GyvQeLFXQ90fBwC/O Kp5WR8ZraK2F8n/c4cYi3TpwJqbgQ2E= X-MC-Unique: eiqFnNhlMiieQyeq6xBGJw-1 X-Mimecast-MFC-AGG-ID: eiqFnNhlMiieQyeq6xBGJw_1762344595 From: Thomas Huth To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Cc: Akihiko Odaki , Dmitry Osipenko , Zhao Liu , Paolo Bonzini Subject: [PATCH] tests/functional/x86_64/test_virtio_gpu: Fix various issues reported by pylint Date: Wed, 5 Nov 2025 13:09:51 +0100 Message-ID: <20251105120951.15815-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.517, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1762344719568154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Use the recommended order for import statements, specify the kind of exceptions that we try to catch, use f-strings where it makes sense, rewrite the vug_log_file part with a proper "with" statement and fix some FIXMEs by checking for the availability of the devices, etc. Signed-off-by: Thomas Huth --- tests/functional/x86_64/test_virtio_gpu.py | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/functional/x86_64/test_virtio_gpu.py b/tests/functional/= x86_64/test_virtio_gpu.py index be96de24da2..a25f15cdb00 100755 --- a/tests/functional/x86_64/test_virtio_gpu.py +++ b/tests/functional/x86_64/test_virtio_gpu.py @@ -5,22 +5,23 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 +import os +import socket +import subprocess =20 from qemu_test import QemuSystemTest, Asset from qemu_test import wait_for_console_pattern from qemu_test import exec_command_and_wait_for_pattern from qemu_test import is_readable_executable_file =20 - -import os -import socket -import subprocess +from qemu.machine.machine import VMLaunchFailure =20 =20 def pick_default_vug_bin(test): bld_dir_path =3D test.build_file("contrib", "vhost-user-gpu", "vhost-u= ser-gpu") if is_readable_executable_file(bld_dir_path): return bld_dir_path + return None =20 =20 class VirtioGPUx86(QemuSystemTest): @@ -46,8 +47,8 @@ def wait_for_console_pattern(self, success_message, vm=3D= None): ) =20 def test_virtio_vga_virgl(self): - # FIXME: should check presence of virtio, virgl etc self.require_accelerator('kvm') + self.require_device('virtio-vga-gl') =20 kernel_path =3D self.ASSET_KERNEL.fetch() initrd_path =3D self.ASSET_INITRD.fetch() @@ -68,7 +69,7 @@ def test_virtio_vga_virgl(self): ) try: self.vm.launch() - except: + except VMLaunchFailure: # TODO: probably fails because we are missing the VirGL featur= es self.skipTest("VirGL not enabled?") =20 @@ -78,8 +79,8 @@ def test_virtio_vga_virgl(self): ) =20 def test_vhost_user_vga_virgl(self): - # FIXME: should check presence of vhost-user-gpu, virgl, memfd etc self.require_accelerator('kvm') + self.require_device('vhost-user-vga') =20 vug =3D pick_default_vug_bin(self) if not vug: @@ -95,27 +96,26 @@ def test_vhost_user_vga_virgl(self): os.set_inheritable(qemu_sock.fileno(), True) os.set_inheritable(vug_sock.fileno(), True) =20 - self._vug_log_path =3D self.log_file("vhost-user-gpu.log") - self._vug_log_file =3D open(self._vug_log_path, "wb") - self.log.info('Complete vhost-user-gpu.log file can be ' - 'found at %s', self._vug_log_path) - - vugp =3D subprocess.Popen( - [vug, "--virgl", "--fd=3D%d" % vug_sock.fileno()], - stdin=3Dsubprocess.DEVNULL, - stdout=3Dself._vug_log_file, - stderr=3Dsubprocess.STDOUT, - shell=3DFalse, - close_fds=3DFalse, - ) - self._vug_log_file.close() + vug_log_path =3D self.log_file("vhost-user-gpu.log") + self.log.info('Complete vhost-user-gpu.log file can be found at %s= ', + vug_log_path) + with open(vug_log_path, "wb") as vug_log_file: + # pylint: disable=3Dconsider-using-with + vugp =3D subprocess.Popen( + [vug, "--virgl", f"--fd=3D{vug_sock.fileno()}"], + stdin=3Dsubprocess.DEVNULL, + stdout=3Dvug_log_file, + stderr=3Dsubprocess.STDOUT, + shell=3DFalse, + close_fds=3DFalse, + ) =20 self.vm.set_console() self.vm.add_args("-cpu", "host") self.vm.add_args("-m", "2G") self.vm.add_args("-object", "memory-backend-memfd,id=3Dmem,size=3D= 2G") self.vm.add_args("-machine", "pc,memory-backend=3Dmem,accel=3Dkvm") - self.vm.add_args("-chardev", "socket,id=3Dvug,fd=3D%d" % qemu_sock= .fileno()) + self.vm.add_args("-chardev", f"socket,id=3Dvug,fd=3D{qemu_sock.fil= eno()}") self.vm.add_args("-device", "vhost-user-vga,chardev=3Dvug") self.vm.add_args("-display", "egl-headless") self.vm.add_args( @@ -128,7 +128,7 @@ def test_vhost_user_vga_virgl(self): ) try: self.vm.launch() - except: + except VMLaunchFailure: # TODO: probably fails because we are missing the VirGL featur= es self.skipTest("VirGL not enabled?") self.wait_for_console_pattern("as init process") --=20 2.51.1