diff --git a/XenAdmin/Dialogs/AddVGPUDialog.cs b/XenAdmin/Dialogs/AddVGPUDialog.cs index d001ccd09..1d2b30772 100644 --- a/XenAdmin/Dialogs/AddVGPUDialog.cs +++ b/XenAdmin/Dialogs/AddVGPUDialog.cs @@ -68,29 +68,26 @@ namespace XenAdmin.Dialogs var enabledTypes = _vm.Connection.ResolveAll(gpu_group.enabled_VGPU_types); var allTypes = _vm.Connection.ResolveAll(gpu_group.supported_VGPU_types); var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref)); - - allTypes.Sort(); - allTypes.Reverse(); - - var commonTypes = new List(); - commonTypes.AddRange(allTypes); + HashSet commonTypesSet = new HashSet(allTypes); foreach (var eVgpu in existingVGpus) { var etype = _vm.Connection.Resolve(eVgpu.type); - foreach (var vgpuType in allTypes) - { - if (!etype.compatible_types_in_vm.Contains(vgpuType.model_name)) - commonTypes.Remove(vgpuType); - } + List> existing_compatible_types_in_vm_refs = etype.compatible_types_in_vm; + List existing_compatible_types_in_vm = _vm.Connection.ResolveAll(existing_compatible_types_in_vm_refs); + HashSet existing_compatible_types_set = new HashSet(existing_compatible_types_in_vm); + commonTypesSet.IntersectWith(existing_compatible_types_set); } + var commonTypes = new List(commonTypesSet); + commonTypes.Sort(); + commonTypes.Reverse(); + if (gpu_group.HasVGpu() && commonTypes.Count > 0) comboBoxTypes.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray())); // Group item foreach (var vgpuType in commonTypes) comboBoxTypes.Items.Add(new GpuTuple(gpu_group, vgpuType, disabledTypes.ToArray())); // GPU_type item - } } } diff --git a/XenAdmin/SettingsPanels/GpuEditPage.cs b/XenAdmin/SettingsPanels/GpuEditPage.cs index ed2a84bf3..eec46263f 100644 --- a/XenAdmin/SettingsPanels/GpuEditPage.cs +++ b/XenAdmin/SettingsPanels/GpuEditPage.cs @@ -254,7 +254,7 @@ namespace XenAdmin.SettingsPanels return; } - var multipleVgpuSupport = vGpus.All(v => { var x = Connection.Resolve(v.type); return x != null && x.compatible_types_in_vm.Length > 0; }); + var multipleVgpuSupport = vGpus.All(v => { var x = Connection.Resolve(v.type); return x != null && x.compatible_types_in_vm.Count > 0; }); addButton.Enabled = multipleVgpuSupport; deleteButton.Enabled = gpuGrid.SelectedRows.Count > 0; diff --git a/XenModel/Actions/VM/GpuAssignAction.cs b/XenModel/Actions/VM/GpuAssignAction.cs index 63c634b99..2145e34ce 100644 --- a/XenModel/Actions/VM/GpuAssignAction.cs +++ b/XenModel/Actions/VM/GpuAssignAction.cs @@ -61,20 +61,19 @@ namespace XenAdmin.Actions return; // Add the new VGPUs - int index = 0; foreach (var vGpu in vGpus) { - AddGpu(vm.Connection.Resolve(vGpu.GPU_group), vm.Connection.Resolve(vGpu.type), index + 11); - index++; + // leave device=0, see PR-1060 + // in XAPI, a new value will be generated + AddGpu(vm.Connection.Resolve(vGpu.GPU_group), vm.Connection.Resolve(vGpu.type)); } } - private void AddGpu(GPU_group gpuGroup, VGPU_type vGpuType, int device) + private void AddGpu(GPU_group gpuGroup, VGPU_type vGpuType, int device = 0) { if (gpuGroup == null) return; - //string device = "0"; // fixed at the moment, see PR-1060 Dictionary other_config = new Dictionary(); if (Helpers.FeatureForbidden(vm, Host.RestrictVgpu) || vGpuType == null) diff --git a/XenModel/XenAPI/FriendlyErrorNames.resx b/XenModel/XenAPI/FriendlyErrorNames.resx index dc7f5649a..4fecc21af 100755 --- a/XenModel/XenAPI/FriendlyErrorNames.resx +++ b/XenModel/XenAPI/FriendlyErrorNames.resx @@ -1958,6 +1958,9 @@ Authorized Roles: {1} The VGPU is not compatible with any PGPU in the destination. + + You try to create a VGPU that is not compatible with existing types on the VM. + The VM cannot start because all GPUs are fully used or are running other types of virtual GPU @@ -2138,6 +2141,9 @@ Authorized Roles: {1} You attempted an operation on a VM which requires a more recent version of the PV drivers. Please upgrade your PV drivers. + + The VM does not have any free PCI slots + VM PV drivers still in use diff --git a/XenModel/XenAPI/JsonRpcClient.cs b/XenModel/XenAPI/JsonRpcClient.cs index aa262e862..da0158e11 100755 --- a/XenModel/XenAPI/JsonRpcClient.cs +++ b/XenModel/XenAPI/JsonRpcClient.cs @@ -12871,13 +12871,6 @@ namespace XenAPI return Rpc("VGPU_type.get_max_heads", new JArray(session, _vgpu_type ?? ""), serializer); } - public long vgpu_type_get_multi_vgpu_supported(string session, string _vgpu_type) - { - var converters = new List {}; - var serializer = CreateSerializer(converters); - return Rpc("VGPU_type.get_multi_vgpu_supported", new JArray(session, _vgpu_type ?? ""), serializer); - } - public long vgpu_type_get_max_resolution_x(string session, string _vgpu_type) { var converters = new List {}; @@ -12948,18 +12941,11 @@ namespace XenAPI return Rpc("VGPU_type.get_experimental", new JArray(session, _vgpu_type ?? ""), serializer); } - public string[] vgpu_type_get_compatible_types_in_vm(string session, string _vgpu_type) + public List> vgpu_type_get_compatible_types_in_vm(string session, string _vgpu_type) { - var converters = new List {}; + var converters = new List {new XenRefListConverter()}; var serializer = CreateSerializer(converters); - return Rpc("VGPU_type.get_compatible_types_in_vm", new JArray(session, _vgpu_type ?? ""), serializer); - } - - public string[] vgpu_type_get_compatible_types_on_pgpu(string session, string _vgpu_type) - { - var converters = new List {}; - var serializer = CreateSerializer(converters); - return Rpc("VGPU_type.get_compatible_types_on_pgpu", new JArray(session, _vgpu_type ?? ""), serializer); + return Rpc>>("VGPU_type.get_compatible_types_in_vm", new JArray(session, _vgpu_type ?? ""), serializer); } public List> vgpu_type_get_all(string session) diff --git a/XenModel/XenAPI/Proxy.cs b/XenModel/XenAPI/Proxy.cs index 6e054997d..6f6046a47 100755 --- a/XenModel/XenAPI/Proxy.cs +++ b/XenModel/XenAPI/Proxy.cs @@ -7376,10 +7376,6 @@ namespace XenAPI Response vgpu_type_get_max_heads(string session, string _vgpu_type); - [XmlRpcMethod("VGPU_type.get_multi_vgpu_supported")] - Response - vgpu_type_get_multi_vgpu_supported(string session, string _vgpu_type); - [XmlRpcMethod("VGPU_type.get_max_resolution_x")] Response vgpu_type_get_max_resolution_x(string session, string _vgpu_type); @@ -7424,10 +7420,6 @@ namespace XenAPI Response vgpu_type_get_compatible_types_in_vm(string session, string _vgpu_type); - [XmlRpcMethod("VGPU_type.get_compatible_types_on_pgpu")] - Response - vgpu_type_get_compatible_types_on_pgpu(string session, string _vgpu_type); - [XmlRpcMethod("VGPU_type.get_all")] Response vgpu_type_get_all(string session); @@ -9172,7 +9164,6 @@ namespace XenAPI public string model_name; public string framebuffer_size; public string max_heads; - public string multi_vgpu_supported; public string max_resolution_x; public string max_resolution_y; public string [] supported_on_PGPUs; @@ -9184,7 +9175,6 @@ namespace XenAPI public string identifier; public bool experimental; public string [] compatible_types_in_vm; - public string [] compatible_types_on_pgpu; } [XmlRpcMissingMapping(MappingAction.Ignore)] diff --git a/XenModel/XenAPI/VGPU_type.cs b/XenModel/XenAPI/VGPU_type.cs index 4a6c64d76..210f5befc 100644 --- a/XenModel/XenAPI/VGPU_type.cs +++ b/XenModel/XenAPI/VGPU_type.cs @@ -54,7 +54,6 @@ namespace XenAPI string model_name, long framebuffer_size, long max_heads, - long multi_vgpu_supported, long max_resolution_x, long max_resolution_y, List> supported_on_PGPUs, @@ -65,15 +64,13 @@ namespace XenAPI vgpu_type_implementation implementation, string identifier, bool experimental, - string[] compatible_types_in_vm, - string[] compatible_types_on_pgpu) + List> compatible_types_in_vm) { this.uuid = uuid; this.vendor_name = vendor_name; this.model_name = model_name; this.framebuffer_size = framebuffer_size; this.max_heads = max_heads; - this.multi_vgpu_supported = multi_vgpu_supported; this.max_resolution_x = max_resolution_x; this.max_resolution_y = max_resolution_y; this.supported_on_PGPUs = supported_on_PGPUs; @@ -85,7 +82,6 @@ namespace XenAPI this.identifier = identifier; this.experimental = experimental; this.compatible_types_in_vm = compatible_types_in_vm; - this.compatible_types_on_pgpu = compatible_types_on_pgpu; } /// @@ -108,7 +104,6 @@ namespace XenAPI model_name = update.model_name; framebuffer_size = update.framebuffer_size; max_heads = update.max_heads; - multi_vgpu_supported = update.multi_vgpu_supported; max_resolution_x = update.max_resolution_x; max_resolution_y = update.max_resolution_y; supported_on_PGPUs = update.supported_on_PGPUs; @@ -120,7 +115,6 @@ namespace XenAPI identifier = update.identifier; experimental = update.experimental; compatible_types_in_vm = update.compatible_types_in_vm; - compatible_types_on_pgpu = update.compatible_types_on_pgpu; } internal void UpdateFromProxy(Proxy_VGPU_type proxy) @@ -130,7 +124,6 @@ namespace XenAPI model_name = proxy.model_name == null ? null : proxy.model_name; framebuffer_size = proxy.framebuffer_size == null ? 0 : long.Parse(proxy.framebuffer_size); max_heads = proxy.max_heads == null ? 0 : long.Parse(proxy.max_heads); - multi_vgpu_supported = proxy.multi_vgpu_supported == null ? 0 : long.Parse(proxy.multi_vgpu_supported); max_resolution_x = proxy.max_resolution_x == null ? 0 : long.Parse(proxy.max_resolution_x); max_resolution_y = proxy.max_resolution_y == null ? 0 : long.Parse(proxy.max_resolution_y); supported_on_PGPUs = proxy.supported_on_PGPUs == null ? null : XenRef.Create(proxy.supported_on_PGPUs); @@ -141,8 +134,7 @@ namespace XenAPI implementation = proxy.implementation == null ? (vgpu_type_implementation) 0 : (vgpu_type_implementation)Helper.EnumParseDefault(typeof(vgpu_type_implementation), (string)proxy.implementation); identifier = proxy.identifier == null ? null : proxy.identifier; experimental = (bool)proxy.experimental; - compatible_types_in_vm = proxy.compatible_types_in_vm == null ? new string[] {} : (string [])proxy.compatible_types_in_vm; - compatible_types_on_pgpu = proxy.compatible_types_on_pgpu == null ? new string[] {} : (string [])proxy.compatible_types_on_pgpu; + compatible_types_in_vm = proxy.compatible_types_in_vm == null ? null : XenRef.Create(proxy.compatible_types_in_vm); } public Proxy_VGPU_type ToProxy() @@ -153,7 +145,6 @@ namespace XenAPI result_.model_name = model_name ?? ""; result_.framebuffer_size = framebuffer_size.ToString(); result_.max_heads = max_heads.ToString(); - result_.multi_vgpu_supported = multi_vgpu_supported.ToString(); result_.max_resolution_x = max_resolution_x.ToString(); result_.max_resolution_y = max_resolution_y.ToString(); result_.supported_on_PGPUs = supported_on_PGPUs == null ? new string[] {} : Helper.RefListToStringArray(supported_on_PGPUs); @@ -164,8 +155,7 @@ namespace XenAPI result_.implementation = vgpu_type_implementation_helper.ToString(implementation); result_.identifier = identifier ?? ""; result_.experimental = experimental; - result_.compatible_types_in_vm = compatible_types_in_vm; - result_.compatible_types_on_pgpu = compatible_types_on_pgpu; + result_.compatible_types_in_vm = compatible_types_in_vm == null ? new string[] {} : Helper.RefListToStringArray(compatible_types_in_vm); return result_; } @@ -198,8 +188,6 @@ namespace XenAPI framebuffer_size = Marshalling.ParseLong(table, "framebuffer_size"); if (table.ContainsKey("max_heads")) max_heads = Marshalling.ParseLong(table, "max_heads"); - if (table.ContainsKey("multi_vgpu_supported")) - multi_vgpu_supported = Marshalling.ParseLong(table, "multi_vgpu_supported"); if (table.ContainsKey("max_resolution_x")) max_resolution_x = Marshalling.ParseLong(table, "max_resolution_x"); if (table.ContainsKey("max_resolution_y")) @@ -221,9 +209,7 @@ namespace XenAPI if (table.ContainsKey("experimental")) experimental = Marshalling.ParseBool(table, "experimental"); if (table.ContainsKey("compatible_types_in_vm")) - compatible_types_in_vm = Marshalling.ParseStringArray(table, "compatible_types_in_vm"); - if (table.ContainsKey("compatible_types_on_pgpu")) - compatible_types_on_pgpu = Marshalling.ParseStringArray(table, "compatible_types_on_pgpu"); + compatible_types_in_vm = Marshalling.ParseSetRef(table, "compatible_types_in_vm"); } public bool DeepEquals(VGPU_type other) @@ -238,7 +224,6 @@ namespace XenAPI Helper.AreEqual2(this._model_name, other._model_name) && Helper.AreEqual2(this._framebuffer_size, other._framebuffer_size) && Helper.AreEqual2(this._max_heads, other._max_heads) && - Helper.AreEqual2(this._multi_vgpu_supported, other._multi_vgpu_supported) && Helper.AreEqual2(this._max_resolution_x, other._max_resolution_x) && Helper.AreEqual2(this._max_resolution_y, other._max_resolution_y) && Helper.AreEqual2(this._supported_on_PGPUs, other._supported_on_PGPUs) && @@ -249,8 +234,7 @@ namespace XenAPI Helper.AreEqual2(this._implementation, other._implementation) && Helper.AreEqual2(this._identifier, other._identifier) && Helper.AreEqual2(this._experimental, other._experimental) && - Helper.AreEqual2(this._compatible_types_in_vm, other._compatible_types_in_vm) && - Helper.AreEqual2(this._compatible_types_on_pgpu, other._compatible_types_on_pgpu); + Helper.AreEqual2(this._compatible_types_in_vm, other._compatible_types_in_vm); } internal static List ProxyArrayToObjectList(Proxy_VGPU_type[] input) @@ -372,20 +356,6 @@ namespace XenAPI return long.Parse(session.proxy.vgpu_type_get_max_heads(session.opaque_ref, _vgpu_type ?? "").parse()); } - /// - /// Get the multi_vgpu_supported field of the given VGPU_type. - /// First published in XenServer 6.2 SP1 Tech-Preview. - /// - /// The session - /// The opaque_ref of the given vgpu_type - public static long get_multi_vgpu_supported(Session session, string _vgpu_type) - { - if (session.JsonRpcClient != null) - return session.JsonRpcClient.vgpu_type_get_multi_vgpu_supported(session.opaque_ref, _vgpu_type); - else - return long.Parse(session.proxy.vgpu_type_get_multi_vgpu_supported(session.opaque_ref, _vgpu_type ?? "").parse()); - } - /// /// Get the max_resolution_x field of the given VGPU_type. /// First published in XenServer 6.2 SP1. @@ -528,30 +498,16 @@ namespace XenAPI /// /// Get the compatible_types_in_vm field of the given VGPU_type. - /// First published in XenServer 6.2 SP1 Tech-Preview. + /// First published in Unreleased. /// /// The session /// The opaque_ref of the given vgpu_type - public static string[] get_compatible_types_in_vm(Session session, string _vgpu_type) + public static List> get_compatible_types_in_vm(Session session, string _vgpu_type) { if (session.JsonRpcClient != null) return session.JsonRpcClient.vgpu_type_get_compatible_types_in_vm(session.opaque_ref, _vgpu_type); else - return (string [])session.proxy.vgpu_type_get_compatible_types_in_vm(session.opaque_ref, _vgpu_type ?? "").parse(); - } - - /// - /// Get the compatible_types_on_pgpu field of the given VGPU_type. - /// First published in XenServer 6.2 SP1 Tech-Preview. - /// - /// The session - /// The opaque_ref of the given vgpu_type - public static string[] get_compatible_types_on_pgpu(Session session, string _vgpu_type) - { - if (session.JsonRpcClient != null) - return session.JsonRpcClient.vgpu_type_get_compatible_types_on_pgpu(session.opaque_ref, _vgpu_type); - else - return (string [])session.proxy.vgpu_type_get_compatible_types_on_pgpu(session.opaque_ref, _vgpu_type ?? "").parse(); + return XenRef.Create(session.proxy.vgpu_type_get_compatible_types_in_vm(session.opaque_ref, _vgpu_type ?? "").parse()); } /// @@ -670,24 +626,6 @@ namespace XenAPI } private long _max_heads = 0; - /// - /// Maximum number of vgpu supported by the VGPU type - /// - public virtual long multi_vgpu_supported - { - get { return _multi_vgpu_supported; } - set - { - if (!Helper.AreEqual(value, _multi_vgpu_supported)) - { - _multi_vgpu_supported = value; - Changed = true; - NotifyPropertyChanged("multi_vgpu_supported"); - } - } - } - private long _multi_vgpu_supported = 0; - /// /// Maximum resolution (width) supported by the VGPU type /// First published in XenServer 6.2 SP1. @@ -882,9 +820,11 @@ namespace XenAPI private bool _experimental = false; /// - /// List of vgpu types that can start on one VM + /// List of VGPU types which are compatible in one VM + /// First published in Unreleased. /// - public virtual string[] compatible_types_in_vm + [JsonConverter(typeof(XenRefListConverter))] + public virtual List> compatible_types_in_vm { get { return _compatible_types_in_vm; } set @@ -897,24 +837,6 @@ namespace XenAPI } } } - private string[] _compatible_types_in_vm = {}; - - /// - /// List of vgpu types that compatible on one PGPU - /// - public virtual string[] compatible_types_on_pgpu - { - get { return _compatible_types_on_pgpu; } - set - { - if (!Helper.AreEqual(value, _compatible_types_on_pgpu)) - { - _compatible_types_on_pgpu = value; - Changed = true; - NotifyPropertyChanged("compatible_types_on_pgpu"); - } - } - } - private string[] _compatible_types_on_pgpu = {}; + private List> _compatible_types_in_vm = new List>() {}; } }