qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, "Hanna Reitz" <hreitz@redhat.com>,
	"Jagannathan Raman" <jag.raman@oracle.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	qemu-block@nongnu.org, "John Snow" <jsnow@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>
Subject: Re: [PATCH 09/14] functional: ensure sockets and files are closed
Date: Tue, 15 Jul 2025 16:12:09 +0100	[thread overview]
Message-ID: <aHZvye9EfVjsvDj2@redhat.com> (raw)
In-Reply-To: <97439ae2-5d37-49c2-a9d4-ff2d6aefee3b@redhat.com>

On Tue, Jul 15, 2025 at 05:03:07PM +0200, Thomas Huth wrote:
> On 15/07/2025 16.30, Daniel P. Berrangé wrote:
> > The multiprocess and virtio_gpu tests open sockets but then forget
> > to close them, which triggers resource leak warnings
> > 
> > The virtio_gpu test also fails to close a log file it opens.
> > 
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >   tests/functional/test_multiprocess.py | 3 +++
> >   tests/functional/test_virtio_gpu.py   | 2 ++
> >   2 files changed, 5 insertions(+)
> > 
> > diff --git a/tests/functional/test_multiprocess.py b/tests/functional/test_multiprocess.py
> > index 751cf10e63..92d5207b0e 100755
> > --- a/tests/functional/test_multiprocess.py
> > +++ b/tests/functional/test_multiprocess.py
> > @@ -83,6 +83,9 @@ def do_test(self, kernel_asset, initrd_asset,
> >                                             'cat /sys/bus/pci/devices/*/uevent',
> >                                             'PCI_ID=1000:0012')
> > +        proxy_sock.close()
> > +        remote_sock.close()
> > +
> >       def test_multiprocess(self):
> >           kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
> >           if self.arch == 'x86_64':
> > diff --git a/tests/functional/test_virtio_gpu.py b/tests/functional/test_virtio_gpu.py
> > index 81c9156d63..be96de24da 100755
> > --- a/tests/functional/test_virtio_gpu.py
> > +++ b/tests/functional/test_virtio_gpu.py
> > @@ -108,6 +108,7 @@ def test_vhost_user_vga_virgl(self):
> >               shell=False,
> >               close_fds=False,
> >           )
> > +        self._vug_log_file.close()
> 
> Maybe cleaner to close it at the end of the function?

This was the last place it was needed - just out of sight in the context
of the diff the file is passed to Popen() which connects it to stderr.
So nothing in this test may access the file after this point to avoid
concurent overlapping writes to the same file.

> 
>  Thomas
> 
> 
> >           self.vm.set_console()
> >           self.vm.add_args("-cpu", "host")
> > @@ -135,6 +136,7 @@ def test_vhost_user_vga_virgl(self):
> >                                             "features: +virgl +edid")
> >           self.vm.shutdown()
> >           qemu_sock.close()
> > +        vug_sock.close()
> >           vugp.terminate()
> >           vugp.wait()
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-07-15 15:46 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-15 14:30 [PATCH 00/14] python: misc cleanups for python code Daniel P. Berrangé
2025-07-15 14:30 ` [PATCH 01/14] python: Replace asyncio.get_event_loop for Python 3.14 Daniel P. Berrangé
2025-08-19 19:47   ` John Snow
2025-08-19 19:51     ` Daniel P. Berrangé
2025-08-19 20:00       ` John Snow
2025-07-15 14:30 ` [PATCH 02/14] python: avoid deprecation warning with get_event_loop Daniel P. Berrangé
2025-07-23 21:24   ` Eric Blake
2025-08-19 19:49     ` John Snow
2025-08-19 19:52       ` Daniel P. Berrangé
2025-07-15 14:30 ` [PATCH 03/14] python: drop 'is_closing' back compat helper Daniel P. Berrangé
2025-07-24 12:44   ` Alex Bennée
2025-08-19 19:56   ` John Snow
2025-07-15 14:30 ` [PATCH 04/14] python: drop 'wait_closed' " Daniel P. Berrangé
2025-08-19 19:56   ` John Snow
2025-07-15 14:30 ` [PATCH 05/14] python: drop 'asyncio_run' " Daniel P. Berrangé
2025-08-19 19:57   ` John Snow
2025-07-15 14:30 ` [PATCH 06/14] python: drop 'create_task' " Daniel P. Berrangé
2025-08-19 19:57   ` John Snow
2025-07-15 14:30 ` [PATCH 07/14] iotests: drop compat for old version context manager Daniel P. Berrangé
2025-08-19 20:04   ` John Snow
2025-07-15 14:30 ` [PATCH 08/14] functional: ensure log handlers are closed Daniel P. Berrangé
2025-07-15 14:50   ` Thomas Huth
2025-07-15 14:30 ` [PATCH 09/14] functional: ensure sockets and files " Daniel P. Berrangé
2025-07-15 15:03   ` Thomas Huth
2025-07-15 15:12     ` Daniel P. Berrangé [this message]
2025-07-15 15:14       ` Thomas Huth
2025-07-15 14:30 ` [PATCH 10/14] functional: always enable all python warnings Daniel P. Berrangé
2025-07-15 15:15   ` Thomas Huth
2025-08-19 20:08     ` John Snow
2025-07-15 14:30 ` [PATCH 11/14] python: ensure QEMUQtestProtocol closes its socket Daniel P. Berrangé
2025-08-19 20:12   ` John Snow
2025-08-19 20:29     ` Daniel P. Berrangé
2025-07-15 14:30 ` [PATCH 12/14] iotests/147: ensure temporary sockets are closed before exiting Daniel P. Berrangé
2025-08-19 21:37   ` John Snow
2025-07-15 14:30 ` [PATCH 13/14] iotests/151: ensure subprocesses are cleaned up Daniel P. Berrangé
2025-08-19 21:37   ` John Snow
2025-08-20  9:45     ` Daniel P. Berrangé
2025-07-15 14:30 ` [PATCH 14/14] iotests/check: always enable all python warnings Daniel P. Berrangé
2025-08-20  5:03   ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aHZvye9EfVjsvDj2@redhat.com \
    --to=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=hreitz@redhat.com \
    --cc=jag.raman@oracle.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).