Merge "libvirt: Add capability to load smm feature from existing xml"
This commit is contained in:
@@ -3135,6 +3135,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
self.assertEqual('fake_machine_type', obj.os_mach_type)
|
||||
self.assertEqual('/tmp/vmlinuz', obj.os_kernel)
|
||||
self.assertEqual('/usr/lib/xen/boot/hvmloader', obj.os_loader)
|
||||
self.assertNotIn(config.LibvirtConfigGuestFeatureSMM(), obj.features)
|
||||
self.assertIsNone(obj.os_loader_type)
|
||||
self.assertIsNone(obj.os_loader_readonly)
|
||||
self.assertIsNone(obj.os_loader_secure)
|
||||
@@ -3157,6 +3158,10 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
<loader readonly='yes' type='pflash'>/tmp/OVMF_CODE.fd</loader>
|
||||
<nvram template='/tmp/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/instance.fd</nvram>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<smm state='on'/>
|
||||
</features>
|
||||
</domain>
|
||||
""" # noqa: E501
|
||||
|
||||
@@ -3167,6 +3172,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
self.assertEqual('hvm', obj.os_type)
|
||||
self.assertIsNone(obj.os_mach_type)
|
||||
self.assertIsNone(obj.os_kernel)
|
||||
self.assertIn(config.LibvirtConfigGuestFeatureSMM(), obj.features)
|
||||
self.assertEqual('/tmp/OVMF_CODE.fd', obj.os_loader)
|
||||
self.assertEqual('pflash', obj.os_loader_type)
|
||||
self.assertTrue(obj.os_loader_readonly)
|
||||
@@ -3190,6 +3196,9 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
<loader readonly='yes' secure='yes' type='pflash'>/tmp/OVMF_CODE.secboot.fd</loader>
|
||||
<nvram template='/tmp/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/instance.fd</nvram>
|
||||
</os>
|
||||
<features>
|
||||
<smm/>
|
||||
</features>
|
||||
</domain>
|
||||
""" # noqa: E501
|
||||
|
||||
@@ -3200,6 +3209,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
self.assertEqual('hvm', obj.os_type)
|
||||
self.assertIsNone(obj.os_mach_type)
|
||||
self.assertIsNone(obj.os_kernel)
|
||||
self.assertIn(config.LibvirtConfigGuestFeatureSMM(), obj.features)
|
||||
self.assertEqual('/tmp/OVMF_CODE.secboot.fd', obj.os_loader)
|
||||
self.assertEqual('pflash', obj.os_loader_type)
|
||||
self.assertTrue(obj.os_loader_readonly)
|
||||
@@ -3222,6 +3232,9 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
<type>hvm</type>
|
||||
<loader readonly='yes' stateless='yes' type='pflash'>/tmp/OVMF_CODE.fd</loader>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
</features>
|
||||
</domain>
|
||||
""" # noqa: E501
|
||||
|
||||
@@ -3232,6 +3245,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest):
|
||||
self.assertEqual('hvm', obj.os_type)
|
||||
self.assertIsNone(obj.os_mach_type)
|
||||
self.assertIsNone(obj.os_kernel)
|
||||
self.assertNotIn(config.LibvirtConfigGuestFeatureSMM(), obj.features)
|
||||
self.assertEqual('/tmp/OVMF_CODE.fd', obj.os_loader)
|
||||
self.assertEqual('pflash', obj.os_loader_type)
|
||||
self.assertTrue(obj.os_loader_readonly)
|
||||
|
||||
@@ -827,8 +827,10 @@ class LibvirtConfigCPUFeature(LibvirtConfigObject):
|
||||
|
||||
return ft
|
||||
|
||||
def __eq__(self, obj):
|
||||
return obj.name == self.name
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, LibvirtConfigCPUFeature):
|
||||
return False
|
||||
return other.name == self.name
|
||||
|
||||
def __ne__(self, obj):
|
||||
return obj.name != self.name
|
||||
@@ -2907,6 +2909,11 @@ class LibvirtConfigGuestFeature(LibvirtConfigObject):
|
||||
super(LibvirtConfigGuestFeature, self).__init__(root_name=name,
|
||||
**kwargs)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, LibvirtConfigGuestFeature):
|
||||
return False
|
||||
return other.root_name == self.root_name
|
||||
|
||||
|
||||
class LibvirtConfigGuestFeatureACPI(LibvirtConfigGuestFeature):
|
||||
|
||||
@@ -2940,6 +2947,11 @@ class LibvirtConfigGuestFeatureSMM(LibvirtConfigGuestFeature):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(LibvirtConfigGuestFeatureSMM, self).__init__("smm", **kwargs)
|
||||
# NOTE(tkajinam): The smm feature also supports tseg sub-element, which
|
||||
# has not set by nova or libvirt. Using the tseg option requires
|
||||
# huge caution according to libvirt doc[1], so the option is
|
||||
# intentionally left unimplemented now.
|
||||
# [1] https://libvirt.org/formatdomain.html#hypervisor-features
|
||||
|
||||
def format_dom(self):
|
||||
root = super(LibvirtConfigGuestFeatureSMM, self).format_dom()
|
||||
@@ -3385,6 +3397,7 @@ class LibvirtConfigGuest(LibvirtConfigObject):
|
||||
def parse_dom(self, xmldoc):
|
||||
self.virt_type = xmldoc.get('type')
|
||||
# Note: This cover only for: LibvirtConfigGuestDisks
|
||||
# LibvirtConfigGuestFeatureSMM
|
||||
# LibvirtConfigGuestFilesys
|
||||
# LibvirtConfigGuestHostdevPCI
|
||||
# LibvirtConfigGuestHostdevMDEV
|
||||
@@ -3448,6 +3461,10 @@ class LibvirtConfigGuest(LibvirtConfigObject):
|
||||
self._parse_os(c)
|
||||
elif c.tag == 'iothreads':
|
||||
self.iothreads = int(c.text)
|
||||
elif c.tag == 'features':
|
||||
for f in c:
|
||||
if f.tag == 'smm' and f.get('state', 'on') == 'on':
|
||||
self.features.append(LibvirtConfigGuestFeatureSMM())
|
||||
else:
|
||||
self._parse_basic_props(c)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user