mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-22 17:57:46 +03:00
F #5516: Incremental backups not compatible with snapshots
- Qemu will terminate VMs with system snapshots and checkpoints, example: libvirtd[7446]: internal error: qemu unexpectedly closed the monitor: 2022-12-07T16:06:59.603678Z qemu-kvm-one: Device has active dirty bitmaps. - Also disk snapshots may render inconsistent bitmaps, example: 'virsh --connect qemu:///system checkpoint-delete 45d76e5f-25fa-416a-97fd-1624380d5e02 one-191-0': error: Failed to delete checkpoint one-191-0 error: internal error: unable to execute QEMU command 'query-named-block-nodes': Bitmap '' doesn't satisfy the constraints Error preparing disk files This commits prevents snapshot operations when increment backups are configured, and vice versa.
This commit is contained in:
parent
f002812c9f
commit
d711ea4362
@ -142,7 +142,7 @@ public:
|
||||
*/
|
||||
bool configured()
|
||||
{
|
||||
return config.empty();
|
||||
return !config.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1602,6 +1602,11 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
// System Snapshot related functions
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* @return true if VM has system snapshots defined
|
||||
*/
|
||||
bool has_snapshots();
|
||||
|
||||
/**
|
||||
* Creates a new Snapshot attribute, and sets it to ACTIVE=YES
|
||||
*
|
||||
|
@ -2307,6 +2307,17 @@ void VirtualMachineSnapshotCreate::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
auto vm_bck = vm->backups();
|
||||
|
||||
if ( vm_bck.configured() && vm_bck.mode() == Backups::INCREMENT )
|
||||
{
|
||||
att.resp_msg = "Action \"snapshot-create\" is not compatible with "
|
||||
"incremental backups";
|
||||
failure_response(ACTION, att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// get quota deltas
|
||||
snap = vm->new_snapshot(name, snap_id);
|
||||
snap = snap->clone();
|
||||
@ -3080,6 +3091,17 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
auto vm_bck = vm->backups();
|
||||
|
||||
if ( vm_bck.configured() && vm_bck.mode() == Backups::INCREMENT )
|
||||
{
|
||||
att.resp_msg = "Action \"disk-snapshot-create\" is not compatible with "
|
||||
"incremental backups";
|
||||
failure_response(ACTION, att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
disk = vm->get_disk(did);
|
||||
|
||||
if (disk == nullptr)
|
||||
|
@ -3197,7 +3197,8 @@ int VirtualMachine::updateconf(VirtualMachineTemplate* tmpl, string &err,
|
||||
// -------------------------------------------------------------------------
|
||||
if ( lcm_state != BACKUP && lcm_state != BACKUP_POWEROFF)
|
||||
{
|
||||
bool increment = disks.backup_increment(_backups.do_volatile());
|
||||
bool increment = disks.backup_increment(_backups.do_volatile()) &&
|
||||
!has_snapshots();
|
||||
|
||||
if ( _backups.parse(tmpl, increment, append, err) != 0 )
|
||||
{
|
||||
|
@ -1579,7 +1579,7 @@ bool VirtualMachineDisks::backup_increment(bool do_volatile)
|
||||
|
||||
one_util::toupper(format);
|
||||
|
||||
if (format != "QCOW2")
|
||||
if (format != "QCOW2" || disk->has_snapshots())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -24,7 +24,17 @@ using namespace std;
|
||||
// System Snapshot Interface
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
bool VirtualMachine::has_snapshots()
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
|
||||
return obj_template->get("SNAPSHOT", snaps) > 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VectorAttribute* VirtualMachine::new_snapshot(string& name, int& snap_id)
|
||||
{
|
||||
int num_snaps;
|
||||
|
Loading…
x
Reference in New Issue
Block a user