Commit 9eeecc6b authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

windows: Upload the virtio drivers to the media

Upload the virtio drivers to the media and add the drivers directory to
the DevicePath Registry key
parent 94639eba
......@@ -373,6 +373,9 @@ class Windows(OSBase):
"VirtIO drivers from. Further image customization is not "
if virtio_dir:
v_val = self.registry.reset_passwd(admin)
disabled_uac = self.registry.update_uac_remote_setting(1)
token = self._add_boot_scripts()
......@@ -615,21 +618,35 @@ class Windows(OSBase):
path = "%s/system32/drivers" % self.systemroot
drivers_path = "%s/system32/drivers" % self.systemroot
path = self.image.g.case_sensitive_path(path)
drivers_path = self.image.g.case_sensitive_path(drivers_path)
except RuntimeError as err:
raise FatalError("Unable to browse to directory: %s. Reason: %s" %
(path, str(err)))
localpath = dirname + os.sep + 'viostor.sys'
(drivers_path, str(err)))
viostor = dirname + os.sep + 'viostor.sys'
self.image.g.upload(localpath, path + '/viostor.sys')
self.image.g.upload(viostor, drivers_path + '/viostor.sys')
except RuntimeError as err:
raise FatalError("Unable to upload file %s to %s. Reason: %s" %
(localpath, path, str(err)))
(viostor, drivers_path, str(err)))
def _install_virtio_drivers(self, dirname):
"""Install the virtio drivers to the media"""
virtio_dir = self.image.g.case_sensitive_path("%s/VirtIO" %
for fname in os.listdir(dirname):
full_path = os.path.join(dirname, fname)
if os.path.isfile(full_path):
self.image.g.upload(full_path, "%s/%s" % (virtio_dir, fname))
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
......@@ -437,4 +437,34 @@ class Registry(object):
def update_devices_dirs(self, dirname, append=True):
"""Update the value of the DevicePath registry key. If the append flag
is True, the dirname is appended to the list of devices directories,
otherwise the value is overwritten.
This function returns the old value of the registry key
with self.open_hive('SOFTWARE', write=True) as hive:
current_version = hive.root()
for child in ('Microsoft', 'Windows', 'CurrentVersion'):
current_version = hive.node_get_child(current_version, child)
device_path = hive.node_get_value(current_version, 'DevicePath')
regtype, value = hive.value_value(device_path)
assert regtype == 2L, "Type (=%d) is not REG_EXPAND_SZ" % regtype
# Remove the trailing '\x00' character
old_value = value.decode('utf-16le')[:-1]
new_value = "%s;%s" % (old_value, dirname) if append else dirname
REG_EXPAND_SZ('DevicePath', new_value))
return old_value
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment