Skip to content

Commit

Permalink
Fix run.py when build/ fs does not support direct IO
Browse files Browse the repository at this point in the history
When the build/ directory is on tmpfs then 'cache=none' option makes
qemu fail with error:

    could not open disk image build/release/usr.img : Invalid argument

Using tmpfs for build/ makes a _huge_ difference in build time on some
setups.

This patch adds fallback to 'unsafe' mode when direct IO is not
supported.

Signed-off-by: Tomasz Grabiec <[email protected]>
  • Loading branch information
tgrabiec committed Oct 17, 2013
1 parent 87b8f73 commit 1989d9e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,30 @@ def set_imgargs():

args = ["setargs", "build/%s/usr.img" % opt_path, cmdargs.execute]
subprocess.call(["scripts/imgedit.py"] + args)

def is_direct_io_supported(path):
if not os.path.exists(path):
raise Exception('Path not found: ' + path)

try:
file = os.open(path, os.O_RDONLY | os.O_DIRECT)
os.close(file)
return True
except OSError, e:
if e.errno == errno.EINVAL:
return False;
raise

def start_osv_qemu():
image_file = "build/%s/usr.img" % opt_path
cache = 'none' if is_direct_io_supported(image_file) else 'unsafe'

args = [
"-vnc", ":1",
"-gdb", "tcp::1234,server,nowait",
"-m", cmdargs.memsize,
"-smp", cmdargs.vcpus,
"-drive", ("file=build/%s/usr.img,if=virtio,cache=none" % opt_path)]
"-drive", "file=%s,if=virtio,cache=%s" % (image_file, cache)]

if (cmdargs.no_shutdown):
args += ["-no-reboot", "-no-shutdown"]
Expand Down

0 comments on commit 1989d9e

Please sign in to comment.