From d407ca3c90af30b57d57d522728274a0e219ee0d Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 11 Dec 2012 16:52:26 +0000 Subject: [PATCH] Add support for libvirt domain XML config On x86 platforms the SMBIOS data tables can be customized using the XML config. For example, to populate them based on the data Or to copy the host's SMBIOS Change-Id: Ia4e6c1d9b0d66c58700ccf0f0fd97fa302aba64d Signed-off-by: Daniel P. Berrange --- nova/tests/test_libvirt_config.py | 13 +++++++++++++ nova/virt/libvirt/config.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/nova/tests/test_libvirt_config.py b/nova/tests/test_libvirt_config.py index f95d904c717c..ed01cc4fd969 100644 --- a/nova/tests/test_libvirt_config.py +++ b/nova/tests/test_libvirt_config.py @@ -303,6 +303,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): @@ -745,6 +756,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 @@ -778,6 +790,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):