2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2013-06-24 13:41:48 +02:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
2013-09-20 12:24:46 +02:00
|
|
|
|
using System.Collections.Generic;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
2013-09-18 14:06:47 +02:00
|
|
|
|
using System.Linq;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
using System.Windows.Forms;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Actions;
|
2013-09-18 14:06:47 +02:00
|
|
|
|
using XenAdmin.Controls;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
using XenAdmin.Controls.DataGridViewEx;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Core;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
using XenAdmin.Dialogs;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Properties;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.SettingsPanels
|
|
|
|
|
{
|
2013-09-20 12:24:46 +02:00
|
|
|
|
public partial class GpuEditPage : XenTabPage, IEditPage
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-09-20 12:24:46 +02:00
|
|
|
|
public VM vm;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
private List<VGPU> currentGpus = new List<VGPU>();
|
2013-09-18 14:06:47 +02:00
|
|
|
|
private GPU_group[] gpu_groups;
|
|
|
|
|
private bool gpusAvailable;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public GpuEditPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2013-11-14 12:29:41 +01:00
|
|
|
|
imgRDP.Visible = labelRDP.Visible =
|
|
|
|
|
imgNeedDriver.Visible = labelNeedDriver.Visible =
|
|
|
|
|
imgNeedGpu.Visible = labelNeedGpu.Visible =
|
|
|
|
|
imgStopVM.Visible = labelStopVM.Visible =
|
2013-11-14 12:57:28 +01:00
|
|
|
|
imgHA.Visible = labelHA.Visible =
|
2013-11-14 12:29:41 +01:00
|
|
|
|
false;
|
2013-09-20 12:24:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
public List<VGPU> VGpus
|
2013-09-20 12:24:46 +02:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
return gpuGrid.Rows.Cast<object>().Select(row => row as VGpuDetailRow)
|
|
|
|
|
.Select(vGpuRow => vGpuRow?.VGpu).Where(vGpu => vGpu != null).ToList();
|
2013-09-20 12:24:46 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-14 13:38:00 +01:00
|
|
|
|
public VM.HA_Restart_Priority SelectedPriority { private get; set; }
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#region IEditPage Members
|
|
|
|
|
|
|
|
|
|
public AsyncAction SaveSettings()
|
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
return new GpuAssignAction(vm, VGpus);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetXenObjects(IXenObject orig, IXenObject clone)
|
|
|
|
|
{
|
|
|
|
|
Trace.Assert(clone is VM); // only VMs should show this page
|
|
|
|
|
Trace.Assert(!Helpers.FeatureForbidden(clone, Host.RestrictGpu)); // If license insufficient, we show upsell page instead
|
|
|
|
|
|
|
|
|
|
vm = (VM)clone;
|
2017-09-05 03:15:38 +02:00
|
|
|
|
SelectedPriority = vm.HARestartPriority();
|
2013-09-18 14:06:47 +02:00
|
|
|
|
|
2013-09-20 12:24:46 +02:00
|
|
|
|
if (Connection == null) // on the PropertiesDialog
|
|
|
|
|
Connection = vm.Connection;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-09-20 12:24:46 +02:00
|
|
|
|
PopulatePage();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
public bool ValidToSave => true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public void ShowLocalValidationMessages()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Cleanup()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
public bool HasChanged => !VGpus.SequenceEqual(currentGpus);
|
|
|
|
|
|
2018-03-20 18:02:45 +01:00
|
|
|
|
#region IVerticalTab Members
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public string SubText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-02-11 19:38:27 +01:00
|
|
|
|
string txt = Messages.UNAVAILABLE;
|
2013-11-14 12:32:51 +01:00
|
|
|
|
|
|
|
|
|
if (gpusAvailable)
|
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
var vGpus = VGpus;
|
|
|
|
|
txt = vGpus.Count > 0 ? string.Join(",", vGpus.Select(v => v.VGpuTypeDescription())) : Messages.GPU_NONE;
|
2013-11-14 12:32:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return txt;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Image Image
|
|
|
|
|
{
|
|
|
|
|
get { return Resources._000_GetMemoryInfo_h32bit_16; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-09-20 12:24:46 +02:00
|
|
|
|
#region XenTabPage overrides
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
public override string Text => Messages.GPU;
|
2013-09-20 12:24:46 +02:00
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
public override string PageTitle => Messages.NEWVMWIZARD_VGPUPAGE_TITLE;
|
2013-09-20 12:24:46 +02:00
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
public override string HelpID => "GPU";
|
2013-09-20 12:24:46 +02:00
|
|
|
|
|
|
|
|
|
public override List<KeyValuePair<string, string>> PageSummary
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var summ = new List<KeyValuePair<string, string>>();
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
if (gpuGrid.Rows.Count > 0)
|
|
|
|
|
summ.Add(new KeyValuePair<string, string>(Messages.GPU, SubText));
|
2013-09-20 12:24:46 +02:00
|
|
|
|
|
|
|
|
|
return summ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PopulatePage()
|
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
currentGpus.Clear();
|
2013-09-20 12:24:46 +02:00
|
|
|
|
|
2019-01-31 00:00:56 +01:00
|
|
|
|
gpu_groups = Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();
|
|
|
|
|
//not showing empty groups
|
|
|
|
|
|
2013-09-20 12:24:46 +02:00
|
|
|
|
gpusAvailable = gpu_groups.Length > 0;
|
|
|
|
|
|
2013-11-14 13:38:00 +01:00
|
|
|
|
if (gpusAvailable)
|
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
PopulateGrid();
|
2013-11-14 13:38:00 +01:00
|
|
|
|
ShowHideWarnings();
|
|
|
|
|
}
|
|
|
|
|
else
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-09-20 12:24:46 +02:00
|
|
|
|
labelRubric.Text = Helpers.GetPool(Connection) == null
|
2013-09-18 14:06:47 +02:00
|
|
|
|
? Messages.GPU_RUBRIC_NO_GPUS_SERVER
|
|
|
|
|
: Messages.GPU_RUBRIC_NO_GPUS_POOL;
|
2013-11-14 13:38:00 +01:00
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
gpuGrid.Visible = addButton.Visible = deleteButton.Visible = false;
|
2013-11-14 13:38:00 +01:00
|
|
|
|
warningsTable.Visible = false;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2013-11-14 13:38:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-08 15:47:58 +01:00
|
|
|
|
public override void SelectDefaultControl()
|
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
if (addButton.CanSelect)
|
|
|
|
|
addButton.Select();
|
2016-12-08 15:47:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-14 13:38:00 +01:00
|
|
|
|
#endregion
|
2013-09-18 14:06:47 +02:00
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
private void PopulateGrid()
|
2013-11-14 13:38:00 +01:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
gpuGrid.SuspendLayout();
|
|
|
|
|
gpuGrid.Rows.Clear();
|
|
|
|
|
gpuGrid.Cursor = Cursors.WaitCursor;
|
|
|
|
|
try
|
2013-11-14 13:38:00 +01:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
foreach(var vGpuRef in vm.VGPUs)
|
2013-11-14 13:38:00 +01:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
var vgpu = Connection.Resolve(vGpuRef);
|
|
|
|
|
if (vgpu != null)
|
2013-11-14 13:38:00 +01:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
currentGpus.Add(vgpu);
|
|
|
|
|
gpuGrid.Rows.Add(new VGpuDetailRow(vgpu));
|
2013-09-18 14:06:47 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-07-10 01:14:03 +02:00
|
|
|
|
DeviceColumn.Visible = vm.VGPUs.Count > 0 && Helpers.QuebecOrGreater(Connection);
|
2019-04-15 20:47:32 +02:00
|
|
|
|
}
|
|
|
|
|
finally
|
2013-11-14 13:38:00 +01:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
gpuGrid.ResumeLayout();
|
|
|
|
|
gpuGrid.Cursor = Cursors.Default;
|
2013-11-14 13:38:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-20 12:24:46 +02:00
|
|
|
|
|
2013-11-14 13:38:00 +01:00
|
|
|
|
public void ShowHideWarnings()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (!gpusAvailable)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
var vGpus = VGpus;
|
|
|
|
|
|
2015-08-17 15:47:55 +02:00
|
|
|
|
imgExperimental.Visible = labelExperimental.Visible =
|
2019-04-15 20:47:32 +02:00
|
|
|
|
vGpus.Count > 0 && vGpus.Any(v => v.IsExperimental());
|
2015-08-17 15:47:55 +02:00
|
|
|
|
|
2013-09-20 12:24:46 +02:00
|
|
|
|
if (vm.power_state != vm_power_state.Halted)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-09-18 14:06:47 +02:00
|
|
|
|
imgRDP.Visible = labelRDP.Visible =
|
|
|
|
|
imgNeedDriver.Visible = labelNeedDriver.Visible =
|
|
|
|
|
imgNeedGpu.Visible = labelNeedGpu.Visible =
|
2013-11-14 12:57:28 +01:00
|
|
|
|
imgHA.Visible = labelHA.Visible =
|
2013-06-24 13:41:48 +02:00
|
|
|
|
false;
|
|
|
|
|
|
2013-09-18 14:06:47 +02:00
|
|
|
|
imgStopVM.Visible = labelStopVM.Visible = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
addButton.Enabled = deleteButton.Enabled = false;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-26 17:57:25 +01:00
|
|
|
|
Pool pool = Helpers.GetPool(Connection);
|
|
|
|
|
if (pool != null && pool.ha_enabled && VM.HaPriorityIsRestart(Connection, SelectedPriority))
|
2013-11-14 12:57:28 +01:00
|
|
|
|
{
|
|
|
|
|
imgRDP.Visible = labelRDP.Visible =
|
|
|
|
|
imgNeedDriver.Visible = labelNeedDriver.Visible =
|
|
|
|
|
imgNeedGpu.Visible = labelNeedGpu.Visible =
|
|
|
|
|
imgStopVM.Visible = labelStopVM.Visible =
|
|
|
|
|
false;
|
|
|
|
|
|
|
|
|
|
imgHA.Visible = labelHA.Visible = true;
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
addButton.Enabled = deleteButton.Enabled = false;
|
2013-11-14 12:57:28 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 11:24:17 +02:00
|
|
|
|
var multipleVgpuSupport = vGpus.All(v => { var x = Connection.Resolve(v.type); return x != null && x.compatible_types_in_vm.Count > 0; });
|
2019-04-25 17:22:47 +02:00
|
|
|
|
addButton.Enabled = multipleVgpuSupport;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
deleteButton.Enabled = gpuGrid.SelectedRows.Count > 0;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-04-25 17:22:47 +02:00
|
|
|
|
imgMulti.Visible = labelMulti.Visible = vGpus.Count > 0;
|
|
|
|
|
if (vGpus.Count > 0)
|
|
|
|
|
labelMulti.Text = multipleVgpuSupport ? Messages.NEWVMWIZARD_VGPUPAGE_MULTIPLE_VGPU_INFO : Messages.NEWVMWIZARD_VGPUPAGE_SINGLE_VGPU_INFO;
|
|
|
|
|
|
2013-11-14 12:57:28 +01:00
|
|
|
|
imgStopVM.Visible = labelStopVM.Visible =
|
|
|
|
|
imgHA.Visible = labelHA.Visible = false;
|
|
|
|
|
|
2013-09-18 14:06:47 +02:00
|
|
|
|
imgRDP.Visible = labelRDP.Visible =
|
2019-04-15 20:47:32 +02:00
|
|
|
|
HasChanged && currentGpus.Count == 0 &&
|
|
|
|
|
vGpus.Count > 0 && vGpus.Any(v => v.IsPassthrough());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-09-18 14:06:47 +02:00
|
|
|
|
imgNeedGpu.Visible = labelNeedGpu.Visible =
|
2019-04-15 20:47:32 +02:00
|
|
|
|
labelNeedDriver.Visible = imgNeedDriver.Visible = vGpus.Count > 0;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
private void warningsTable_SizeChanged(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
int[] columnsWidth = warningsTable.GetColumnWidths();
|
|
|
|
|
int textColumnWidth = columnsWidth.Length > 1 ? columnsWidth[1] : 1;
|
|
|
|
|
|
|
|
|
|
labelRDP.MaximumSize = labelStopVM.MaximumSize = new Size(textColumnWidth, 999);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var dialog = new AddVGPUDialog(vm, VGpus))
|
|
|
|
|
{
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var tuple = dialog.SelectedTuple;
|
|
|
|
|
if (tuple == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
VGPU_type type = tuple.VgpuTypes[0];
|
2019-07-04 11:34:57 +02:00
|
|
|
|
// Set vGPU device to null. vGPU creation will check whether a valid device is assigned
|
|
|
|
|
// to the vGPU, if not then 0 is used to declare the first availabe slot in VM
|
2019-04-15 20:47:32 +02:00
|
|
|
|
var vGpu = new VGPU();
|
2019-07-04 11:34:57 +02:00
|
|
|
|
vGpu.device = null;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
vGpu.GPU_group = new XenRef<GPU_group>(tuple.GpuGroup.opaque_ref);
|
|
|
|
|
vGpu.type = new XenRef<VGPU_type>(type.opaque_ref);
|
|
|
|
|
vGpu.Connection = vm.Connection;
|
|
|
|
|
gpuGrid.Rows.Add(new VGpuDetailRow(vGpu));
|
|
|
|
|
warningsTable.SuspendLayout();
|
|
|
|
|
ShowHideWarnings();
|
|
|
|
|
warningsTable.ResumeLayout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (gpuGrid.SelectedRows.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gpuGrid.Rows.Remove(gpuGrid.SelectedRows[0]);
|
2013-09-18 14:06:47 +02:00
|
|
|
|
warningsTable.SuspendLayout();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
ShowHideWarnings();
|
2013-09-18 14:06:47 +02:00
|
|
|
|
warningsTable.ResumeLayout();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VGpuDetailRow : DataGridViewExRow
|
|
|
|
|
{
|
|
|
|
|
private readonly DataGridViewTextBoxCell deviceColumn = new DataGridViewTextBoxCell();
|
|
|
|
|
private readonly DataGridViewTextBoxCell nameColumn = new DataGridViewTextBoxCell();
|
|
|
|
|
private readonly DataGridViewTextBoxCell vGpusPerGpuColumn = new DataGridViewTextBoxCell();
|
|
|
|
|
private readonly DataGridViewTextBoxCell maxResolutionColumn = new DataGridViewTextBoxCell();
|
|
|
|
|
private readonly DataGridViewTextBoxCell maxDisplaysColumn = new DataGridViewTextBoxCell();
|
|
|
|
|
private readonly DataGridViewTextBoxCell videoRamColumn = new DataGridViewTextBoxCell();
|
2019-07-04 11:34:57 +02:00
|
|
|
|
// Xapi reserves device numbers [0,20] for vGPU for backwards compatibility.
|
|
|
|
|
// The guest PCI bus slots lie within [11,31], hence XenCenter needs to
|
|
|
|
|
// shift the device number by 11 in order to show the actual PCI slot number used in the VM
|
|
|
|
|
private const int VGPU_PCI_SLOT_NUMBER_SHIFT = 11;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
|
|
|
|
|
public VGPU VGpu { get; }
|
|
|
|
|
|
|
|
|
|
public VGpuDetailRow(VGPU vGpu)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-04-15 20:47:32 +02:00
|
|
|
|
VGpu = vGpu;
|
2013-09-18 14:06:47 +02:00
|
|
|
|
|
2019-04-15 20:47:32 +02:00
|
|
|
|
SetCells();
|
|
|
|
|
Cells.AddRange(deviceColumn, nameColumn, vGpusPerGpuColumn, maxResolutionColumn, maxDisplaysColumn, videoRamColumn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetCells()
|
|
|
|
|
{
|
2019-07-04 11:34:57 +02:00
|
|
|
|
if (int.TryParse(VGpu.device, out var device))
|
2019-07-10 01:14:03 +02:00
|
|
|
|
deviceColumn.Value = Helpers.QuebecOrGreater(VGpu.Connection) ? device + VGPU_PCI_SLOT_NUMBER_SHIFT : device;
|
2019-04-15 20:47:32 +02:00
|
|
|
|
else
|
|
|
|
|
deviceColumn.Value = Messages.HYPHEN;
|
|
|
|
|
|
|
|
|
|
var vGpuType = VGpu.Connection.Resolve(VGpu.type);
|
|
|
|
|
var gpuGroup = VGpu.Connection.Resolve(VGpu.GPU_group);
|
|
|
|
|
|
|
|
|
|
bool isPassThru = vGpuType.IsPassthrough();
|
|
|
|
|
|
|
|
|
|
nameColumn.Value = isPassThru
|
|
|
|
|
? gpuGroup.HasVGpu() ? Messages.VGPU_PASSTHRU_TOSTRING : gpuGroup.Name()
|
|
|
|
|
: vGpuType.model_name;
|
|
|
|
|
|
|
|
|
|
if (!isPassThru)
|
|
|
|
|
vGpusPerGpuColumn.Value = vGpuType.Capacity();
|
|
|
|
|
else
|
|
|
|
|
vGpusPerGpuColumn.Value = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (!isPassThru)
|
|
|
|
|
{
|
|
|
|
|
var maxRes = vGpuType.MaxResolution();
|
|
|
|
|
maxResolutionColumn.Value = maxRes == "0x0" || String.IsNullOrEmpty(maxRes) ? "" : maxRes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isPassThru)
|
|
|
|
|
maxDisplaysColumn.Value = vGpuType.max_heads < 1 ? "" : String.Format("{0}", vGpuType.max_heads);
|
|
|
|
|
else
|
|
|
|
|
maxDisplaysColumn.Value = string.Empty;
|
|
|
|
|
|
|
|
|
|
videoRamColumn.Value = vGpuType.framebuffer_size != 0 ? Util.MemorySizeStringSuitableUnits(vGpuType.framebuffer_size, true) : string.Empty;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|