[pve-devel] [RFC manager 5/5] GUI: QEMU Hardware: add comment fields to rows
Matthias Heiserer
m.heiserer at proxmox.com
Mon Feb 14 15:01:44 CET 2022
This patch adds comment support to all qemu/hardware items.
Mostly, these are property-string based fields.
As processor(sockets), memory, bios, machine, and scsihw are
multikey fields, comments haev to be sent in separate fields.
I tried to keep the number of changes minimal, which means that
the various files differ to some extent in how comments are
implemented (e.g. USBEdit). Streamlining them might be a good idea.
Signed-off-by: Matthias Heiserer <m.heiserer at proxmox.com>
---
www/manager6/qemu/AudioEdit.js | 3 ++-
www/manager6/qemu/CDEdit.js | 7 ++++---
www/manager6/qemu/CIDriveEdit.js | 2 ++
www/manager6/qemu/DisplayEdit.js | 2 +-
www/manager6/qemu/HDEdit.js | 4 ++++
www/manager6/qemu/HDEfi.js | 3 +++
www/manager6/qemu/HDTPM.js | 2 ++
www/manager6/qemu/MachineEdit.js | 24 ++++++++++++++----------
www/manager6/qemu/MemoryEdit.js | 3 +++
www/manager6/qemu/NetworkEdit.js | 7 +++++--
www/manager6/qemu/PCIEdit.js | 1 +
www/manager6/qemu/ProcessorEdit.js | 1 +
www/manager6/qemu/QemuBiosEdit.js | 1 +
www/manager6/qemu/RNGEdit.js | 1 +
www/manager6/qemu/ScsiHwEdit.js | 15 +++++++++------
www/manager6/qemu/SerialEdit.js | 6 +++---
www/manager6/qemu/USBEdit.js | 13 ++++++++++++-
17 files changed, 68 insertions(+), 27 deletions(-)
diff --git a/www/manager6/qemu/AudioEdit.js b/www/manager6/qemu/AudioEdit.js
index e7861ceb..f657f8f6 100644
--- a/www/manager6/qemu/AudioEdit.js
+++ b/www/manager6/qemu/AudioEdit.js
@@ -36,7 +36,8 @@ Ext.define('PVE.qemu.AudioInputPanel', {
['spice', 'SPICE'],
['none', `${Proxmox.Utils.NoneText} (${gettext('Dummy Device')})`],
],
- }],
+ },
+ PVE.Utils.commentField()],
});
Ext.define('PVE.qemu.AudioEdit', {
diff --git a/www/manager6/qemu/CDEdit.js b/www/manager6/qemu/CDEdit.js
index 72c01037..ec1f3388 100644
--- a/www/manager6/qemu/CDEdit.js
+++ b/www/manager6/qemu/CDEdit.js
@@ -17,7 +17,7 @@ Ext.define('PVE.qemu.CDInputPanel', {
} else {
me.drive.file = 'none';
}
-
+ PVE.Utils.propertyStringSet(me.drive, values.comment, 'comment');
var params = {};
params[confid] = PVE.Parser.printQemuDrive(me.drive);
@@ -49,9 +49,8 @@ Ext.define('PVE.qemu.CDInputPanel', {
values.cdimage = drive.file;
}
}
-
+ values.comment = PVE.Parser.parseComment(drive.comment);
me.drive = drive;
-
me.setValues(values);
},
@@ -140,6 +139,8 @@ Ext.define('PVE.qemu.CDInputPanel', {
boxLabel: gettext('Do not use any media'),
});
+ items.push(PVE.Utils.commentField());
+
me.items = items;
me.callParent();
diff --git a/www/manager6/qemu/CIDriveEdit.js b/www/manager6/qemu/CIDriveEdit.js
index 754b8353..1f5ee37b 100644
--- a/www/manager6/qemu/CIDriveEdit.js
+++ b/www/manager6/qemu/CIDriveEdit.js
@@ -13,6 +13,7 @@ Ext.define('PVE.qemu.CIDriveInputPanel', {
var params = {};
drive.file = values.hdstorage + ":cloudinit";
drive.format = values.diskformat;
+ drive.comment = values.comment;
params[values.controller + values.deviceid] = PVE.Parser.printQemuDrive(drive);
return params;
},
@@ -48,6 +49,7 @@ Ext.define('PVE.qemu.CIDriveInputPanel', {
nodename: me.nodename,
hideSize: true,
},
+ PVE.Utils.commentField(),
];
me.callParent();
},
diff --git a/www/manager6/qemu/DisplayEdit.js b/www/manager6/qemu/DisplayEdit.js
index 82e6777e..0f03101a 100644
--- a/www/manager6/qemu/DisplayEdit.js
+++ b/www/manager6/qemu/DisplayEdit.js
@@ -83,7 +83,7 @@ Ext.define('PVE.qemu.DisplayInputPanel', {
maxValue: 512,
step: 4,
name: 'memory',
- }],
+ }, PVE.Utils.commentField()],
});
Ext.define('PVE.qemu.DisplayEdit', {
diff --git a/www/manager6/qemu/HDEdit.js b/www/manager6/qemu/HDEdit.js
index c643ee73..bffdee48 100644
--- a/www/manager6/qemu/HDEdit.js
+++ b/www/manager6/qemu/HDEdit.js
@@ -93,6 +93,7 @@ Ext.define('PVE.qemu.HDInputPanel', {
PVE.Utils.propertyStringSet(me.drive, values.readOnly, 'ro', 'on');
PVE.Utils.propertyStringSet(me.drive, values.cache, 'cache');
PVE.Utils.propertyStringSet(me.drive, values.aio, 'aio');
+ PVE.Utils.propertyStringSet(me.drive, values.comment, 'comment');
['mbps_rd', 'mbps_wr', 'iops_rd', 'iops_wr'].forEach(name => {
let burst_name = `${name}_max`;
@@ -153,6 +154,7 @@ Ext.define('PVE.qemu.HDInputPanel', {
values.iothread = PVE.Parser.parseBoolean(drive.iothread);
values.readOnly = PVE.Parser.parseBoolean(drive.ro);
values.aio = drive.aio || '__default__';
+ values.comment = PVE.Parser.parseComment(drive.comment) || '';
values.mbps_rd = drive.mbps_rd;
values.mbps_wr = drive.mbps_wr;
@@ -238,6 +240,8 @@ Ext.define('PVE.qemu.HDInputPanel', {
});
}
+ column1.push(PVE.Utils.commentField());
+
column2.push(
{
xtype: 'CacheTypeSelector',
diff --git a/www/manager6/qemu/HDEfi.js b/www/manager6/qemu/HDEfi.js
index a8ca8f56..7d16540b 100644
--- a/www/manager6/qemu/HDEfi.js
+++ b/www/manager6/qemu/HDEfi.js
@@ -17,6 +17,8 @@ Ext.define('PVE.qemu.EFIDiskInputPanel', {
var confid = 'efidisk0';
+ me.drive.comment = values.comment;
+
if (values.hdimage) {
me.drive.file = values.hdimage;
} else {
@@ -76,6 +78,7 @@ Ext.define('PVE.qemu.EFIDiskInputPanel', {
'data-qtip': gettext('Use EFIvars image with standard distribution and Microsoft secure boot keys enrolled.'),
},
},
+ PVE.Utils.commentField(),
{
xtype: 'label',
text: gettext("Warning: The VM currently does not uses 'OVMF (UEFI)' as BIOS."),
diff --git a/www/manager6/qemu/HDTPM.js b/www/manager6/qemu/HDTPM.js
index 87349aed..0b4a6431 100644
--- a/www/manager6/qemu/HDTPM.js
+++ b/www/manager6/qemu/HDTPM.js
@@ -13,6 +13,7 @@ Ext.define('PVE.qemu.TPMDiskInputPanel', {
}
var confid = 'tpmstate0';
+ me.drive.comment = values.comment;
if (values.hdimage) {
me.drive.file = values.hdimage;
@@ -68,6 +69,7 @@ Ext.define('PVE.qemu.TPMDiskInputPanel', {
['v2.0', 'v2.0'],
],
},
+ PVE.Utils.commentField(),
];
me.callParent();
diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
index f928c80c..61540d55 100644
--- a/www/manager6/qemu/MachineEdit.js
+++ b/www/manager6/qemu/MachineEdit.js
@@ -69,16 +69,19 @@ Ext.define('PVE.qemu.MachineInputPanel', {
this.callParent(arguments);
},
- items: {
- xtype: 'proxmoxKVComboBox',
- name: 'machine',
- reference: 'machine',
- fieldLabel: gettext('Machine'),
- comboItems: [
- ['__default__', PVE.Utils.render_qemu_machine('')],
- ['q35', 'q35'],
- ],
- },
+ items: [
+ {
+ xtype: 'proxmoxKVComboBox',
+ name: 'machine',
+ reference: 'machine',
+ fieldLabel: gettext('Machine'),
+ comboItems: [
+ ['__default__', PVE.Utils.render_qemu_machine('')],
+ ['q35', 'q35'],
+ ],
+ },
+ PVE.Utils.commentField('machine_comment'),
+ ],
advancedItems: [
{
@@ -137,6 +140,7 @@ Ext.define('PVE.qemu.MachineEdit', {
let conf = response.result.data;
let values = {
machine: conf.machine || '__default__',
+ machine_comment: conf.machine_comment,
};
values.isWindows = PVE.Utils.is_windows(conf.ostype);
me.setValues(values);
diff --git a/www/manager6/qemu/MemoryEdit.js b/www/manager6/qemu/MemoryEdit.js
index 5e91dc9b..aa5c6b4d 100644
--- a/www/manager6/qemu/MemoryEdit.js
+++ b/www/manager6/qemu/MemoryEdit.js
@@ -38,6 +38,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
res.memory = values.memory;
res.balloon = values.balloon;
+ res.memory_comment = values.memory_comment;
if (!values.ballooning) {
res.balloon = 0;
@@ -80,6 +81,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
},
},
},
+ PVE.Utils.commentField('memory_comment'),
];
me.advancedItems= [
@@ -183,6 +185,7 @@ Ext.define('PVE.qemu.MemoryEdit', {
shares: data.shares,
memory: data.memory || '512',
balloon: data.balloon > 0 ? data.balloon : data.memory || '512',
+ memory_comment: data.memory_comment,
};
ipanel.setValues(values);
diff --git a/www/manager6/qemu/NetworkEdit.js b/www/manager6/qemu/NetworkEdit.js
index b39cffdc..074d3006 100644
--- a/www/manager6/qemu/NetworkEdit.js
+++ b/www/manager6/qemu/NetworkEdit.js
@@ -19,7 +19,7 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
me.network.macaddr = values.macaddr;
me.network.disconnect = values.disconnect;
me.network.queues = values.queues;
-
+ me.network.comment = values.comment;
if (values.rate) {
me.network.rate = values.rate;
} else {
@@ -140,7 +140,10 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
vtype: 'MacAddress',
allowBlank: true,
emptyText: 'auto',
- });
+ },
+ PVE.Utils.commentField(),
+ );
+
me.advancedColumn2 = [
{
xtype: 'numberfield',
diff --git a/www/manager6/qemu/PCIEdit.js b/www/manager6/qemu/PCIEdit.js
index f505e34f..ac556c7a 100644
--- a/www/manager6/qemu/PCIEdit.js
+++ b/www/manager6/qemu/PCIEdit.js
@@ -151,6 +151,7 @@ Ext.define('PVE.qemu.PCIInputPanel', {
fieldLabel: gettext('All Functions'),
name: 'multifunction',
},
+ PVE.Utils.commentField(),
];
me.column2 = [
diff --git a/www/manager6/qemu/ProcessorEdit.js b/www/manager6/qemu/ProcessorEdit.js
index 539e3e7d..f7d1c2e2 100644
--- a/www/manager6/qemu/ProcessorEdit.js
+++ b/www/manager6/qemu/ProcessorEdit.js
@@ -121,6 +121,7 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
value: '{coreCount}',
},
},
+ PVE.Utils.commentField('sockets_comment'),
],
column2: [
diff --git a/www/manager6/qemu/QemuBiosEdit.js b/www/manager6/qemu/QemuBiosEdit.js
index 70731a71..228375c2 100644
--- a/www/manager6/qemu/QemuBiosEdit.js
+++ b/www/manager6/qemu/QemuBiosEdit.js
@@ -25,6 +25,7 @@ Ext.define('PVE.qemu.BiosEdit', {
bind: '{bios}',
fieldLabel: 'BIOS',
},
+ PVE.Utils.commentField('bios_comment'),
{
xtype: 'displayfield',
name: 'efidisk0',
diff --git a/www/manager6/qemu/RNGEdit.js b/www/manager6/qemu/RNGEdit.js
index e34e2c08..e9aa488f 100644
--- a/www/manager6/qemu/RNGEdit.js
+++ b/www/manager6/qemu/RNGEdit.js
@@ -77,6 +77,7 @@ Ext.define('PVE.qemu.RNGInputPanel', {
labelWidth: 130,
emptyText: '1000',
},
+ PVE.Utils.commentField(),
{
xtype: 'displayfield',
reference: 'sourceWarning',
diff --git a/www/manager6/qemu/ScsiHwEdit.js b/www/manager6/qemu/ScsiHwEdit.js
index 70f09c17..edd66808 100644
--- a/www/manager6/qemu/ScsiHwEdit.js
+++ b/www/manager6/qemu/ScsiHwEdit.js
@@ -6,12 +6,15 @@ Ext.define('PVE.qemu.ScsiHwEdit', {
Ext.applyIf(me, {
subject: gettext('SCSI Controller Type'),
- items: {
- xtype: 'pveScsiHwSelector',
- name: 'scsihw',
- value: '__default__',
- fieldLabel: gettext('Type'),
- },
+ items: [
+ {
+ xtype: 'pveScsiHwSelector',
+ name: 'scsihw',
+ value: '__default__',
+ fieldLabel: gettext('Type'),
+ },
+ PVE.Utils.commentField('scsihw_comment'),
+ ],
});
me.callParent();
diff --git a/www/manager6/qemu/SerialEdit.js b/www/manager6/qemu/SerialEdit.js
index 6ce18ec2..730fe2c3 100644
--- a/www/manager6/qemu/SerialEdit.js
+++ b/www/manager6/qemu/SerialEdit.js
@@ -17,12 +17,11 @@ Ext.define('PVE.qemu.SerialnputPanel', {
},
onGetValues: function(values) {
- var me = this;
-
var id = 'serial' + values.serialid;
delete values.serialid;
values[id] = 'socket';
- return values;
+
+ return { [id]: PVE.Parser.printPropertyString(values, id) };
},
items: [
@@ -44,6 +43,7 @@ Ext.define('PVE.qemu.SerialnputPanel', {
return true;
},
},
+ PVE.Utils.commentField(),
],
});
diff --git a/www/manager6/qemu/USBEdit.js b/www/manager6/qemu/USBEdit.js
index a2204584..817693ec 100644
--- a/www/manager6/qemu/USBEdit.js
+++ b/www/manager6/qemu/USBEdit.js
@@ -45,6 +45,8 @@ Ext.define('PVE.qemu.USBInputPanel', {
val += ',usb3=1';
}
values[me.confid] = val;
+ values[me.confid] += ',comment=' + PVE.Parser.encodeComment(values.comment);
+ delete values.comment;
return values;
},
@@ -107,6 +109,7 @@ Ext.define('PVE.qemu.USBInputPanel', {
reference: 'usb3',
fieldLabel: gettext('Use USB3'),
},
+ PVE.Utils.commentField(),
],
},
],
@@ -145,7 +148,7 @@ Ext.define('PVE.qemu.USBEdit', {
}
var data = response.result.data[me.confid].split(',');
- var port, hostdevice, usb3 = false;
+ var port, hostdevice, usb3, comment = false;
var type = 'spice';
for (let i = 0; i < data.length; i++) {
@@ -162,12 +165,20 @@ Ext.define('PVE.qemu.USBEdit', {
if (/^usb3=(1|on|true)$/.test(data[i])) {
usb3 = true;
}
+
+ // FIXME: use PVE.Parser.parsePropertyString
+ if (/comment=([^,]*)(,|$)/.test(data[i])) {
+ comment = data[i];
+ comment = comment.replace('comment=', '');
+ comment = PVE.Parser.parseComment(comment);
+ }
}
var values = {
usb: type,
hostdevice: hostdevice,
port: port,
usb3: usb3,
+ comment: comment,
};
ipanel.setValues(values);
--
2.30.2
More information about the pve-devel
mailing list