diff --git a/common.py b/common.py index 39c343c..6947d7f 100644 --- a/common.py +++ b/common.py @@ -1148,7 +1148,6 @@ Incompatible archs are skipped. # Image if env['baremetal'] is not None: - env['disk_image'] = None env['image'] = self.resolve_baremetal_executable(env['baremetal']) source_path_noext = os.path.splitext(join( env['root_dir'], @@ -1176,16 +1175,18 @@ Incompatible archs are skipped. if env['emulator'] == 'gem5': if not env['_args_given']['linux_exec']: env['image'] = env['vmlinux'] - if env['ramfs']: - env['disk_image'] = None - else: - env['disk_image'] = env['rootfs_raw_file'] else: if not env['_args_given']['linux_exec']: env['image'] = env['linux_image'] - env['disk_image'] = env['qcow2_file'] if env['_args_given']['linux_exec']: env['image'] = env['linux_exec'] + if env['emulator'] == 'gem5': + if env['ramfs']: + env['disk_image'] = None + else: + env['disk_image'] = env['rootfs_raw_file'] + else: + env['disk_image'] = env['qcow2_file'] # Android if not env['_args_given']['android_base_dir']: diff --git a/run b/run index 8692cef..606c954 100755 --- a/run +++ b/run @@ -501,6 +501,9 @@ Extra options to append at the end of the emulator command line. f.write(struct.pack('<{}'.format(self.python_struct_int_format(self.env['int_size'])), len(cli_args))) f.write(b''.join(argv_addr_data)) f.write(b'\0'.join(arg.encode() for arg in cli_args) + b'\0') + use_disk_image = self.env['disk_image'] is not None and \ + os.path.exists(self.env['disk_image']) or \ + self.env['baremetal'] is None if self.env['emulator'] == 'gem5': if self.env['quiet']: show_stdout = False @@ -569,7 +572,7 @@ Extra options to append at the end of the emulator command line. '--num-cpus', str(self.env['cpus']), LF, '--script', self.env['gem5_readfile_file'], LF, ]) - if self.env['disk_image'] is not None: + if use_disk_image: cmd.extend(['--disk-image', self.env['disk_image'], LF]) if not self.env['baremetal'] is None: cmd.extend([ @@ -646,7 +649,7 @@ Extra options to append at the end of the emulator command line. '--little-cpus', str(self.env['cpus'] // 2), LF, '--root', '/dev/vda', LF, ]) - if self.env['disk_image'] is not None: + if use_disk_image: cmd.extend(['--disk', self.env['disk_image'], LF]) if self.env['dtb']: cmd.extend([ @@ -796,7 +799,7 @@ Extra options to append at the end of the emulator command line. '-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF, '-device', 'ide-hd,drive=img-blkreplay', LF, ]) - if self.env['disk_image'] is not None: + if use_disk_image: extra_emulator_args.extend([ '-drive', 'file={},format=qcow2,if={}{}{}'.format(