Skip to content

Commit

Permalink
Merge "libvirt: check for AMD SEV only on x86-64"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Dec 6, 2020
2 parents 2dd41e9 + f0ffed8 commit 97729aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nova/tests/unit/virt/libvirt/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,21 @@ def test_unsupported_without_feature(self, fake_exists):
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."""
Expand Down
5 changes: 5 additions & 0 deletions nova/virt/libvirt/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
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
Expand Down Expand Up @@ -1273,6 +1274,10 @@ def supports_amd_sev(self):
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
Expand Down

0 comments on commit 97729aa

Please sign in to comment.