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