From 573ada525b8a7384398a8d7d5f094f343555df56 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 1 May 2012 17:09:32 +0100 Subject: Add support for configuring libvirt VM clock and timers There are a number of time sources made available to guests, each of which have a number of configurable policies. This introduces config APIs for the libvirt domain XML to configure the clock time sources Change-Id: Ic5047b02b4753f20bb9a63e85130d84258df7a28 Signed-off-by: Daniel P. Berrange --- nova/tests/test_libvirt_config.py | 92 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_libvirt_config.py b/nova/tests/test_libvirt_config.py index df435690f..1e0818bd7 100644 --- a/nova/tests/test_libvirt_config.py +++ b/nova/tests/test_libvirt_config.py @@ -54,6 +54,98 @@ class LibvirtConfigTest(LibvirtConfigBaseTest): self.assertXmlEqual(xml, "bar") +class LibvirtConfigGuestTimerTest(LibvirtConfigBaseTest): + def test_config_platform(self): + obj = config.LibvirtConfigGuestTimer() + obj.track = "host" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + def test_config_pit(self): + obj = config.LibvirtConfigGuestTimer() + obj.name = "pit" + obj.tickpolicy = "discard" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + def test_config_hpet(self): + obj = config.LibvirtConfigGuestTimer() + obj.name = "hpet" + obj.present = False + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + +class LibvirtConfigGuestClockTest(LibvirtConfigBaseTest): + def test_config_utc(self): + obj = config.LibvirtConfigGuestClock() + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + def test_config_localtime(self): + obj = config.LibvirtConfigGuestClock() + obj.offset = "localtime" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + def test_config_timezone(self): + obj = config.LibvirtConfigGuestClock() + obj.offset = "timezone" + obj.timezone = "EDT" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + def test_config_variable(self): + obj = config.LibvirtConfigGuestClock() + obj.offset = "variable" + obj.adjustment = "123456" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + """) + + def test_config_timers(self): + obj = config.LibvirtConfigGuestClock() + + tmpit = config.LibvirtConfigGuestTimer() + tmpit.name = "pit" + tmpit.tickpolicy = "discard" + + tmrtc = config.LibvirtConfigGuestTimer() + tmrtc.name = "rtc" + tmrtc.tickpolicy = "merge" + + obj.add_timer(tmpit) + obj.add_timer(tmrtc) + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + + + + + """) + + class LibvirtConfigGuestDiskTest(LibvirtConfigBaseTest): def test_config_file(self): -- cgit