Skip to content

Commit

Permalink
Windows instances require the timezone to be "localtime"
Browse files Browse the repository at this point in the history
This was relatively simple to fix, assuming that the image used
to boot the windows instance has the os_type set to "windows".
The use of os_type in this manner is consistent with the
existing use in the Xen hypervisor driver.

DocImpact: if you're booting windows instances, then you need to
set the os_type image property in glance to "windows". Otherwise
your instances will have their clock timezone set to UTC, which
has unexpected side effects in windows.

(cherry picked from commit 280a336)
(cherry picked from commit 18de647)

Conflicts:
	nova/virt/libvirt/driver.py

Note that the unit test had to be tweaked to work in the backport.
There are no functional changes however.

Change-Id: Id6759a290ed25c9add97ac61bb7d165b3fb908b2
Closes-Bug: 1231254
  • Loading branch information
mikalstill committed Oct 14, 2013
1 parent 5a09443 commit 6d3cf90
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 13 additions & 0 deletions nova/tests/test_libvirt.py
Expand Up @@ -608,6 +608,19 @@ def test_get_guest_config(self):
self.assertEquals(cfg.clock.timers[1].tickpolicy,
"catchup")

def test_get_guest_config_windows(self):
conn = libvirt_driver.LibvirtDriver(True)
instance_ref = db.instance_create(self.context, self.test_instance)
instance_ref['os_type'] = 'windows'

cfg = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1),
None, None)

self.assertEquals(type(cfg.clock),
config.LibvirtConfigGuestClock)
self.assertEquals(cfg.clock.offset, "localtime")

def test_get_guest_config_with_two_nics(self):
conn = libvirt_driver.LibvirtDriver(True)
instance_ref = db.instance_create(self.context, self.test_instance)
Expand Down
11 changes: 10 additions & 1 deletion nova/virt/libvirt/driver.py
Expand Up @@ -1801,8 +1801,17 @@ def get_guest_config(self, instance, network_info, image_meta, rescue=None,
guest.acpi = True
guest.apic = True

# NOTE(mikal): Microsoft Windows expects the clock to be in
# "localtime". If the clock is set to UTC, then you can use a
# registry key to let windows know, but Microsoft says this is
# buggy in http://support.microsoft.com/kb/2687252
clk = config.LibvirtConfigGuestClock()
clk.offset = "utc"
if instance['os_type'] == 'windows':
LOG.info(_('Configuring timezone for windows instance to '
'localtime'), instance=instance)
clk.offset = 'localtime'
else:
clk.offset = 'utc'
guest.set_clock(clk)

if FLAGS.libvirt_type == "kvm":
Expand Down

0 comments on commit 6d3cf90

Please sign in to comment.