CA-121671: Tighten up PGPU.set_enabled_VGPU_types

The PGPU.remove_enabled_VGPU_types API checked if there were any VMs running of
that type before disabling the type. However, the set_enabled_VGPU_types call
(which may disable some types) made no such check.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
Correct field name in assert_no_resident_VGPUs_of_type

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
Add "managed" field to PIF and param to PIF.introduce

Indicates whether the interface is managed by xapi. If it is not, then xapi
will not configure the interface, the commands
PIF.plug/unplug/reconfigure_ip(v6) can not be used, nor can the interface be
bonded or have VLANs based on top through xapi.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Only attempt to bring up managed PIFs at start of day
Enforce that only managed PIFs can be plugged, unplugged, and reconfigured

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Enforce that only managed PIFs can be bonded or have VLANs/tunnels

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Don't attempt to bring down an unmanaged PIF when forgetting it

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
When attaching a network, only configure managed PIFs

This change means that PIFs that are not managed by xapi can still be used by
VMs, and as management interface, but xapi will assume that they have already
been configured. This means that the interface must be up, it must have a
bridge (with a name matching the related network.bridge field), and it must
have IP configuration (in case of the management interface).

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Add optional "managed" argument to "xe pif-introduce"

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Whitespace and style improvements in management_reconfigure

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Allow changing management to an unmanaged PIF

For an unmanaged PIF, the ip_configuration_mode will always be "none". We still
allow such a PIF to be the management interface, and rely on "something else"
to setup the bridge and IP address.

Also fixes assertion logic in host.management_reconfigure.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Allowing to forget the management PIF may cause trouble

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Merge pull request #1567 from robhoes/unmanaged-pif-pr1675

Unmanaged PIFs
CA-122661: Disable persistence mode before unbinding from nvidia

Signed-off-by: John Else <john.else@citrix.com>
Merge pull request #1572 from johnelse/ca-122661

CA-122661: Disable persistence mode before unbinding from nvidia
CP-122830: Fix gpumon restart after VM start

Signed-off-by: John Else <john.else@citrix.com>
Merge pull request #1573 from johnelse/ca-122830

CP-122830: Fix gpumon restart after VM start
CA-123007: Hold a mutex inside Device.PCI.unbind_from_nvidia

If multiple threads are trying to unbind different devices in parallel,
there is a chance that some of the nodes under /proc/driver/nvidia/ will
disappear after a thread has retrieved the list of nodes but before that
thread has accessed their contents.

Holding a mutex for the duration of the (find device,lock device,unbind)
sequence means this should no longer happen.

Signed-off-by: John Else <john.else@citrix.com>
Merge pull request #1574 from johnelse/ca-123007

CA-123007: Hold a mutex inside Device.PCI.unbind_from_nvidia
Merge pull request #1575 from simonjbeaumont/ca-121671

CA-121671: Tighten up PGPU.set_enabled_VGPU_types