Exemplo n.º 1
0
 def __init__(self, out_dir, target_cpu):
     self._out_dir = out_dir
     self._started = False
     self._dry_run = False
     self._target_cpu = target_cpu
     self._command_runner = None
     self._ffx_path = os.path.join(common.SDK_ROOT, 'tools',
                                   common.GetHostArchFromPlatform(), 'ffx')
Exemplo n.º 2
0
 def __init__(self, out_dir, target_cpu, logs_dir):
     self._out_dir = out_dir
     self._target_cpu = target_cpu
     self._command_runner = None
     self._symbolizer_proc = None
     self._log_listener_proc = None
     self._dry_run = False
     self._started = False
     self._ffx_path = os.path.join(common.SDK_ROOT, 'tools',
                                   common.GetHostArchFromPlatform(), 'ffx')
     self._log_manager = LogManager(logs_dir)
Exemplo n.º 3
0
def _EnsureBlobstoreQcowAndReturnPath(output_dir, target_arch):
    """Returns a file containing the Fuchsia blobstore in a QCOW format,
  with extra buffer space added for growth."""

    qimg_tool = os.path.join(common.GetEmuRootForPlatform('qemu'), 'bin',
                             'qemu-img')
    fvm_tool = common.GetHostToolPathFromPlatform('fvm')
    blobstore_path = boot_data.GetTargetFile('storage-full.blk', target_arch,
                                             'qemu')
    qcow_path = os.path.join(output_dir, 'gen', 'blobstore.qcow')

    # Check a hash of the blobstore to determine if we can re-use an existing
    # extended version of it.
    blobstore_hash_path = os.path.join(output_dir, 'gen', 'blobstore.hash')
    current_blobstore_hash = _ComputeFileHash(blobstore_path)

    if os.path.exists(blobstore_hash_path) and os.path.exists(qcow_path):
        if current_blobstore_hash == open(blobstore_hash_path, 'r').read():
            return qcow_path

    # Add some extra room for growth to the Blobstore volume.
    # Fuchsia is unable to automatically extend FVM volumes at runtime so the
    # volume enlargement must be performed prior to QEMU startup.

    # The 'fvm' tool only supports extending volumes in-place, so make a
    # temporary copy of 'blobstore.bin' before it's mutated.
    extended_blobstore = tempfile.NamedTemporaryFile()
    shutil.copyfile(blobstore_path, extended_blobstore.name)
    subprocess.check_call([
        fvm_tool, extended_blobstore.name, 'extend', '--length',
        str(EXTENDED_BLOBSTORE_SIZE), blobstore_path
    ])

    # Construct a QCOW image from the extended, temporary FVM volume.
    # The result will be retained in the build output directory for re-use.
    qemu_img_cmd = [
        qimg_tool, 'convert', '-f', 'raw', '-O', 'qcow2', '-c',
        extended_blobstore.name, qcow_path
    ]
    # TODO(crbug.com/1046861): Remove arm64 call with retries when bug is fixed.
    if common.GetHostArchFromPlatform() == 'arm64':
        qemu_image.ExecQemuImgWithRetry(qemu_img_cmd)
    else:
        subprocess.check_call(qemu_img_cmd)

    # Write out a hash of the original blobstore file, so that subsequent runs
    # can trivially check if a cached extended FVM volume is available for reuse.
    with open(blobstore_hash_path, 'w') as blobstore_hash_file:
        blobstore_hash_file.write(current_blobstore_hash)

    return qcow_path
Exemplo n.º 4
0
def get_ffx_path():
    """Returns the full path to `ffx`."""
    return os.path.join(common.SDK_ROOT, 'tools',
                        common.GetHostArchFromPlatform(), 'ffx')