]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/RNGEdit.js
fix # 4044: ui: hd move: avoid bogus progress bar, show task viewer
[pve-manager.git] / www / manager6 / qemu / RNGEdit.js
CommitLineData
6c1d8ead
SR
1Ext.define('PVE.qemu.RNGInputPanel', {
2 extend: 'Proxmox.panel.InputPanel',
3 xtype: 'pveRNGInputPanel',
4
86c112d0 5 onlineHelp: 'qm_virtio_rng',
6c1d8ead
SR
6
7 onGetValues: function(values) {
8 if (values.max_bytes === "") {
9 values.max_bytes = "0";
10 } else if (values.max_bytes === "1024" && values.period === "") {
11 delete values.max_bytes;
12 }
13
14 var ret = PVE.Parser.printPropertyString(values);
15
16 return {
f6710aac 17 rng0: ret,
6c1d8ead
SR
18 };
19 },
20
21 setValues: function(values) {
91a47a76 22 if (values.max_bytes === 0) {
6c1d8ead
SR
23 values.max_bytes = null;
24 }
25
26 this.callParent(arguments);
27 },
28
29 controller: {
30 xclass: 'Ext.app.ViewController',
31 control: {
32 '#max_bytes': {
33 change: function(el, newVal) {
34 let limitWarning = this.lookupReference('limitWarning');
35 limitWarning.setHidden(!!newVal);
f6710aac 36 },
6c1d8ead
SR
37 },
38 '#source': {
39 change: function(el, newVal) {
40 let limitWarning = this.lookupReference('sourceWarning');
41 limitWarning.setHidden(newVal !== '/dev/random');
f6710aac
TL
42 },
43 },
44 },
6c1d8ead
SR
45 },
46
47 items: [{
48 itemId: 'source',
49 name: 'source',
50 xtype: 'proxmoxKVComboBox',
51 value: '/dev/urandom',
52 fieldLabel: gettext('Entropy source'),
53 labelWidth: 130,
54 comboItems: [
55 ['/dev/urandom', '/dev/urandom'],
56 ['/dev/random', '/dev/random'],
f6710aac
TL
57 ['/dev/hwrng', '/dev/hwrng'],
58 ],
6c1d8ead
SR
59 },
60 {
61 xtype: 'numberfield',
62 itemId: 'max_bytes',
63 name: 'max_bytes',
64 minValue: 0,
65 step: 1,
66 value: 1024,
67 fieldLabel: gettext('Limit (Bytes/Period)'),
68 labelWidth: 130,
f6710aac 69 emptyText: gettext('unlimited'),
6c1d8ead
SR
70 },
71 {
72 xtype: 'numberfield',
73 name: 'period',
74 minValue: 1,
75 step: 1,
76 fieldLabel: gettext('Period') + ' (ms)',
77 labelWidth: 130,
17b77791 78 emptyText: '1000',
6c1d8ead
SR
79 },
80 {
81 xtype: 'displayfield',
82 reference: 'sourceWarning',
83 value: gettext('Using /dev/random as entropy source is discouraged, as it can lead to host entropy starvation. /dev/urandom is preferred, and does not lead to a decrease in security in practice.'),
84 userCls: 'pmx-hint',
f6710aac 85 hidden: true,
6c1d8ead
SR
86 },
87 {
88 xtype: 'displayfield',
89 reference: 'limitWarning',
90 value: gettext('Disabling the limiter can potentially allow a guest to overload the host. Proceed with caution.'),
91 userCls: 'pmx-hint',
f6710aac
TL
92 hidden: true,
93 }],
6c1d8ead
SR
94});
95
96Ext.define('PVE.qemu.RNGEdit', {
97 extend: 'Proxmox.window.Edit',
98
99 subject: gettext('VirtIO RNG'),
100
101 items: [{
f6710aac 102 xtype: 'pveRNGInputPanel',
6c1d8ead
SR
103 }],
104
8058410f 105 initComponent: function() {
6c1d8ead
SR
106 var me = this;
107
108 me.callParent();
109
110 if (!me.isCreate) {
111 me.load({
112 success: function(response) {
113 me.vmconfig = response.result.data;
114
115 var rng0 = me.vmconfig.rng0;
116 if (rng0) {
117 me.setValues(PVE.Parser.parsePropertyString(rng0));
118 }
f6710aac 119 },
6c1d8ead
SR
120 });
121 }
f6710aac 122 },
6c1d8ead 123});