]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virDomainSnapshotAlignDisks: refactor extension to all disks
authorPeter Krempa <pkrempa@redhat.com>
Mon, 21 Sep 2020 17:36:17 +0000 (19:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 23 Sep 2020 20:39:24 +0000 (22:39 +0200)
commitd3c029bb105e8cc9d53c45ab3ef9e4c0310347bf
tree90272f811350585bdda3c0bd1b7a33a8aedc55db
parent17c238626b84f79470f96e2e7b6554233da9bc4a
virDomainSnapshotAlignDisks: refactor extension to all disks

Last step of the algorithm in virDomainSnapshotAlignDisks is to extend
the array of disks to all VM's disk and provide defaults. This was done
by extending the array, adding defaults at the end and then sorting it.
This requires the 'idx' variable and also a separate sorting function.

If we store the pointer to existing snapshot disk definitions in a hash
table and create a new array of snapshot disk definitions, we can fill
the new array directly by either copying the definition from the old
array or adding the default.

This avoids the sorting step and thus even the need to store the index
of the domain disk altogether.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
src/conf/snapshot_conf.c