Commit 4445d421 authored by Nikos Skalkotos's avatar Nikos Skalkotos

windows: Fix a bug in the VirtIO installation code

Make sure the guestfs VM is killed before we launch the VM that
installs the VirtIO drivers.
parent 7dfcf976
......@@ -721,6 +721,7 @@ class Windows(OSBase):
self.out.output("failed! See: `%s' for the full output" %
if i < retries - 1:
self.out.output("retrying ...", False)
raise FatalError("Connection to the Windows VM failed after %d retries"
% retries)
......@@ -866,8 +867,17 @@ class Windows(OSBase):
tmp = uuid.uuid4().hex
self.image.g.mkdir_p("%s/%s" % (self.systemroot, tmp))
self._add_cleanup('virtio', self.image.g.rm_rf,
"%s/%s" % (self.systemroot, tmp))
# This is a hack. We create a function here and pass it to
# _add_cleanup because self.image.g may change and the _add_cleanup
# will cache it which is wrong. For older versions of the guestfs
# library we recreate the g handler in enable_guestfs() and the
# program will crash if cleanup retains an older value for the
# guestfs handler.
def remove_tmp():
self.image.g.rm_rf("%s/%s" % (self.systemroot, tmp))
self._add_cleanup('virtio', remove_tmp)
for fname in os.listdir(dirname):
full_path = os.path.join(dirname, fname)
......@@ -929,13 +939,16 @@ class Windows(OSBase):
def _boot_virtio_vm(self):
"""Boot the media and install the VirtIO drivers"""
old_windows = self.check_version(6, 1) <= 0
timeout = self.sysprep_params['boot_timeout'].value
shutdown_timeout = self.sysprep_params['shutdown_timeout'].value
virtio_timeout = self.sysprep_params['virtio_timeout'].value
self.out.output("Starting Windows VM ...", False)
booted = False
if self.check_version(6, 1) <= 0:
if old_windows:
self.vm.interface = 'ide'
......@@ -961,6 +974,8 @@ class Windows(OSBase):
self.vm.stop(shutdown_timeout if booted else 1, fatal=False)
with self.mount(readonly=True, silent=True):
self.virtio_state = self.compute_virtio_state()
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