From nobody Sat Feb 7 09:04:13 2026 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=1763718021; cv=none; d=zohomail.com; s=zohoarc; b=mvv2MSI1EJW883rPn0MlLhK95rQgPG2ZtCLaJEMYDMx2VzPS5HYM/QLyGRuWltg2EY9Ycp6O1aSb6aQtLZv/i801JKMLFr9YaXWGWS8tDRKd7SS4m30DO9y6JJk9dcBiZhRgKnI1i8nYu85DSFF2X4pUntDGoGhKKRJwgFSBqG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763718021; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Io0s1tnUZyrqZWP1vXpYf7coc9LTL5KfzTYr+KpgWRc=; b=C63p6bC+ALSntB49r3KHDiofZO+ZY9s9hgICqegROVbVqAaPfrp+wp6J4z5Zc/gKOXSFIuhaMSgKVyTzfFzlbeIYQFhlEsT1xndh9Ov6e3HGsPAKiILvVu+gktdPZ/HdOHqnzzEk0GSAZqysZ2AjWlQReW04UZ82989XSofd/ms= 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 1763718021818489.3403128532483; Fri, 21 Nov 2025 01:40:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vMNb6-0005fR-DR; Fri, 21 Nov 2025 04:38:32 -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 1vMNb4-0005em-Sf for qemu-devel@nongnu.org; Fri, 21 Nov 2025 04:38:31 -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 1vMNb3-0004F0-8Q for qemu-devel@nongnu.org; Fri, 21 Nov 2025 04:38:30 -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-610-Tlkv-qsoMdC_pAbkGfyk-g-1; Fri, 21 Nov 2025 04:38:25 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 8BC111800370; Fri, 21 Nov 2025 09:38:23 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.32.78]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2560730044DC; Fri, 21 Nov 2025 09:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763717908; 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=Io0s1tnUZyrqZWP1vXpYf7coc9LTL5KfzTYr+KpgWRc=; b=gvTCTqDHC99aH36l8PPHjvOuIamiSax9+mdbIBimV7cG9ZDTEEm3E81qZG+pqz7u8hMZhj Zko9gse/UPgvC0YulKT+PQfPws3MGXcwLuAMvpzSav+HJFPCe3DPJG8X1uN4w7dFDxJo9M ZHAAgbuaORzzid70Fg3rF/yYPFJOuEE= X-MC-Unique: Tlkv-qsoMdC_pAbkGfyk-g-1 X-Mimecast-MFC-AGG-ID: Tlkv-qsoMdC_pAbkGfyk-g_1763717904 From: Thomas Huth To: qemu-devel@nongnu.org Cc: Richard Henderson , Akihiko Odaki , Zhao Liu , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 03/10] tests/functional/x86_64/test_virtio_gpu: Fix various issues reported by pylint Date: Fri, 21 Nov 2025 10:38:05 +0100 Message-ID: <20251121093812.280911-4-thuth@redhat.com> In-Reply-To: <20251121093812.280911-1-thuth@redhat.com> References: <20251121093812.280911-1-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: -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, 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: 1763718023688018901 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. Message-Id: <20251113114015.490303-1-thuth@redhat.com> Reviewed-by: Akihiko Odaki Reviewed-by: Zhao Liu Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Thomas Huth Message-ID: <20251119082636.43286-5-thuth@redhat.com> --- tests/functional/x86_64/test_virtio_gpu.py | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/functional/x86_64/test_virtio_gpu.py b/tests/functional/= x86_64/test_virtio_gpu.py index be96de24da2..58b0f72ba42 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,29 @@ 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: + with subprocess.Popen([vug, "--virgl", f"--fd=3D{vug_sock.file= no()}"], + stdin=3Dsubprocess.DEVNULL, + stdout=3Dvug_log_file, + stderr=3Dsubprocess.STDOUT, + shell=3DFalse, + close_fds=3DFalse) as vugp: + self._test_vhost_user_vga_virgl(qemu_sock, + kernel_path, initrd_path) + qemu_sock.close() + vug_sock.close() + vugp.terminate() + + def _test_vhost_user_vga_virgl(self, qemu_sock, kernel_path, initrd_pa= th): 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,17 +131,14 @@ 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") exec_command_and_wait_for_pattern(self, "/usr/sbin/modprobe virtio= _gpu", "features: +virgl +edid") self.vm.shutdown() - qemu_sock.close() - vug_sock.close() - vugp.terminate() - vugp.wait() + =20 if __name__ =3D=3D '__main__': QemuSystemTest.main() --=20 2.51.1