mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-157501: Fixing inconsistent GPU dialogs in XS "Standard" when compared with "Enterprise"
Changes following code review: - Added VM.CanHaveVGpu function (at the moment just returns CanHaveGpu, but it will change in the future) - Added vGPU_type.IsPassthrough function and used it everywhere we needed to test for passthrough (max-heads==0) - Simplified code in Helpers.GpuCapability, Helpers.VGpuCapability, NewVMWizard (gpuCapability), MainWindow and GpuRow Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
parent
dbdd3cc02c
commit
a295ab0159
@ -126,7 +126,7 @@ namespace XenAdmin.Controls
|
||||
if (vgpuType != null)
|
||||
{
|
||||
IsVgpuSubitem = gpuGroup.supported_VGPU_types.Count > 1;
|
||||
IsFractionalVgpu = vgpuType.max_heads != 0;
|
||||
IsFractionalVgpu = !vgpuType.IsPassthrough;
|
||||
if (disabledVGpuTypes != null && disabledVGpuTypes.Select(t => t.opaque_ref).Contains(vgpuType.opaque_ref))
|
||||
IsNotEnabledVgpu = true;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ namespace XenAdmin.Controls.GPU
|
||||
|
||||
private void SetCells()
|
||||
{
|
||||
bool isPassThru = VGpuType.max_heads == 0;
|
||||
bool isPassThru = VGpuType.IsPassthrough;
|
||||
|
||||
nameColumn.Value = isPassThru ? Messages.VGPU_PASSTHRU_TOSTRING : VGpuType.model_name;
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace XenAdmin.Controls.GPU
|
||||
this.xenObject = xenObject;
|
||||
pGpuLabel.Text = pGpuList[0].Name;
|
||||
RepopulateAllowedTypes(pGpuList[0]);
|
||||
vGpuCapability = !Helpers.FeatureForbidden(xenObject, Host.RestrictVgpu) && pGpuList.Any(pgpu => pgpu.HasVGpu);
|
||||
vGpuCapability = !Helpers.FeatureForbidden(xenObject, Host.RestrictVgpu) && pGpuList[0].HasVGpu;
|
||||
Rebuild(pGpuList);
|
||||
SetupPage();
|
||||
}
|
||||
|
@ -1295,10 +1295,7 @@ namespace XenAdmin
|
||||
|
||||
bool isPoolOrLiveStandaloneHost = isPoolSelected || (isHostSelected && isHostLive && selectionPool == null);
|
||||
|
||||
if (!multi && !SearchMode && ((isHostSelected && isHostLive) || isPoolOrLiveStandaloneHost))
|
||||
{
|
||||
ShowTab(TabPageGPU, Helpers.ClearwaterSp1OrGreater(selectionConnection) && Helpers.GpuCapability(selectionConnection));
|
||||
}
|
||||
ShowTab(TabPageGPU, !multi && !SearchMode && ((isHostSelected && isHostLive) || isPoolOrLiveStandaloneHost) && Helpers.ClearwaterSp1OrGreater(selectionConnection) && Helpers.GpuCapability(selectionConnection));
|
||||
|
||||
pluginManager.SetSelectedXenObject(SelectionManager.Selection.FirstAsXenObject);
|
||||
|
||||
|
@ -86,8 +86,6 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
page_6b_LunPerVdi = new LunPerVdiNewVMMappingPage { Connection = xenConnection };
|
||||
pageVgpu = new GpuEditPage();
|
||||
|
||||
gpuCapability = Helpers.GpuCapability(connection);
|
||||
|
||||
#region RBAC Warning Page Checks
|
||||
if (connection.Session.IsLocalSuperuser || Helpers.GetMaster(connection).external_auth_type == Auth.AUTH_TYPE_NONE)
|
||||
{
|
||||
@ -123,7 +121,7 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
|
||||
page_RbacWarning.AddPermissionChecks(xenConnection, createCheck, affinityCheck, memCheck);
|
||||
|
||||
if (gpuCapability)
|
||||
if (Helpers.GpuCapability(connection))
|
||||
{
|
||||
var vgpuCheck = new RBACWarningPage.WizardPermissionCheck(Messages.RBAC_WARNING_VM_WIZARD_GPU);
|
||||
vgpuCheck.ApiCallsToCheck.Add("vgpu.create");
|
||||
@ -205,7 +203,6 @@ namespace XenAdmin.Wizards.NewVMWizard
|
||||
page_7_Networking.SelectedTemplate = selectedTemplate;
|
||||
|
||||
RemovePage(pageVgpu);
|
||||
// update gpuCapability to include "CanHaveGpu"
|
||||
gpuCapability = Helpers.GpuCapability(xenConnection) && selectedTemplate.CanHaveGpu;
|
||||
if (gpuCapability)
|
||||
AddAfterPage(page_5_CpuMem, pageVgpu);
|
||||
|
@ -1901,24 +1901,18 @@ namespace XenAdmin.Core
|
||||
|
||||
public static bool GpuCapability(IXenConnection connection)
|
||||
{
|
||||
if (!FeatureForbidden(connection, Host.RestrictGpu))
|
||||
{
|
||||
var pool = GetPoolOfOne(connection);
|
||||
if (pool != null)
|
||||
return pool.HasGpu;
|
||||
}
|
||||
if (FeatureForbidden(connection, Host.RestrictGpu))
|
||||
return false;
|
||||
var pool = GetPoolOfOne(connection);
|
||||
return pool != null && pool.HasGpu;
|
||||
}
|
||||
|
||||
public static bool VGpuCapability(IXenConnection connection)
|
||||
{
|
||||
if (!FeatureForbidden(connection, Host.RestrictVgpu))
|
||||
{
|
||||
var pool = GetPoolOfOne(connection);
|
||||
if (pool != null)
|
||||
return pool.HasVGpu;
|
||||
}
|
||||
if (FeatureForbidden(connection, Host.RestrictVgpu))
|
||||
return false;
|
||||
var pool = GetPoolOfOne(connection);
|
||||
return pool != null && pool.HasVGpu;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -51,7 +51,7 @@ namespace XenAPI
|
||||
get
|
||||
{
|
||||
var supportedTypes = Connection.ResolveAll(supported_VGPU_types);
|
||||
return supportedTypes.Any(supportedType => supportedType.max_heads != 0);
|
||||
return supportedTypes.Any(supportedType => !supportedType.IsPassthrough);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace XenAPI
|
||||
get
|
||||
{
|
||||
var vGPUType = Connection.Resolve(type);
|
||||
return vGPUType == null || vGPUType.max_heads == 0;
|
||||
return vGPUType == null || vGPUType.IsPassthrough;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace XenAPI
|
||||
{
|
||||
get
|
||||
{
|
||||
if (max_heads == 0)
|
||||
if (IsPassthrough)
|
||||
return Messages.VGPU_PASSTHRU_TOSTRING;
|
||||
|
||||
return string.Format(Messages.VGPU_TOSTRING, model_name, Capacity);
|
||||
@ -52,7 +52,7 @@ namespace XenAPI
|
||||
{
|
||||
get
|
||||
{
|
||||
if (max_heads == 0)
|
||||
if (IsPassthrough)
|
||||
return Messages.VGPU_PASSTHRU_TOSTRING;
|
||||
|
||||
var videoRam = framebuffer_size != 0 ? Util.SuperiorSizeString(framebuffer_size, 0): string.Empty;
|
||||
@ -105,5 +105,9 @@ namespace XenAPI
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPassthrough
|
||||
{
|
||||
get { return max_heads == 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -464,6 +464,11 @@ namespace XenAPI
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanHaveVGpu
|
||||
{
|
||||
get { return CanHaveGpu; }
|
||||
}
|
||||
|
||||
void set_other_config(string key, string value)
|
||||
{
|
||||
Dictionary<string, string> new_other_config =
|
||||
|
Loading…
Reference in New Issue
Block a user