Skip to content

Commit

Permalink
scripts: make run.py behave correctly regardless where called from
Browse files Browse the repository at this point in the history
This patch tweaks run.py to make sure that it does NOT
assume it is called as './scripts/run.py' from OSv root
directory. Now it can be invoked from any place on the filesystem.

Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com>
  • Loading branch information
wkozaczuk committed Oct 23, 2019
1 parent d6787f8 commit bf4c37a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

devnull = open('/dev/null', 'w')

osv_base = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')

def stty_save():
global stty_params
p = subprocess.Popen(["stty", "-g"], stdout=subprocess.PIPE, stderr=devnull)
Expand Down Expand Up @@ -64,7 +66,7 @@ def set_imgargs(options):
execute = '--sampler=%d %s' % (int(options.sampler), execute)

options.osv_cmdline = execute
cmdline = ["scripts/imgedit.py", "setargs", options.image_file, execute]
cmdline = [os.path.join(osv_base, "scripts/imgedit.py"), "setargs", options.image_file, execute]
if options.dry_run:
print(format_args(cmdline))
else:
Expand Down Expand Up @@ -157,7 +159,7 @@ def start_osv_qemu(options):

if options.networking:
if options.vhost:
args += ["-netdev", "tap,id=hn%d,script=scripts/qemu-ifup.sh,vhost=on" % idx]
args += ["-netdev", "tap,id=hn%d,script=%s,vhost=on" % (idx, os.path.join(osv_base, "scripts/qemu-ifup.sh"))]
else:
for bridge_helper_dir in ['/usr/libexec', '/usr/lib/qemu']:
bridge_helper = bridge_helper_dir + '/qemu-bridge-helper'
Expand Down Expand Up @@ -508,8 +510,8 @@ def main(options):
help="specify virtio version: legacy, transitional or modern")
cmdargs = parser.parse_args()
cmdargs.opt_path = "debug" if cmdargs.debug else "release" if cmdargs.release else "last"
cmdargs.image_file = os.path.abspath(cmdargs.image or "build/%s/usr.img" % cmdargs.opt_path)
cmdargs.kernel_file = "build/%s/loader-stripped.elf" % cmdargs.opt_path
cmdargs.image_file = os.path.abspath(cmdargs.image or os.path.join(osv_base, "build/%s/usr.img" % cmdargs.opt_path))
cmdargs.kernel_file = os.path.join(osv_base, "build/%s/loader-stripped.elf" % cmdargs.opt_path)
if not os.path.exists(cmdargs.image_file):
raise Exception('Image file %s does not exist.' % cmdargs.image_file)
if cmdargs.cloud_init_image:
Expand Down

0 comments on commit bf4c37a

Please sign in to comment.