CP-5931: Add flag to enable/disable the VNC console with vGPU

Setting VM.platform:vgpu_vnc_enabled to "true" or "false" will enable or
disable copying of the vGPU's framebuffer to the VNC console. The
setting will default to enabled if the platform key is not present.

Signed-off-by: John Else <john.else@citrix.com>
Rename database fields

PGPU.capacity -> PGPU.size
VGPU_type.PGPU_footprint -> VGPU_type.size

Signed-off-by: John Else <john.else@citrix.com>
Update comments

Signed-off-by: John Else <john.else@citrix.com>
CP-5924: Add a function to help with PGPU capacity tracking

Signed-off-by: John Else <john.else@citrix.com>
CP-5924: Implement GPU_group.get_remaining_capacity

Signed-off-by: John Else <john.else@citrix.com>
CP-5924: Add GPU_group.get_remaining_capacity to CLI

Signed-off-by: John Else <john.else@citrix.com>
CP-5923: Add GPU-related helper functions to test_common.ml

Signed-off-by: John Else <john.else@citrix.com>
Implement PGPU.get_remaining_capacity

Signed-off-by: John Else <john.else@citrix.com>
Whitespace: Formatting in Xapi_vm_helpers

$ camlp4o ocaml/xapi/xapi_vm_helpers.ml -printer o | md5sum
4f52a2cd7f2290d29e818aa4edbada31  -

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
CP-5845: Modify select_host to take a host list

Modify the function in Xapi_vm_placement to take a list of hosts to choose from
rather than trying all hosts in the pool.

No behavioural change is expected after this changeset since the list being
passed in is currently the list of all hosts.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
CP-5845: Use policy when choosing VM host and pGPU

At the pool-level, hosts are split into groups of equally-optimal hosts (based
on GPU_group.allocation_algorithm). The VM placement code is then run
sequentially on each of these groups (cf. was run before on all hosts in pool).
Only when exhausing this list of lists of hosts does it fail to start the VM.

At the host-level, a pGPU is selected according to the same
allocation_algorithm. If no capacity can be found then the VM_REQUIRES_VGPU
error is raised.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
CP-5845: Use PGPU.get_remaining_capacity API call

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
CP-5923: Add some generic code for vGPU testing

Signed-off-by: John Else <john.else@citrix.com>
CP-5923: Add the test input as an argument to extract_output

Signed-off-by: John Else <john.else@citrix.com>
CP-5923: Add a couple of basic tests of get_remaining_capacity

Signed-off-by: John Else <john.else@citrix.com>
CP-5845: Fix partially applied helper function

The call_api_functions was only partially applied and so the function couldn't
be used as a comparitor for the Schwarzian transform sort.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
Don't allow changing of VGPUs for running VMs

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
Change how PGPU.set_GPU_group is called via the CLI

Instead of

  xe pgpu-set-gpu-group uuid=... gpu-group-uuid=...

a user now needs to call

  xe pgpu-param-set uuid=... gpu-group-uuid=...

for consistency with other CLI setters.

Signed-off-by: John Else <john.else@citrix.com>
Check VGPU type is supported when checking enabled

Required a re-order of function definitions.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
Allow moving last PGPU out of GPU group with VGPUs

With the new API, it is perfectly reasonably to create VGPUs on GPU groups with
no pGPUs in them since vGPU -> pGPU allocation is done at VM start time. As
such we can loosen the requirements on moving the last pGPU out of a GPU group.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>