     memory: { type: 'integer', optional: true }
   }
 
+  # Current user must be an administrator.
+  @checkPermission 'admin'
+
   try
     VM = @getObject params.id
   catch

  xapi = @getXAPI VM

  # Some settings can only be changed when the VM is halted.
  if 'CPUs' of params and VM.power_state isnt 'Halted'
    @throw 'INVALID_PARAMS', 'cannot change CPUs when the VM is not halted'

  for param, field of {
    CPUs: 'VCPUs_at_startup'
    memory: 'memory_static_max'
    'name_label'
    'name_description'
  }
    continue unless param of params

    xapi.call "VM.set_#{field}", VM.ref, "#{params[param]}"

{
  each: $each
  isArray: $isArray
} = require 'underscore'

$js2xml = do ->
