def main(args):
    # delete rekall's BasicConfig
    # we want to configure the root logger
    for handler in logging.root.handlers[:]:
        logging.root.removeHandler(handler)
    debug = args['--debug']
    # configure root logger
    log_level = logging.INFO
    if debug:
        log_level = logging.DEBUG
    logging.basicConfig(level=log_level)
    logging.debug(args)

    domain_name = args['<domain>']
    uri = args['--uri']
    old_format = args['--old']
    url = args['<url>']


    config = None
    if not url:
        # take temporary memory dump
        # we need to create our own tmp_dir
        # otherwise the dumpfile will be owned by libvirt
        # and we don't have the permission to remove it in /tmp
        with TemporaryDirectory() as tmp_dir:
            with NamedTemporaryFile(dir=tmp_dir) as ram_dump:
                # chmod to be r/w by everyone
                # before libvirt takes ownership
                os.chmod(ram_dump.name,
                         stat.S_IRUSR | stat.S_IWUSR |
                         stat.S_IRGRP | stat.S_IWGRP |
                         stat.S_IROTH | stat.S_IWOTH)
                con = libvirt.open(uri)
                domain = con.lookupByName(domain_name)
                # take dump
                logging.info('Dumping %s physical memory to %s', domain.name(),
                             ram_dump.name)
                flags = libvirt.VIR_DUMP_MEMORY_ONLY
                dumpformat = libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW
                domain.coreDumpWithFormat(ram_dump.name, dumpformat, flags)
                ram_dump.flush()
                # extract offsets
                config = extract_offsets(domain.name(), ram_dump.name)

    else:
        config = extract_offsets(domain_name, url)
    formatted_config = format_config(domain_name, config, old_format)
    logging.info(formatted_config)