Skip to content
Snippets Groups Projects
Commit 1989d9ea authored by Tomasz Grabiec's avatar Tomasz Grabiec
Browse files

Fix run.py when build/ fs does not support direct IO


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: default avatarTomasz Grabiec <tgrabiec@cloudius-systems.com>
parent 87b8f73b
No related branches found
No related tags found
No related merge requests found
......@@ -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"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment