From 3c095c6b8d5e0132a0dcd1f4d13dd7bd186d0f48 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Fri, 31 Oct 2025 13:37:52 +0100 Subject: [PATCH] Make guestfs' Tpool usage optional When running in eventlet mode we keep the original eventlet.tpool usage but when running in threading mode we call the functions directly on the thread of the caller. Change-Id: I779374814a8ed8b2146bea226afe1250dea63079 Signed-off-by: Balazs Gibizer --- nova/tests/unit/virt/disk/vfs/test_guestfs.py | 6 +++--- nova/virt/disk/vfs/guestfs.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nova/tests/unit/virt/disk/vfs/test_guestfs.py b/nova/tests/unit/virt/disk/vfs/test_guestfs.py index 9dc937202a..9e089341fd 100644 --- a/nova/tests/unit/virt/disk/vfs/test_guestfs.py +++ b/nova/tests/unit/virt/disk/vfs/test_guestfs.py @@ -334,7 +334,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase): @mock.patch('os.access') @mock.patch('os.uname', return_value=os_uname( 'Linux', '', 'kernel_name', '', '')) - def test_appliance_setup_inspect_capabilties_fail_with_ubuntu( + def test_appliance_setup_inspect_capabilities_fail_with_ubuntu( self, mock_uname, mock_access, ): # In ubuntu os will default host kernel as 600 permission @@ -343,7 +343,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase): vfs = vfsimpl.VFSGuestFS(self.qcowfile) mock_access.return_value = False self.flags(debug=False, group='guestfs') - with mock.patch('eventlet.tpool.Proxy', return_value=m) as tpool_mock: + with mock.patch('nova.utils.tpool_wrap', return_value=m) as target: self.assertRaises(exception.LibguestfsCannotReadKernel, vfs.inspect_capabilities) m.add_drive.assert_called_once_with('/dev/null') @@ -351,7 +351,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase): mock_access.assert_called_once_with('/boot/vmlinuz-kernel_name', mock.ANY) mock_uname.assert_called_once_with() - self.assertEqual(1, tpool_mock.call_count) + self.assertEqual(1, target.call_count) def test_appliance_setup_inspect_capabilties_debug_mode(self): """Asserts that we do not use an eventlet thread pool when guestfs diff --git a/nova/virt/disk/vfs/guestfs.py b/nova/virt/disk/vfs/guestfs.py index 5b3d7f6a7e..66fc561a41 100644 --- a/nova/virt/disk/vfs/guestfs.py +++ b/nova/virt/disk/vfs/guestfs.py @@ -14,13 +14,13 @@ import os -from eventlet import tpool from oslo_log import log as logging from oslo_utils import importutils import nova.conf from nova import exception from nova.i18n import _ +from nova import utils from nova.virt.disk.vfs import api as vfs from nova.virt.image import model as imgmodel @@ -82,7 +82,7 @@ class VFSGuestFS(vfs.VFS): LOG.debug('Inspecting guestfs capabilities non-threaded.') g = guestfs.GuestFS() else: - g = tpool.Proxy(guestfs.GuestFS()) + g = utils.tpool_wrap(guestfs.GuestFS()) g.add_drive("/dev/null") # sic g.launch() except Exception as e: @@ -181,7 +181,7 @@ class VFSGuestFS(vfs.VFS): LOG.debug("Setting up appliance for %(image)s", {'image': self.image}) try: - self.handle = tpool.Proxy( + self.handle = utils.tpool_wrap( guestfs.GuestFS(python_return_dict=False, close_on_exit=False)) except TypeError as e: @@ -189,7 +189,7 @@ class VFSGuestFS(vfs.VFS): # NOTE(russellb) In case we're not using a version of # libguestfs new enough to support parameters close_on_exit # and python_return_dict which were added in libguestfs 1.20. - self.handle = tpool.Proxy(guestfs.GuestFS()) + self.handle = utils.tpool_wrap(guestfs.GuestFS()) else: raise