def write_tarball_from_ivorn_xml_tuples(ivorn_xml_tuples, filepath):
    """
    Iterate over a series of ivorn / xml bstring tuples and write to bz'd tarball.

    Args:
        ivorn_xml_tuples (iterable): [(ivorn,xml)]
            An iterable (e.g. list) of tuples containing two entries -
            an ivorn string and an xml bytestring.
        filepath (string): Path to the new tarball to create. Typically of form
            '/path/to/foo.tar.bz2'
    Returns
        packet_count (int): Number of packets written to tarball
    """
    out = tarfile.open(filepath, mode='w:bz2')
    logger.info("Writing packets to tarball at " + filepath)
    packet_count = 0
    try:
        for (ivorn, xml) in ivorn_xml_tuples:
            out.addfile(*bytestring_to_tar_tuple(
                filename_from_ivorn(ivorn),
                xml
            ))
            packet_count += 1
    finally:
        out.close()
    return packet_count