Merge "Make guestfs' Tpool usage optional"

This commit is contained in:
Zuul
2025-12-16 13:27:31 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 7 deletions

View File

@@ -334,7 +334,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
@mock.patch('os.access') @mock.patch('os.access')
@mock.patch('os.uname', return_value=os_uname( @mock.patch('os.uname', return_value=os_uname(
'Linux', '', 'kernel_name', '', '')) '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, self, mock_uname, mock_access,
): ):
# In ubuntu os will default host kernel as 600 permission # In ubuntu os will default host kernel as 600 permission
@@ -343,7 +343,7 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
vfs = vfsimpl.VFSGuestFS(self.qcowfile) vfs = vfsimpl.VFSGuestFS(self.qcowfile)
mock_access.return_value = False mock_access.return_value = False
self.flags(debug=False, group='guestfs') 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, self.assertRaises(exception.LibguestfsCannotReadKernel,
vfs.inspect_capabilities) vfs.inspect_capabilities)
m.add_drive.assert_called_once_with('/dev/null') 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_access.assert_called_once_with('/boot/vmlinuz-kernel_name',
mock.ANY) mock.ANY)
mock_uname.assert_called_once_with() 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): def test_appliance_setup_inspect_capabilties_debug_mode(self):
"""Asserts that we do not use an eventlet thread pool when guestfs """Asserts that we do not use an eventlet thread pool when guestfs

View File

@@ -14,13 +14,13 @@
import os import os
from eventlet import tpool
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
import nova.conf import nova.conf
from nova import exception from nova import exception
from nova.i18n import _ from nova.i18n import _
from nova import utils
from nova.virt.disk.vfs import api as vfs from nova.virt.disk.vfs import api as vfs
from nova.virt.image import model as imgmodel from nova.virt.image import model as imgmodel
@@ -82,7 +82,7 @@ class VFSGuestFS(vfs.VFS):
LOG.debug('Inspecting guestfs capabilities non-threaded.') LOG.debug('Inspecting guestfs capabilities non-threaded.')
g = guestfs.GuestFS() g = guestfs.GuestFS()
else: else:
g = tpool.Proxy(guestfs.GuestFS()) g = utils.tpool_wrap(guestfs.GuestFS())
g.add_drive("/dev/null") # sic g.add_drive("/dev/null") # sic
g.launch() g.launch()
except Exception as e: except Exception as e:
@@ -181,7 +181,7 @@ class VFSGuestFS(vfs.VFS):
LOG.debug("Setting up appliance for %(image)s", LOG.debug("Setting up appliance for %(image)s",
{'image': self.image}) {'image': self.image})
try: try:
self.handle = tpool.Proxy( self.handle = utils.tpool_wrap(
guestfs.GuestFS(python_return_dict=False, guestfs.GuestFS(python_return_dict=False,
close_on_exit=False)) close_on_exit=False))
except TypeError as e: except TypeError as e:
@@ -189,7 +189,7 @@ class VFSGuestFS(vfs.VFS):
# NOTE(russellb) In case we're not using a version of # NOTE(russellb) In case we're not using a version of
# libguestfs new enough to support parameters close_on_exit # libguestfs new enough to support parameters close_on_exit
# and python_return_dict which were added in libguestfs 1.20. # 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: else:
raise raise