libvirt - Add log if libguestfs can't read host kernel
Host's kernel only allows a root user to have read/write permission in ubuntu. If compute-service didn't have read permission then libguestfs will launch image fail. In libguestfs offical FAQ site had point out this issue, following is the link http://libguestfs.org/guestfs-faq.1.html#binaries It had suggested users to change host's kernel permission. But this action should be handled by other patch. Here only give a hint what's going wrong. Change-Id: I36c93610831e2935d46f7ee37f95619fe6dc1481 Related-Bug: 1413142 Closes-Bug: 1491216
This commit is contained in:
@@ -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)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user