Ejemplo n.º 1
0
tar_files = subprocess32.check_output(['tar', 'tf', project['tarfile']])
sourcedir = tar_files.splitlines()[0].split(os.path.sep)[0]
sourcedir = abspath(sourcedir)

print()
# e.g. file-5.22-true.iso
installdir = join(sourcedir, 'lava-install')
input_file_guest = join(installdir, input_file_base)
isoname = '{}-{}.iso'.format(sourcedir, input_file_base)
command_args = shlex.split(project['command'].format(
    install_dir=pipes.quote(installdir),
    input_file=input_file_guest))
shutil.copy(input_file, installdir)

create_recording(qemu_path, project['qcow'], project['snapshot'],
                 command_args, installdir, isoname,
                 project["expect_prompt"], "ide1-cd0", rr=qemu_use_rr)

try:
    os.mkdir('inputs')
except OSError as e:
    if e.errno != EEXIST:
        raise
shutil.copy(input_file, 'inputs/')

record_time = tock()
print("panda record complete %.2f seconds" % record_time)
sys.stdout.flush()

tick()
print()
Ejemplo n.º 2
0
                "wget", "http://panda.moyix.net/~moyix/" + extra_file, "-O",
                extra_file_path
            ])

    # Expand out the dot dir in extra_args if necessary
    if arch_data.extra_args:
        extra_args = arch_data.extra_args.format(**{'DOT_DIR': dot_dir})
        # And split it
        extra_args = shlex.split(extra_args)
    else:
        extra_args = []

    new_guest_cmd = map(transform_arg_copy, guest_cmd)
    exename = basename(new_guest_cmd[0])

    print "args =", guest_cmd
    print "new_guest_cmd =", new_guest_cmd
    print "env = ", env

    create_recording(join(panda_build_dir, arch_data.dir, arch_data.binary),
                     qcow,
                     args.snapshot,
                     new_guest_cmd,
                     install_dir,
                     join(binary_dir, binary_basename),
                     arch_data.prompt,
                     rr=args.rr,
                     perf=args.perf,
                     env=env,
                     extra_args=extra_args + shlex.split(args.qemu_args))
Ejemplo n.º 3
0
def run_and_create_recording():
    global install_dir
    
    parser = argparse.ArgumentParser(usage=USAGE)

    parser.add_argument("--perf", action='store_true')
    parser.add_argument("--rr", action='store_true')
    parser.add_argument("--cmd", action='store')
    parser.add_argument("--env", action='store')
    parser.add_argument("--qemu_args", action='store', default="")
    parser.add_argument("--qcow", action='store', default="")
    parser.add_argument("--snapshot", "-s", action='store', default="root")
    parser.add_argument("--arch", action='store', default='i386', choices=SUPPORTED_ARCHES.keys())
    parser.add_argument("--fileinput", action='store')
    parser.add_argument("--stdin", action='store_true')
    parser.add_argument("--replaybase", action='store')

    args, guest_cmd = parser.parse_known_args()
    if args.cmd:
        guest_cmd = shlex.split(args.cmd)

    if len(sys.argv) < 2:
        EXIT_USAGE()

    arch_data = SUPPORTED_ARCHES[args.arch]

    env = {}
    if args.env:
        try:
            env = eval(args.env)
        except:
            print("Something went wrong parsing the environment string: [{}]".format(env))
            EXIT_USAGE()

    binary = guest_cmd[0]

    if binary.startswith('guest:'): binary = binary[6:]
    binary_basename = basename(binary)

    # Directory structure:
    # + replays
    # +---+ binary1
    #     +---- cdrom
    #     +---- cdrom.iso
    binary_dir = join(os.getcwd(), 'replays', binary_basename)
    if not os.path.exists(binary_dir):
        os.makedirs(binary_dir)

    install_dir = join(binary_dir, 'cdrom')
    # if os.path.exists(install_dir):
        # shutil.rmtree(install_dir)
    if not os.path.exists(install_dir):
        os.mkdir(install_dir)

    if args.qcow:
        qcow = args.qcow
    else:
        qcow = join(dot_dir, arch_data.qcow)

    if not os.path.isfile(qcow):
        print "\nQcow %s doesn't exist. Downloading from moyix. Thanks moyix!\n" % qcow
        sp.check_call(["wget", "http://panda.moyix.net/~moyix/" + arch_data.qcow, "-O", qcow])
        for extra_file in arch_data.extra_files or []:
            extra_file_path = join(dot_dir, extra_file)
            sp.check_call(["wget", "http://panda.moyix.net/~moyix/" + extra_file, "-O", extra_file_path])

    # Expand out the dot dir in extra_args if necessary
    if arch_data.extra_args:
        extra_args = arch_data.extra_args.format(**{'DOT_DIR': dot_dir})
        # And split it
        extra_args = shlex.split(extra_args)
    else:
        extra_args = []

    new_guest_cmd = map(transform_arg_copy, guest_cmd)
    exename = basename(new_guest_cmd[0])

    print "args =", guest_cmd
    print "new_guest_cmd =", new_guest_cmd
    print "env = ", env

    if args.replaybase is None:
        replay_base = join(binary_dir, binary_basename)
    else:
        replay_base = args.replaybase

    create_recording(
        qemu_binary(arch_data),
        qcow, args.snapshot, new_guest_cmd,
        install_dir,
        replay_base,
        arch_data.prompt,
        arch_data.cdrom,
        rr=args.rr,
        perf=args.perf,
        env=env,
        extra_args=extra_args + shlex.split(args.qemu_args)
    )
    return (replay_base, arch_data, args.stdin, args.fileinput, guest_cmd)
