diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-12-20 14:02:13 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-12-20 14:02:13 +0000 |
| commit | 59206947af095cbeadde27a88a40eb4fec266948 (patch) | |
| tree | cb8561d73ff73e9473a33bbdb2d91b7a9aed6ed9 /nova | |
| parent | ae4fb9974df79e4eb3f20638a3071b409fc70a9e (diff) | |
| parent | 095759640dd48e2ea470dc160726a3a8501800a1 (diff) | |
Merge "Export custom SMBIOS info to QEMU/KVM guests"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/test_libvirt.py | 39 | ||||
| -rw-r--r-- | nova/virt/libvirt/driver.py | 24 |
2 files changed, 63 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index af8991d09..28d680f5c 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -48,6 +48,7 @@ from nova.tests import fake_network import nova.tests.image.fake from nova.tests import matchers from nova import utils +from nova import version from nova.virt.disk import api as disk from nova.virt import driver from nova.virt import fake @@ -596,6 +597,7 @@ class LibvirtConnTestCase(test.TestCase): nova.tests.image.fake.stub_out_image_service(self.stubs) self.test_instance = { + 'uuid': '32dfcb37-5af1-552b-357c-be8c3aa38310', 'memory_kb': '1024000', 'basepath': '/some/path', 'bridge_name': 'br100', @@ -1830,6 +1832,43 @@ class LibvirtConnTestCase(test.TestCase): check_list.append(check) if hypervisor_type in ['qemu', 'kvm']: + xpath = "./sysinfo/system/entry" + check = (lambda t: t.findall(xpath)[0].get("name"), + "manufacturer") + check_list.append(check) + check = (lambda t: t.findall(xpath)[0].text, + version.vendor_string()) + check_list.append(check) + + check = (lambda t: t.findall(xpath)[1].get("name"), + "product") + check_list.append(check) + check = (lambda t: t.findall(xpath)[1].text, + version.product_string()) + check_list.append(check) + + check = (lambda t: t.findall(xpath)[2].get("name"), + "version") + check_list.append(check) + check = (lambda t: t.findall(xpath)[2].text, + version.version_string_with_package()) + check_list.append(check) + + check = (lambda t: t.findall(xpath)[3].get("name"), + "serial") + check_list.append(check) + check = (lambda t: t.findall(xpath)[3].text, + "cef19ce0-0ca2-11df-855d-b19fbce37686") + check_list.append(check) + + check = (lambda t: t.findall(xpath)[4].get("name"), + "uuid") + check_list.append(check) + check = (lambda t: t.findall(xpath)[4].text, + instance['uuid']) + check_list.append(check) + + if hypervisor_type in ['qemu', 'kvm']: check = (lambda t: t.findall('./devices/serial')[0].get( 'type'), 'file') check_list.append(check) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index e8dee77e1..9c78dc57d 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -69,6 +69,7 @@ from nova.openstack.common import jsonutils from nova.openstack.common import log as logging from nova.openstack.common.notifier import api as notifier from nova import utils +from nova import version from nova.virt import configdrive from nova.virt.disk import api as disk from nova.virt import driver @@ -1517,6 +1518,11 @@ class LibvirtDriver(driver.ComputeDriver): caps.parse_str(xmlstr) return caps + def get_host_uuid(self): + """Returns a UUID representing the host""" + caps = self.get_host_capabilities() + return caps.host.uuid + def get_host_cpu_for_guest(self): """Returns an instance of config.LibvirtConfigGuestCPU representing the host's CPU model & topology with @@ -1717,6 +1723,18 @@ class LibvirtDriver(driver.ComputeDriver): return devices + def get_guest_config_sysinfo(self, instance): + sysinfo = vconfig.LibvirtConfigGuestSysinfo() + + sysinfo.system_manufacturer = version.vendor_string() + sysinfo.system_product = version.product_string() + sysinfo.system_version = version.version_string_with_package() + + sysinfo.system_serial = self.get_host_uuid() + sysinfo.system_uuid = instance['uuid'] + + return sysinfo + def get_guest_config(self, instance, network_info, image_meta, rescue=None, block_device_info=None): """Get config data for parameters. @@ -1762,6 +1780,12 @@ class LibvirtDriver(driver.ComputeDriver): if CONF.libvirt_type == "xen" and guest.os_type == vm_mode.HVM: guest.os_loader = CONF.xen_hvmloader_path + if CONF.libvirt_type in ("kvm", "qemu"): + caps = self.get_host_capabilities() + if caps.host.cpu.arch in ("i686", "x86_64"): + guest.sysinfo = self.get_guest_config_sysinfo(instance) + guest.os_smbios = vconfig.LibvirtConfigGuestSMBIOS() + if CONF.libvirt_type == "lxc": guest.os_type = vm_mode.EXE guest.os_init_path = "/sbin/init" |
