def METHOD_NAME(vm, vm_name):
    """
    Check the guest agent state from guest xml
    :param vm: The vm to be checked
    :param vm_name: The vm's name
    :return: the guest agent state
    """
    # The session is just to make sure the guest
    # is fully boot up
    vm.wait_for_login().close()
    cur_xml = vm_xml.VMXML.new_from_dumpxml(vm_name)
    channels = cur_xml.get_agent_channels()
    for channel in channels:
        state = channel.find('./target').get('state')
    logging.debug("The guest agent state is %s", state)
    agent_status = state == "connected"
    return agent_status