On 3/20/19 1:40 AM, Eric Blake wrote:
An upcoming patch will rework virDomainSnapshotObjList to be generic
for both snapshots and checkpoints; reduce the churn by adding a new
accessor virDomainSnapshotObjGetDef() which returns the
snapshot-specific definition even when the list is rewritten to
operate only on a base class, then using it at sites that that are
specific to snapshots.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/conf/virdomainsnapshotobj.h | 6 +++++
src/conf/snapshot_conf.c | 41 +++++++++++++++++------------
src/conf/virdomainsnapshotobjlist.c | 17 +++++++-----
src/qemu/qemu_domain.c | 6 ++---
4 files changed, 43 insertions(+), 27 deletions(-)
[...]
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index c692d36bd1..aec23f111c 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
[...]
@@ -958,12 +964,13 @@ virDomainSnapshotRedefinePrep(virDomainPtr
domain,
}
other = virDomainSnapshotFindByName(vm->snapshots, def->name);
- check_if_stolen = other && other->def->dom;
+ otherdef = other ? virDomainSnapshotObjGetDef(other) : NULL;
+ check_if_stolen = other && otherdef->dom;
if (virDomainSnapshotRedefineValidate(def, domain->uuid, other, xmlopt,
flags) < 0) {
/* revert any stealing of the snapshot domain definition */
- if (check_if_stolen && def->dom && !other->def->dom) {
- other->def->dom = def->dom;
+ if (check_if_stolen && def->dom && !otherdef->dom) {
+ otherdef->dom = def->dom;
def->dom = NULL;
}
return -1;
@@ -977,8 +984,8 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
/* Drop and rebuild the parent relationship, but keep all
* child relations by reusing snap. */
virDomainSnapshotDropParent(other);
- virDomainSnapshotDefFree(other->def);
- other->def = def;
+ virDomainSnapshotDefFree(otherdef);
+ otherdef = def;
Too much substitution ;-/... leave the old code other->def = def; Or
maybe we'll need the corresponding virDomainSnapshotObjSetDef...
Reviewed-by: John Ferlan <jferlan(a)redhat.com>
John
*defptr = NULL;
*snap = other;
}
[...]