Ejemplo n.º 4
0
                "wget", "http://panda.moyix.net/~moyix/" + extra_file, "-O",
                extra_file_path
            ])

    # Expand out the dot dir in extra_args if necessary
    if arch_data.extra_args:
        extra_args = arch_data.extra_args.format(**{'DOT_DIR': dot_dir})
        # And split it
        extra_args = shlex.split(extra_args)
    else:
        extra_args = None

    new_guest_cmd = map(transform_arg_copy, guest_cmd)
    exename = basename(new_guest_cmd[0])

    print "args =", guest_cmd
    print "new_guest_cmd =", new_guest_cmd
    print "env = ", env

    create_recording(join(panda_build_dir, arch_data.dir, arch_data.binary),
                     qcow,
                     "root",
                     new_guest_cmd,
                     install_dir,
                     join(binary_dir, binary_basename),
                     arch_data.prompt,
                     rr=args.rr,
                     perf=args.perf,
                     env=env,
                     extra_args=extra_args)
Ejemplo n.º 5
0
    if not os.path.exists(binary_dir):
        os.makedirs(binary_dir)

    install_dir = join(binary_dir, 'cdrom')
    # if os.path.exists(install_dir):
    # shutil.rmtree(install_dir)
    if not os.path.exists(install_dir):
        os.mkdir(install_dir)

    qcow = join(dot_dir, "wheezy_panda2.qcow2")
    if not os.path.isfile(qcow):
        print "\nYou need a qcow. Downloading from moyix. Thanks moyix!\n"
        sp.check_call([
            "wget", "http://panda.moyix.net/~moyix/wheezy_panda2.qcow2", "-O",
            qcow
        ])

    new_guest_cmd = map(transform_arg_copy, guest_cmd)
    exename = basename(new_guest_cmd[0])

    print "args =", guest_cmd
    print "new_guest_cmd =", new_guest_cmd

    create_recording(join(panda_build_dir, 'i386-softmmu', 'qemu-system-i386'),
                     qcow,
                     "root",
                     new_guest_cmd,
                     install_dir,
                     join(binary_dir, binary_basename),
                     env=env)
Ejemplo n.º 6
0
    # shutil.rmtree(install_dir)
    if not os.path.exists(install_dir):
        os.mkdir(install_dir)

    qcow = join(dot_dir, qcow_fname)
    if not os.path.isfile(qcow):
        print "\nYou need a qcow. Downloading from moyix. Thanks moyix!\n"
        sp.check_call([
            "wget", "http://panda.moyix.net/~moyix/" + qcow_fname, "-O", qcow
        ])

    new_guest_cmd = map(transform_arg_copy, guest_cmd)
    exename = basename(new_guest_cmd[0])

    print "args =", guest_cmd
    print "new_guest_cmd =", new_guest_cmd
    print "env = ", env

    create_recording(
        join(panda_build_dir, qemu_softmmu, qemu_binary),
        qcow,
        "root",
        new_guest_cmd,
        install_dir,
        join(binary_dir, binary_basename),
        expect_prompt,
        rr=args.rr,
        perf=args.perf,
        env=env,
    )
Ejemplo n.º 7
0
        for extra_file in arch_data.extra_files or []:
            extra_file_path = join(dot_dir, extra_file)
            sp.check_call(["wget", "http://panda.moyix.net/~moyix/" + extra_file, "-O", extra_file_path])

    # Expand out the dot dir in extra_args if necessary
    if arch_data.extra_args:
        extra_args = arch_data.extra_args.format(**{'DOT_DIR': dot_dir})
        # And split it
        extra_args = shlex.split(extra_args)
    else:
        extra_args = []

    new_guest_cmd = map(transform_arg_copy, guest_cmd)
    exename = basename(new_guest_cmd[0])

    print "args =", guest_cmd
    print "new_guest_cmd =", new_guest_cmd
    print "env = ", env
    
    create_recording(
        join(panda_build_dir, arch_data.dir, arch_data.binary),
        qcow, args.snapshot, new_guest_cmd,
        install_dir,
        join(binary_dir, binary_basename),
        arch_data.prompt,
        rr=args.rr,
        perf=args.perf,
        env=env,
        extra_args=extra_args + shlex.split(args.qemu_args)
    )