]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/PCIEdit.js
a8e05f2dde6946097cfb57541278c911f641a1d3
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
) {
128 record
.data
.iommugroup
=== iommu
&&
129 record
.data
.id
.substring(0, 5) !== id
136 var warning
= me
.down('#iommuwarning');
137 if (count
&& !warning
) {
138 warning
= Ext
.create('Ext.form.field.Display', {
141 itemId
: 'iommuwarning',
142 value
: 'The selected Device is not in a seperate' +
143 'IOMMU group, make sure this is intended.',
146 me
.items
.insert(0, warning
);
147 me
.updateLayout(); // insert does not trigger that
148 } else if (!count
&& warning
) {
152 if (pcidev
.data
.mdev
) {
153 mdevfield
.setPciID(value
);
159 xtype
: 'proxmoxcheckbox',
160 fieldLabel
: gettext('All Functions'),
161 name
: 'multifunction',
167 xtype
: 'pveMDevSelector',
170 fieldLabel
: gettext('MDev Type'),
171 nodename
: me
.nodename
,
173 change: function(field
, value
) {
174 var mf
= me
.down('field[name=multifunction]');
178 mf
.setDisabled(!!value
);
183 xtype
: 'proxmoxcheckbox',
184 fieldLabel
: gettext('Primary GPU'),
189 me
.advancedColumn1
= [
191 xtype
: 'proxmoxcheckbox',
192 fieldLabel
: 'ROM-Bar',
196 xtype
: 'displayfield',
199 fieldLabel
: 'ROM-File',
204 me
.advancedColumn2
= [
206 xtype
: 'proxmoxcheckbox',
207 fieldLabel
: 'PCI-Express',
216 Ext
.define('PVE.qemu.PCIEdit', {
217 extend
: 'Proxmox.window.Edit',
223 subject
: gettext('PCI Device'),
226 initComponent: function() {
229 me
.isCreate
= !me
.confid
;
231 var ipanel
= Ext
.create('PVE.qemu.PCIInputPanel', {
233 pveSelNode
: me
.pveSelNode
,
243 success: function(response
) {
244 ipanel
.setVMConfig(response
.result
.data
);