code: def setmem(vm_, memory):
      '''
      Changes the amount of memory allocated to VM.
  
      Memory is to be specified in MB
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' virt.setmem myvm 768
      '''
      with _get_xapi_session() as xapi:
          mem_target = int(memory) * 1024 * 1024
  
          vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
          if vm_uuid is False:
              return False
          try:
              xapi.VM.set_memory_dynamic_max_live(vm_uuid, mem_target)
              xapi.VM.set_memory_dynamic_min_live(vm_uuid, mem_target)
              return True
          except Exception:
              return Falsf setmem(vm_, memory):
      '''
      Changes the amount of memory allocated to VM.
  
      Memory is to be specified in MB
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' virt.setmem myvm 768
      '''
      with _get_xapi_session() as xapi:
          mem_target = int(memory) * 1024 * 1024
  
          vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
          if vm_uuid is False:
              return False
          try:
              xapi.VM.set_memory_dynamic_max_live(vm_uuid, mem_target)
              xapi.VM.set_memory_dynamic_min_live(vm_uuid, mem_target)
              return True
          except Exception:
              return False
docs: Changes the amount of memory allocated to VM.
  
      Memory is to be specified in MB
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' virt.setmem myvm 768