Merge "libvirt: Ensure both swtpm and swtpm_setup exist for vTPM support"
This commit is contained in:
@@ -1470,13 +1470,13 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||
exc = self.assertRaises(exception.InvalidConfiguration,
|
||||
drvr.init_host, "dummyhost")
|
||||
self.assertIn(
|
||||
"vTPM support is configured but the 'swtpm' and 'swtpm_setup' "
|
||||
"binaries could not be found on PATH.",
|
||||
"vTPM support is configured but one (or all) of the 'swtpm' "
|
||||
"and 'swtpm_setup' binaries could not be found on PATH.",
|
||||
str(exc),
|
||||
)
|
||||
|
||||
mock_which.assert_has_calls(
|
||||
[mock.call('swtpm_setup'), mock.call('swtpm')],
|
||||
[mock.call('swtpm_setup')],
|
||||
)
|
||||
|
||||
@mock.patch.object(host.Host, 'has_min_version', return_value=True)
|
||||
@@ -1547,12 +1547,13 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||
correctly.
|
||||
"""
|
||||
self.flags(swtpm_enabled=True, virt_type='kvm', group='libvirt')
|
||||
mock_which.return_value = True
|
||||
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
drvr.init_host('dummyhost')
|
||||
|
||||
mock_which.assert_has_calls(
|
||||
[mock.call('swtpm_setup'), mock.call().__bool__()],
|
||||
[mock.call('swtpm_setup'), mock.call('swtpm')],
|
||||
)
|
||||
|
||||
@mock.patch.object(libvirt_driver.LOG, 'warning')
|
||||
|
@@ -1090,10 +1090,10 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
# NOTE(stephenfin): This checks using the PATH of the user running
|
||||
# nova-compute rather than the libvirtd service, meaning it's an
|
||||
# imperfect check but the best we can do
|
||||
if not any(shutil.which(cmd) for cmd in ('swtpm_setup', 'swtpm')):
|
||||
if not all(shutil.which(cmd) for cmd in ('swtpm_setup', 'swtpm')):
|
||||
msg = _(
|
||||
"vTPM support is configured but the 'swtpm' and "
|
||||
"'swtpm_setup' binaries could not be found on PATH.")
|
||||
"vTPM support is configured but one (or all) of the 'swtpm' "
|
||||
"and 'swtpm_setup' binaries could not be found on PATH.")
|
||||
raise exception.InvalidConfiguration(msg)
|
||||
|
||||
# The user and group must be valid on this host for cold migration and
|
||||
|
Reference in New Issue
Block a user