diff --git a/nova/tests/test_libvirt_config.py b/nova/tests/test_libvirt_config.py index f771d23f84d7..567c39e5026d 100644 --- a/nova/tests/test_libvirt_config.py +++ b/nova/tests/test_libvirt_config.py @@ -301,6 +301,17 @@ class LibvirtConfigGuestCPUTest(LibvirtConfigBaseTest): """) +class LibvirtConfigGuestSMBIOSTest(LibvirtConfigBaseTest): + + def test_config_simple(self): + obj = config.LibvirtConfigGuestSMBIOS() + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + class LibvirtConfigGuestSysinfoTest(LibvirtConfigBaseTest): def test_config_simple(self): @@ -743,6 +754,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest): obj.uuid = "b38a3f43-4be2-4046-897f-b67c2f5e0147" obj.os_type = "linux" obj.os_boot_dev = "hd" + obj.os_smbios = config.LibvirtConfigGuestSMBIOS() obj.acpi = True obj.apic = True @@ -776,6 +788,7 @@ class LibvirtConfigGuestTest(LibvirtConfigBaseTest): linux + diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index dcf5aeb40e66..14d940269df4 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -337,6 +337,21 @@ class LibvirtConfigGuestCPU(LibvirtConfigCPU): return cpu +class LibvirtConfigGuestSMBIOS(LibvirtConfigObject): + + def __init__(self, **kwargs): + super(LibvirtConfigGuestSMBIOS, self).__init__(root_name="smbios", + **kwargs) + + self.mode = "sysinfo" + + def format_dom(self): + smbios = super(LibvirtConfigGuestSMBIOS, self).format_dom() + smbios.set("mode", self.mode) + + return smbios + + class LibvirtConfigGuestSysinfo(LibvirtConfigObject): def __init__(self, **kwargs): @@ -678,6 +693,7 @@ class LibvirtConfigGuest(LibvirtConfigObject): self.os_root = None self.os_init_path = None self.os_boot_dev = None + self.os_smbios = None self.devices = [] def _format_basic_props(self, root): @@ -703,6 +719,8 @@ class LibvirtConfigGuest(LibvirtConfigObject): os.append(self._text_node("init", self.os_init_path)) if self.os_boot_dev is not None: os.append(etree.Element("boot", dev=self.os_boot_dev)) + if self.os_smbios is not None: + os.append(self.os_smbios.format_dom()) root.append(os) def _format_features(self, root):