From 97cfa76290990ce49cc8cc0a897d1933c472eb47 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 12 Feb 2024 22:48:27 +0100 Subject: [PATCH] F #6400: Error message when changing from FULL to INCREMENTAL backup This commits returns an error message when trying to change a VM to incremental mode if not supported by the VM configuration. Previously, the change was silently ignored by OpenNebula. --- src/vm/VirtualMachine.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 486b6c76a0..092d61fc76 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -3205,11 +3205,35 @@ int VirtualMachine::updateconf(VirtualMachineTemplate* tmpl, string &err, // Parse backup configuration (if not doing a backup). Uses current value of // BACKUP_VOLATILE attribute. // ------------------------------------------------------------------------- - if ( lcm_state != BACKUP && lcm_state != BACKUP_POWEROFF) + VectorAttribute * backup_conf = tmpl->get("BACKUP_CONFIG"); + + if ( backup_conf != nullptr && lcm_state != BACKUP && lcm_state != BACKUP_POWEROFF) { bool increment = disks.backup_increment(_backups.do_volatile()) && !has_snapshots(); + string smode = backup_conf->vector_value("MODE"); + Backups::Mode bmode = Backups::str_to_mode(smode); + + if (!smode.empty() && !increment && bmode == Backups::INCREMENT) + { + err = "VM cannot use backup increment mode"; + + if (has_snapshots()) + { + err += ", it has snapshots."; + } + else + { + err += ", it has disks snapshots or disks are not qcow2."; + } + + NebulaLog::log("ONE", Log::ERROR, err); + return -1; + } + + backup_conf = nullptr; + if ( _backups.parse(tmpl, increment, append, err) != 0 ) { NebulaLog::log("ONE",Log::ERROR, err);