Warn about file system state when a freeze would be needed, but isn't possible

If a snapshot of a running VM is taken and the RAM is not included, the backend
checks whether the QEMU Guest Agent is running inside the VM. If it is, it freezes
the file system, otherwise the snapshot is taken without freezing, which
could lead to an inconsistent file system state in the snapshot.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2020-02-06 13:26:37 +01:00 committed by Thomas Lamprecht
parent 7fb02366e0
commit a6ebb96d7c

View File

@ -1,6 +1,19 @@
Ext.define('PVE.window.Snapshot', {
extend: 'Proxmox.window.Edit',
viewModel: {
data: {
type: undefined,
isCreate: undefined,
running: false,
guestAgentEnabled: false,
},
formulas: {
runningWithoutGuestAgent: (get) => get('type') === 'qemu' && get('running') && !get('guestAgentEnabled'),
shouldWarnAboutFS: (get) => get('isCreate') && get('runningWithoutGuestAgent') && get('!vmstate.checked'),
},
},
onGetValues: function(values) {
let me = this;
@ -13,6 +26,7 @@ Ext.define('PVE.window.Snapshot', {
initComponent : function() {
var me = this;
var vm = me.getViewModel();
if (!me.nodename) {
throw "no node name specified";
@ -26,7 +40,34 @@ Ext.define('PVE.window.Snapshot', {
throw "no type specified";
}
vm.set('type', me.type);
vm.set('running', me.running);
vm.set('isCreate', me.isCreate);
if (me.type === 'qemu' && me.isCreate) {
Proxmox.Utils.API2Request({
url: `/nodes/${me.nodename}/${me.type}/${me.vmid}/config`,
params: { 'current': '1' },
method: 'GET',
success: function(response, options) {
let res = response.result.data;
let enabled = PVE.Parser.parsePropertyString(res.agent, 'enabled');
vm.set('guestAgentEnabled', !!PVE.Parser.parseBoolean(enabled.enabled));
}
});
}
me.items = [
{
xtype: 'displayfield',
userCls: 'pmx-hint',
name: 'fswarning',
hidden: true,
value: gettext('It is recommended to either include the RAM or enable the QEMU Guest Agent when taking a snapshot of a running VM. Otherwise the file system might be in an inconsistent state when the snapshot is taken.'),
bind: {
hidden: '{!shouldWarnAboutFS}',
},
},
{
xtype: me.isCreate ? 'textfield' : 'displayfield',
name: 'snapname',
@ -48,6 +89,7 @@ Ext.define('PVE.window.Snapshot', {
hidden: me.type !== 'qemu' || !me.isCreate || !me.running,
disabled: me.type !== 'qemu' || !me.isCreate || !me.running,
name: 'vmstate',
reference: 'vmstate',
uncheckedValue: 0,
defaultValue: 0,
checked: 1,