diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-06-13 21:56:12 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-06-13 21:56:12 +0000 |
| commit | 004b97fbf16e9e2b1d7efb6cf64ce64553f7cbff (patch) | |
| tree | fb9b8abd1f574bd350176d75ce297ed63cced3b0 /nova/virt | |
| parent | 85db093bea5972ecea25474ee9081623788b8e49 (diff) | |
| parent | 573ada525b8a7384398a8d7d5f094f343555df56 (diff) | |
Merge "Add support for configuring libvirt VM clock and timers"
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt/config.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index 3f068fa05..3ebdf21f0 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -63,6 +63,63 @@ class LibvirtConfigObject(object): return xml_str +class LibvirtConfigGuestTimer(LibvirtConfigObject): + + def __init__(self, **kwargs): + super(LibvirtConfigGuestTimer, self).__init__(root_name="timer", + **kwargs) + + self.name = "platform" + self.track = None + self.tickpolicy = None + self.present = None + + def format_dom(self): + tm = super(LibvirtConfigGuestTimer, self).format_dom() + + tm.set("name", self.name) + if self.track is not None: + tm.set("track", self.track) + if self.tickpolicy is not None: + tm.set("tickpolicy", self.tickpolicy) + if self.present is not None: + if self.present: + tm.set("present", "yes") + else: + tm.set("present", "no") + + return tm + + +class LibvirtConfigGuestClock(LibvirtConfigObject): + + def __init__(self, **kwargs): + super(LibvirtConfigGuestClock, self).__init__(root_name="clock", + **kwargs) + + self.offset = "utc" + self.adjustment = None + self.timezone = None + self.timers = [] + + def format_dom(self): + clk = super(LibvirtConfigGuestClock, self).format_dom() + + clk.set("offset", self.offset) + if self.adjustment: + clk.set("adjustment", self.adjustment) + elif self.timezone: + clk.set("timezone", self.timezone) + + for tm in self.timers: + clk.append(tm.format_dom()) + + return clk + + def add_timer(self, tm): + self.timers.append(tm) + + class LibvirtConfigGuestDevice(LibvirtConfigObject): def __init__(self, **kwargs): @@ -306,6 +363,7 @@ class LibvirtConfigGuest(LibvirtConfigObject): self.memory = 1024 * 1024 * 500 self.vcpus = 1 self.acpi = False + self.clock = None self.os_type = None self.os_kernel = None self.os_initrd = None @@ -360,6 +418,10 @@ class LibvirtConfigGuest(LibvirtConfigObject): self._format_basic_props(root) self._format_os(root) self._format_features(root) + + if self.clock is not None: + root.append(self.clock.format_dom()) + self._format_devices(root) return root @@ -367,6 +429,9 @@ class LibvirtConfigGuest(LibvirtConfigObject): def add_device(self, dev): self.devices.append(dev) + def set_clock(self, clk): + self.clock = clk + class LibvirtConfigCPU(LibvirtConfigObject): |
