def _callbacks_cleanup(cnx, callback_ids):
    '''
    Unregister all the registered callbacks

    :param cnx: libvirt connection
    :param callback_ids: dictionary mapping a libvirt object type to an ID list
                         of callbacks to deregister
    '''
    for obj, ids in callback_ids.items():
        register_name = REGISTER_FUNCTIONS[obj]
        deregister_name = register_name.replace('Reg', 'Dereg')
        deregister = getattr(cnx, deregister_name)
        for callback_id in ids:
            deregister(callback_id)
Unregister all the registered callbacks

    :param cnx: libvirt connection
    :param callback_ids: dictionary mapping a libvirt object type to an ID list
                         of callbacks to deregister