def check_domain_exists(conn, guestname, logger):
    """ check if the domain exists, may or may not be active """
    guest_names = []
    ids = conn.listDomainsID()
    for id in ids:
        obj = conn.lookupByID(id)
        guest_names.append(obj.name())
    guest_names += conn.listDefinedDomains()
    if guestname not in guest_names:
        logger.error("%s doesn't exist" % guestname)
        return False
    return True
