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.

Change-Id: Id6759a290ed25c9add97ac61bb7d165b3fb908b2
Closes-Bug: 1231254
  • Loading branch information
mikalstill committed Sep 26, 2013
1 parent e2a3b92 commit 280a336
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions nova/tests/virt/libvirt/test_libvirt.py
Expand Up @@ -722,6 +722,21 @@ 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(fake.FakeVirtAPI(), True)
instance_ref = db.instance_create(self.context, self.test_instance)
instance_ref['os_type'] = 'windows'

disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
cfg = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1),
None, disk_info)

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

def test_get_guest_config_with_two_nics(self):
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), 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 @@ -2886,8 +2886,17 @@ def get_guest_config(self, instance, network_info, image_meta,
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 = vconfig.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 CONF.libvirt_type == "kvm":
Expand Down

0 comments on commit 280a336

Please sign in to comment.