clalancette / oz

Automated installation for guest images
GNU Lesser General Public License v2.1
310 stars 129 forks source link

oz-install holding lock the ISO File causes qemu-img create to fail #256

Open prestonr83 opened 6 years ago

prestonr83 commented 6 years ago

Not sure where in the call stack but some where its holding a lock on the ISO File that is downloaded. I see no mention of this anywhere so maybe this is a bug related to Ubuntu 17.10.

Anyway I could not get it build. Every time I tried to call it would get following error.

libguestfs: trace: disk_create "/tmp/libguestfsX4o2P9/overlay1" "qcow2" -1 "backingfile:/tmp/iso/isos/Windows2016x86_64-iso.iso" "backingformat:raw"
libguestfs: command: run: qemu-img
libguestfs: command: run: \ create
libguestfs: command: run: \ -f qcow2
libguestfs: command: run: \ -o backing_file=/tmp/iso/isos/Windows2016x86_64-iso.iso,backing_fmt=raw
libguestfs: command: run: \ /tmp/libguestfsX4o2P9/overlay1
qemu-img: /tmp/libguestfsX4o2P9/overlay1: Failed to lock byte 100
Could not open backing image to determine size.
libguestfs: trace: disk_create = -1 (error)
libguestfs: trace: add_drive = -1 (error)
RuntimeError: 'qemu-img: /tmp/libguestfsX4o2P9/overlay1: qemu-img exited with error status 1, see debug messages above'

However I could manually run and it would complete without issue.

import guestfs
img = "/tmp/iso/isos/Windows2016x86_64-iso.iso"
gfs = guestfs.GuestFS()
gfs.add_drive_opts(img, readonly=1, format='raw')

Running lsof just prior to gfs.add_drive_opts being executed in Guest.py shows the iso open by oz-install.

As a workaround I simply added the following to Guest.py

self.log.info("Setting up guestfs handle for %s", self.tdl.name)
 fd = os.open(self.orig_iso, os.O_RDWR)
os.close ( fd )
gfs = guestfs.GuestFS()
apconole commented 6 years ago

Ran into the same issue on Fedora 27, and I applied the workaround described to get passed the issue. I don't think it's the correct solution, but I'm interested in seeing this resolved.