mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemuDomainSnapshotForEachQcow2: Pass in 'def' rather than selecting it internally
In some cases such as when creating an internal inactive snapshot we know that the domain definition in the snapshot is equivalent to the current definition. Additionally we set up the current definition for the snapshotting but not the one contained in the snapshot. Thus in some cases the caller knows better which def to use. Make qemuDomainSnapshotForEachQcow2 take the definition by the caller and copy the logic for selecting the definition to callers where we don't know for sure that the above claim applies. This fixes internal inactive snapshots when <disk type='volume'> is used as we translate the pool/vol combo only in the current def. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/97 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d3c6c80c79
commit
926563dc3a
@ -6560,18 +6560,11 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr driver,
|
||||
* failure, 1 if we skipped a disk due to try_all. */
|
||||
int
|
||||
qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainDefPtr def,
|
||||
virDomainMomentObjPtr snap,
|
||||
const char *op,
|
||||
bool try_all)
|
||||
{
|
||||
/* Prefer action on the disks in use at the time the snapshot was
|
||||
* created; but fall back to current definition if dealing with a
|
||||
* snapshot created prior to libvirt 0.9.5. */
|
||||
virDomainDefPtr def = snap->def->dom;
|
||||
|
||||
if (!def)
|
||||
def = vm->def;
|
||||
return qemuDomainSnapshotForEachQcow2Raw(driver, def, snap->def->name,
|
||||
op, try_all, def->ndisks);
|
||||
}
|
||||
@ -6592,9 +6585,16 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
|
||||
if (!metadata_only) {
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
/* Ignore any skipped disks */
|
||||
if (qemuDomainSnapshotForEachQcow2(driver, vm, snap, "-d",
|
||||
true) < 0)
|
||||
return -1;
|
||||
|
||||
/* Prefer action on the disks in use at the time the snapshot was
|
||||
* created; but fall back to current definition if dealing with a
|
||||
* snapshot created prior to libvirt 0.9.5. */
|
||||
virDomainDefPtr def = snap->def->dom;
|
||||
|
||||
if (!def)
|
||||
def = vm->def;
|
||||
|
||||
return qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true);
|
||||
} else {
|
||||
priv = vm->privateData;
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
|
@ -613,7 +613,7 @@ int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
||||
const char *snapshotDir);
|
||||
|
||||
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainDefPtr def,
|
||||
virDomainMomentObjPtr snap,
|
||||
const char *op,
|
||||
bool try_all);
|
||||
|
@ -138,7 +138,7 @@ qemuSnapshotCreateInactiveInternal(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainMomentObjPtr snap)
|
||||
{
|
||||
return qemuDomainSnapshotForEachQcow2(driver, vm, snap, "-c", false);
|
||||
return qemuDomainSnapshotForEachQcow2(driver, vm->def, snap, "-c", false);
|
||||
}
|
||||
|
||||
|
||||
@ -1813,9 +1813,19 @@ qemuSnapshotRevertInactive(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainMomentObjPtr snap)
|
||||
{
|
||||
/* Prefer action on the disks in use at the time the snapshot was
|
||||
* created; but fall back to current definition if dealing with a
|
||||
* snapshot created prior to libvirt 0.9.5. */
|
||||
virDomainDefPtr def = snap->def->dom;
|
||||
|
||||
if (!def)
|
||||
def = vm->def;
|
||||
|
||||
/* Try all disks, but report failure if we skipped any. */
|
||||
int ret = qemuDomainSnapshotForEachQcow2(driver, vm, snap, "-a", true);
|
||||
return ret > 0 ? -1 : ret;
|
||||
if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-a", true) != 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user