1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

qemu: snapshot: Limit scope of checkpoint-snapshot interlock

'qemuDomainSupportsCheckpointsBlockjobs()' should really be used only
with active VMs based on the scope of interlocking it does.

This means that the inactive snapshot code path needs to do the
interlocking based on what's supported:
 - external snapshot support was not implemented yet
    (bitmaps need to be propagated to the new overlay image)
 - internal snapshot support can be deferred to qemu

Move the check inside qemuSnapshotPrepare() which has knowledge about
the snapshot type and implement an explicit check for the inactive case.

See: https://gitlab.com/libvirt/libvirt/-/issues/739
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2025-02-03 15:45:49 +01:00
parent 5def28df55
commit 29d77d1a64

View File

@ -39,6 +39,7 @@
#include "domain_audit.h"
#include "locking/domain_lock.h"
#include "virdomainsnapshotobjlist.h"
#include "virdomaincheckpointobjlist.h"
#include "virqemu.h"
#include "storage_source.h"
@ -1080,6 +1081,23 @@ qemuSnapshotPrepare(virDomainObj *vm,
}
/* Handle interlocking with 'checkpoints':
* - if the VM is online use qemuDomainSupportsCheckpointsBlockjobs
* - if the VM is offline disallow external snapshots as the support for
* propagating bitmaps into the would-be-created overlay is not yet implemented
*/
if (!active) {
if (external &&
virDomainListCheckpoints(vm->checkpoints, NULL, NULL, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("support for offline external snapshots while checkpoint exists was not yet implemented"));
return -1;
}
} else {
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
return -1;
}
/* Alter flags to let later users know what we learned. */
if (external && !active)
*flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
@ -2147,9 +2165,6 @@ qemuSnapshotCreateXML(virDomainPtr domain,
VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE,
NULL);
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
return NULL;
if (!vm->persistent && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot halt after transient domain snapshot"));