]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/PCIEdit.js
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');
13 if (!values
.host
.match(/^[0-9a-f]{4}:/i)) { // add optional domain
14 values
.host
= "0000:" + values
.host
;
16 if (values
.host
&& values
.host
.length
< 11) { // 0000:00:00 format not 0000:00:00.0
18 values
.multifunction
= true;
20 values
['x-vga'] = PVE
.Parser
.parseBoolean(values
['x-vga'], 0);
21 values
.pcie
= PVE
.Parser
.parseBoolean(values
.pcie
, 0);
22 values
.rombar
= PVE
.Parser
.parseBoolean(values
.rombar
, 1);
25 if (!me
.vmconfig
.machine
|| me
.vmconfig
.machine
.indexOf('q35') === -1) {
26 // machine is not set to some variant of q35, so we disable pcie
27 var pcie
= me
.down('field[name=pcie]');
28 pcie
.setDisabled(true);
29 pcie
.setBoxLabel(gettext('Q35 only'));
33 me
.down('field[name=romfile]').setVisible(true);
37 onGetValues: function(values
) {
42 for (i
= 0; i
< 5; i
++) {
43 if (!me
.vmconfig
['hostpci' + i
.toString()]) {
44 me
.confid
= 'hostpci' + i
.toString();
49 // remove optional '0000' domain
50 if (values
.host
.substring(0,5) === '0000:') {
51 values
.host
= values
.host
.substring(5);
53 if (values
.multifunction
) {
54 // modify host to skip the '.X'
55 values
.host
= values
.host
.substring(0, values
.host
.indexOf('.'));
56 delete values
.multifunction
;
65 if (!values
.romfile
) {
66 delete values
.romfile
;
69 ret
[me
.confid
] = PVE
.Parser
.printPropertyString(values
, 'host');
73 initComponent: function() {
76 me
.nodename
= me
.pveSelNode
.data
.node
;
78 throw "no node name specified";
83 xtype
: 'pvePCISelector',
84 fieldLabel
: gettext('Device'),
86 nodename
: me
.nodename
,
88 onLoadCallBack: function(store
, records
, success
) {
89 if (!success
|| !records
.length
) {
93 var first
= records
[0];
94 if (first
.data
.iommugroup
=== -1) {
96 var warning
= Ext
.create('Ext.form.field.Display', {
99 value
: 'No IOMMU detected, please activate it.' +
100 'See Documentation for further information.',
103 me
.items
.insert(0, warning
);
104 me
.updateLayout(); // insert does not trigger that
108 change: function(pcisel
, value
) {
112 var pcidev
= pcisel
.getStore().getById(value
);
113 var mdevfield
= me
.down('field[name=mdev]');
114 mdevfield
.setDisabled(!pcidev
|| !pcidev
.data
.mdev
);
118 var id
= pcidev
.data
.id
.substring(0,5); // 00:00
119 var iommu
= pcidev
.data
.iommugroup
;
120 // try to find out if there are more devices
121 // in that iommu group
124 pcisel
.getStore().each(function(record
) {
125 if (record
.data
.iommugroup
=== iommu
&&
126 record
.data
.id
.substring(0,5) !== id
)
132 var warning
= me
.down('#iommuwarning');
133 if (count
&& !warning
) {
134 warning
= Ext
.create('Ext.form.field.Display', {
137 itemId
: 'iommuwarning',
138 value
: 'The selected Device is not in a seperate' +
139 'IOMMU group, make sure this is intended.',
142 me
.items
.insert(0, warning
);
143 me
.updateLayout(); // insert does not trigger that
144 } else if (!count
&& warning
) {
148 if (pcidev
.data
.mdev
) {
149 mdevfield
.setPciID(value
);
155 xtype
: 'proxmoxcheckbox',
156 fieldLabel
: gettext('All Functions'),
157 name
: 'multifunction'
163 xtype
: 'pveMDevSelector',
166 fieldLabel
: gettext('MDev Type'),
167 nodename
: me
.nodename
,
169 change: function(field
, value
) {
170 var mf
= me
.down('field[name=multifunction]');
174 mf
.setDisabled(!!value
);
179 xtype
: 'proxmoxcheckbox',
180 fieldLabel
: gettext('Primary GPU'),
185 me
.advancedColumn1
= [
187 xtype
: 'proxmoxcheckbox',
188 fieldLabel
: 'ROM-Bar',
192 xtype
: 'displayfield',
195 fieldLabel
: 'ROM-File',
200 me
.advancedColumn2
= [
202 xtype
: 'proxmoxcheckbox',
203 fieldLabel
: 'PCI-Express',
212 Ext
.define('PVE.qemu.PCIEdit', {
213 extend
: 'Proxmox.window.Edit',
219 subject
: gettext('PCI Device'),
222 initComponent : function() {
225 me
.isCreate
= !me
.confid
;
227 var ipanel
= Ext
.create('PVE.qemu.PCIInputPanel', {
229 pveSelNode
: me
.pveSelNode
239 success: function(response
) {
240 ipanel
.setVMConfig(response
.result
.data
);