]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/PCIEdit.js
72a355d02c8dd8471e20aadb9734368f95e7ea67
1 Ext
.define('PVE.qemu.PCIInputPanel', {
2 extend
: 'Proxmox.panel.InputPanel',
4 onlineHelp
: 'qm_pci_passthrough',
6 setVMConfig: function(vmconfig
) {
8 me
.vmconfig
= vmconfig
;
10 var hostpci
= me
.vmconfig
[me
.confid
] || '';
12 var values
= PVE
.Parser
.parsePropertyString(hostpci
, 'host');
14 if (!values
.host
.match(/^[0-9a-f]{4}:/i)) { // add optional domain
15 values
.host
= "0000:" + values
.host
;
17 if (values
.host
.length
< 11) { // 0000:00:00 format not 0000:00:00.0
19 values
.multifunction
= true;
23 values
['x-vga'] = PVE
.Parser
.parseBoolean(values
['x-vga'], 0);
24 values
.pcie
= PVE
.Parser
.parseBoolean(values
.pcie
, 0);
25 values
.rombar
= PVE
.Parser
.parseBoolean(values
.rombar
, 1);
28 if (!me
.vmconfig
.machine
|| me
.vmconfig
.machine
.indexOf('q35') === -1) {
29 // machine is not set to some variant of q35, so we disable pcie
30 var pcie
= me
.down('field[name=pcie]');
31 pcie
.setDisabled(true);
32 pcie
.setBoxLabel(gettext('Q35 only'));
36 me
.down('field[name=romfile]').setVisible(true);
40 onGetValues: function(values
) {
45 for (i
= 0; i
< 5; i
++) {
46 if (!me
.vmconfig
['hostpci' + i
.toString()]) {
47 me
.confid
= 'hostpci' + i
.toString();
52 // remove optional '0000' domain
53 if (values
.host
.substring(0,5) === '0000:') {
54 values
.host
= values
.host
.substring(5);
56 if (values
.multifunction
) {
57 // modify host to skip the '.X'
58 values
.host
= values
.host
.substring(0, values
.host
.indexOf('.'));
59 delete values
.multifunction
;
68 if (!values
.romfile
) {
69 delete values
.romfile
;
72 ret
[me
.confid
] = PVE
.Parser
.printPropertyString(values
, 'host');
76 initComponent: function() {
79 me
.nodename
= me
.pveSelNode
.data
.node
;
81 throw "no node name specified";
86 xtype
: 'pvePCISelector',
87 fieldLabel
: gettext('Device'),
89 nodename
: me
.nodename
,
91 onLoadCallBack: function(store
, records
, success
) {
92 if (!success
|| !records
.length
) {
96 if (records
.every((val
) => val
.data
.iommugroup
=== -1)) {
98 var warning
= Ext
.create('Ext.form.field.Display', {
101 value
: 'No IOMMU detected, please activate it.' +
102 'See Documentation for further information.',
105 me
.items
.insert(0, warning
);
106 me
.updateLayout(); // insert does not trigger that
110 change: function(pcisel
, value
) {
114 var pcidev
= pcisel
.getStore().getById(value
);
115 var mdevfield
= me
.down('field[name=mdev]');
116 mdevfield
.setDisabled(!pcidev
|| !pcidev
.data
.mdev
);
120 var id
= pcidev
.data
.id
.substring(0,5); // 00:00
121 var iommu
= pcidev
.data
.iommugroup
;
122 // try to find out if there are more devices
123 // in that iommu group
126 pcisel
.getStore().each(function(record
) {
127 if (record
.data
.iommugroup
=== iommu
&&
128 record
.data
.id
.substring(0,5) !== id
)
134 var warning
= me
.down('#iommuwarning');
135 if (count
&& !warning
) {
136 warning
= Ext
.create('Ext.form.field.Display', {
139 itemId
: 'iommuwarning',
140 value
: 'The selected Device is not in a seperate' +
141 'IOMMU group, make sure this is intended.',
144 me
.items
.insert(0, warning
);
145 me
.updateLayout(); // insert does not trigger that
146 } else if (!count
&& warning
) {
150 if (pcidev
.data
.mdev
) {
151 mdevfield
.setPciID(value
);
157 xtype
: 'proxmoxcheckbox',
158 fieldLabel
: gettext('All Functions'),
159 name
: 'multifunction'
165 xtype
: 'pveMDevSelector',
168 fieldLabel
: gettext('MDev Type'),
169 nodename
: me
.nodename
,
171 change: function(field
, value
) {
172 var mf
= me
.down('field[name=multifunction]');
176 mf
.setDisabled(!!value
);
181 xtype
: 'proxmoxcheckbox',
182 fieldLabel
: gettext('Primary GPU'),
187 me
.advancedColumn1
= [
189 xtype
: 'proxmoxcheckbox',
190 fieldLabel
: 'ROM-Bar',
194 xtype
: 'displayfield',
197 fieldLabel
: 'ROM-File',
202 me
.advancedColumn2
= [
204 xtype
: 'proxmoxcheckbox',
205 fieldLabel
: 'PCI-Express',
214 Ext
.define('PVE.qemu.PCIEdit', {
215 extend
: 'Proxmox.window.Edit',
221 subject
: gettext('PCI Device'),
224 initComponent : function() {
227 me
.isCreate
= !me
.confid
;
229 var ipanel
= Ext
.create('PVE.qemu.PCIInputPanel', {
231 pveSelNode
: me
.pveSelNode
241 success: function(response
) {
242 ipanel
.setVMConfig(response
.result
.data
);