[libvirt] [PATCH 08/16] snapshot: Access snapshot def directly when needed

Eric Blake eblake at redhat.com
Sat Mar 23 22:07:15 UTC 2019


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 at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190323/24ecadbe/attachment-0001.sig>


More information about the libvir-list mailing list