def _freemem(conn):
    '''
    Internal variant of freemem taking a libvirt connection as parameter
    '''
    mem = conn.getInfo()[1]
    # Take off just enough to sustain the hypervisor
    mem -= 256
    for dom in _get_domain(conn, iterable=True):
        if dom.ID() > 0:
            mem -= dom.info()[2] / 1024
    return mem
Internal variant of freemem taking a libvirt connection as parameter