code: def setvcpus(vm_, vcpus):
      '''
      Changes the amount of vcpus allocated to VM.
  
      vcpus is an int representing the number to be assigned
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' virt.setvcpus myvm 2
      '''
      with _get_xapi_session() as xapi:
          vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
          if vm_uuid is False:
              return False
          try:
              xapi.VM.set_VCPUs_number_live(vm_uuid, vcpus)
              return True
          except Exception:
              return Falsf setvcpus(vm_, vcpus):
      '''
      Changes the amount of vcpus allocated to VM.
  
      vcpus is an int representing the number to be assigned
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' virt.setvcpus myvm 2
      '''
      with _get_xapi_session() as xapi:
          vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
          if vm_uuid is False:
              return False
          try:
              xapi.VM.set_VCPUs_number_live(vm_uuid, vcpus)
              return True
          except Exception:
              return False
docs: Changes the amount of vcpus allocated to VM.
  
      vcpus is an int representing the number to be assigned
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' virt.setvcpus myvm 2