Skip to content

Commit f73eaaf

Browse files
committed
prebuilt: automatically pick up qemu from PATH if not built like qemu-img
1 parent 701bf67 commit f73eaaf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ name_to_component_map = {
133133
'protobuf-compiler',
134134
'python-dev',
135135
'python-pip',
136+
# For prebuilt qcow2 unpack.
137+
'qemu-utils',
136138
'scons',
137139
'zlib1g-dev',
138140
},

common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def print_time(ellapsed_seconds):
537537
print("time {:02}:{:02}:{:02}".format(int(hours), int(minutes), int(seconds)))
538538

539539
def raw_to_qcow2(prebuilt=False, reverse=False):
540-
if prebuilt:
540+
if prebuilt or not os.path.exists(common.qemu_img_executable):
541541
disable_trace = []
542542
qemu_img_executable = common.qemu_img_basename
543543
else:

run

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,14 @@ def main(args, extra_args=None):
249249
raise_image_not_found()
250250
extra_emulator_args.extend(extra_qemu_args)
251251
common.make_run_dirs()
252-
if args.prebuilt:
252+
if args.prebuilt or not os.path.exists(common.qemu_executable):
253253
qemu_executable = common.qemu_executable_basename
254-
qemu_found = shutil.which(qemu_executable) is not None
254+
qemu_executable_prebuilt = True
255255
else:
256256
qemu_executable = common.qemu_executable
257-
qemu_found = os.path.exists(qemu_executable)
258-
if not qemu_found and not args.dry_run:
257+
qemu_executable_prebuilt = False
258+
qemu_executable = shutil.which(qemu_executable)
259+
if qemu_executable is None:
259260
raise Exception('QEMU executable not found, did you forget to build or install it?\n' \
260261
'Tried to use: ' + qemu_executable)
261262
if args.debug_vm:
@@ -296,10 +297,11 @@ def main(args, extra_args=None):
296297
'-smp', str(args.cpus), common.Newline,
297298
] +
298299
virtfs_cmd +
299-
qemu_user_and_system_options +
300300
serial_monitor +
301301
vnc
302302
)
303+
if not qemu_executable_prebuilt:
304+
cmd.extend(qemu_user_and_system_options)
303305
if args.initrd:
304306
extra_emulator_args.extend(['-initrd', os.path.join(common.buildroot_images_dir, 'rootfs.cpio')])
305307
rr = args.record or args.replay

0 commit comments

Comments
 (0)