Merge "libvirt - Add log if libguestfs can't read host kernel"
This commit is contained in:
commit
93797372c2
|
@ -2107,6 +2107,10 @@ class UnsupportedHostCPUControlPolicy(Invalid):
|
||||||
msg_fmt = _("Requested CPU control policy not supported by host")
|
msg_fmt = _("Requested CPU control policy not supported by host")
|
||||||
|
|
||||||
|
|
||||||
|
class LibguestfsCannotReadKernel(Invalid):
|
||||||
|
msg_fmt = _("Libguestfs does not have permission to read host kernel.")
|
||||||
|
|
||||||
|
|
||||||
class RealtimePolicyNotSupported(Invalid):
|
class RealtimePolicyNotSupported(Invalid):
|
||||||
msg_fmt = _("Realtime policy not supported by hypervisor")
|
msg_fmt = _("Realtime policy not supported by hypervisor")
|
||||||
|
|
||||||
|
|
|
@ -310,3 +310,21 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
|
||||||
vfs = vfsimpl.VFSGuestFS(self.qcowfile)
|
vfs = vfsimpl.VFSGuestFS(self.qcowfile)
|
||||||
vfs.setup(mount=False)
|
vfs.setup(mount=False)
|
||||||
self.assertFalse(setup_os.called)
|
self.assertFalse(setup_os.called)
|
||||||
|
|
||||||
|
@mock.patch('os.access')
|
||||||
|
@mock.patch('os.uname', return_value=('Linux', '', 'kernel_name'))
|
||||||
|
def test_appliance_setup_inspect_capabilties_fail_with_ubuntu(self,
|
||||||
|
mock_uname,
|
||||||
|
mock_access):
|
||||||
|
# In ubuntu os will default host kernel as 600 permission
|
||||||
|
m = mock.MagicMock()
|
||||||
|
m.launch.side_effect = Exception
|
||||||
|
vfs = vfsimpl.VFSGuestFS(self.qcowfile)
|
||||||
|
with mock.patch('eventlet.tpool.Proxy', return_value=m):
|
||||||
|
self.assertRaises(exception.LibguestfsCannotReadKernel,
|
||||||
|
vfs.inspect_capabilities)
|
||||||
|
m.add_drive.assert_called_once_with('/dev/null')
|
||||||
|
m.launch.assert_called_once_with()
|
||||||
|
mock_access.assert_called_once_with('/boot/vmlinuz-kernel_name',
|
||||||
|
mock.ANY)
|
||||||
|
mock_uname.assert_called_once_with()
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from eventlet import tpool
|
from eventlet import tpool
|
||||||
|
import os
|
||||||
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 six
|
import six
|
||||||
|
@ -78,6 +79,8 @@ class VFSGuestFS(vfs.VFS):
|
||||||
g.add_drive("/dev/null") # sic
|
g.add_drive("/dev/null") # sic
|
||||||
g.launch()
|
g.launch()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if os.access("/boot/vmlinuz-%s" % os.uname()[2], os.R_OK):
|
||||||
|
raise exception.LibguestfsCannotReadKernel()
|
||||||
raise exception.NovaException(
|
raise exception.NovaException(
|
||||||
_("libguestfs installed but not usable (%s)") % e)
|
_("libguestfs installed but not usable (%s)") % e)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue