1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(logs): libvirt prints no errors on the processes' stderr

libvirt's default handler printed each error on stderr without saying
where it came from: in Docker those lines went to docker logs, and a
VM page read of a shut-off VM left one there. Every process that talks to
libvirt imports vrtManager.connection, which now registers a silent
handler; the errors still reach their callers as exceptions. The
console callback's own registration is dropped.
This commit is contained in:
catborise 2026-11-05 15:12:06 +03:00
parent 5d90d3fcf9
commit f670ee7333
3 changed files with 17 additions and 3 deletions

View file

@ -3,6 +3,8 @@
import contextlib
import os
import socket
import subprocess
import sys
import threading
import time
import unittest
@ -410,3 +412,14 @@ class EventLoopTestCase(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
class LibvirtStderrTestCase(unittest.TestCase):
def test_a_libvirt_error_is_not_printed_on_stderr(self):
script = (
"from django.conf import settings; settings.configure(); "
"import libvirt, vrtManager.connection\n"
"try:\n libvirt.open('test:///default').lookupByName('no-such-vm')\nexcept libvirt.libvirtError:\n pass"
)
result = subprocess.run([sys.executable, "-c", script], cwd=os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), capture_output=True, text=True)
self.assertEqual((result.returncode, result.stderr), (0, ""))