On 3/20/19 12: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>
---
+++ b/src/conf/snapshot_conf.c
@@ -923,6 +927,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr
domain,
{
virDomainSnapshotDefPtr def = *defptr;
virDomainSnapshotObjPtr other;
+ virDomainSnapshotDefPtr otherdef;
bool check_if_stolen;
/* Prevent circular chains */
@@ -940,15 +945,16 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
def->parent, def->name);
return -1;
}
- while (other->def->parent) {
- if (STREQ(other->def->parent, def->name)) {
+ otherdef = virDomainSnapshotObjGetDef(other);
+ while (otherdef->parent) {
+ if (STREQ(otherdef->parent, def->name)) {
virReportError(VIR_ERR_INVALID_ARG,
_("parent %s would create cycle to %s"),
- other->def->name, def->name);
+ otherdef->name, def->name);
return -1;
}
other = virDomainSnapshotFindByName(vm->snapshots,
- other->def->parent);
+ otherdef->parent);
if (!other) {
Whoops - this tries to follow a chain back to a root, but while it
updates other, it does not update otherdef. I caused a circular chain in
trying to check for circular chains. Will fix, along with a testsuite
addition that covers it.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org