From f73eaaffd27aa7d6a8ec099d2c83b5bb7b62838b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Thu, 22 Nov 2018 00:00:02 +0000 Subject: [PATCH] prebuilt: automatically pick up qemu from PATH if not built like qemu-img --- build | 2 ++ common.py | 2 +- run | 12 +++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build b/build index 14c4eb4..050f3ff 100755 --- a/build +++ b/build @@ -133,6 +133,8 @@ name_to_component_map = { 'protobuf-compiler', 'python-dev', 'python-pip', + # For prebuilt qcow2 unpack. + 'qemu-utils', 'scons', 'zlib1g-dev', }, diff --git a/common.py b/common.py index 3b0f933..a591b89 100644 --- a/common.py +++ b/common.py @@ -537,7 +537,7 @@ def print_time(ellapsed_seconds): print("time {:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds))) def raw_to_qcow2(prebuilt=False, reverse=False): - if prebuilt: + if prebuilt or not os.path.exists(common.qemu_img_executable): disable_trace = [] qemu_img_executable = common.qemu_img_basename else: diff --git a/run b/run index 24c4494..1962aa6 100755 --- a/run +++ b/run @@ -249,13 +249,14 @@ def main(args, extra_args=None): raise_image_not_found() extra_emulator_args.extend(extra_qemu_args) common.make_run_dirs() - if args.prebuilt: + if args.prebuilt or not os.path.exists(common.qemu_executable): qemu_executable = common.qemu_executable_basename - qemu_found = shutil.which(qemu_executable) is not None + qemu_executable_prebuilt = True else: qemu_executable = common.qemu_executable - qemu_found = os.path.exists(qemu_executable) - if not qemu_found and not args.dry_run: + qemu_executable_prebuilt = False + qemu_executable = shutil.which(qemu_executable) + if qemu_executable is None: raise Exception('QEMU executable not found, did you forget to build or install it?\n' \ 'Tried to use: ' + qemu_executable) if args.debug_vm: @@ -296,10 +297,11 @@ def main(args, extra_args=None): '-smp', str(args.cpus), common.Newline, ] + virtfs_cmd + - qemu_user_and_system_options + serial_monitor + vnc ) + if not qemu_executable_prebuilt: + cmd.extend(qemu_user_and_system_options) if args.initrd: extra_emulator_args.extend(['-initrd', os.path.join(common.buildroot_images_dir, 'rootfs.cpio')]) rr = args.record or args.replay