libvirt: check for AMD SEV only on x86-64

"kernel doesn't support AMD SEV" message on aarch64 does not make sense

Closes-bug: #1873012
Change-Id: I1ae22197dc68751938f524d823f39e5c89cec7b0
This commit is contained in:
Marcin Juszkiewicz 2020-03-23 13:08:24 +01:00 committed by Stephen Finucane
parent 16cabdd100
commit f0ffed8c7f
2 changed files with 20 additions and 0 deletions

View File

@ -1342,6 +1342,21 @@ class TestLibvirtSEVUnsupported(TestLibvirtSEV):
def test_unsupported_with_feature(self, fake_exists):
self.assertFalse(self.host.supports_amd_sev)
def test_non_x86_architecture(self):
fake_caps_xml = '''
<capabilities>
<host>
<uuid>cef19ce0-0ca2-11df-855d-b19fbce37686</uuid>
<cpu>
<arch>aarch64</arch>
</cpu>
</host>
</capabilities>'''
with mock.patch.object(fakelibvirt.virConnect, 'getCapabilities',
return_value=fake_caps_xml):
self.host._set_amd_sev_support()
self.assertFalse(self.host.supports_amd_sev)
class TestLibvirtSEVSupported(TestLibvirtSEV):
"""Libvirt driver tests for when AMD SEV support is present."""

View File

@ -51,6 +51,7 @@ import nova.conf
from nova import context as nova_context
from nova import exception
from nova.i18n import _
from nova.objects import fields
from nova import rpc
from nova import utils
from nova.virt import event as virtevent
@ -1273,6 +1274,10 @@ class Host(object):
def _set_amd_sev_support(self):
self._supports_amd_sev = False
caps = self.get_capabilities()
if caps.host.cpu.arch != fields.Architecture.X86_64:
return
if not self._kernel_supports_amd_sev():
LOG.info("kernel doesn't support AMD SEV")
self._supports_amd_sev = False