mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
qemu_snapshot: use virDomainDiskByName while updating domain def
When creating external snapshot this function is called only when the VM is not running so there is only one definition to care about. However, it will be used by external snapshot revert code for active and inactive definition and they may be different if a disk was (un)plugged only for the active or inactive definition. The current code would crash so use virDomainDiskByName() to get the correct disk from the domain definition based on the disk name and make sure it exists. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
4edd9e297a
commit
db9e253fc4
@ -152,11 +152,14 @@ qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef,
|
||||
for (i = 0; i < snapdef->ndisks; i++) {
|
||||
g_autoptr(virStorageSource) newsrc = NULL;
|
||||
virDomainSnapshotDiskDef *snapdisk = &(snapdef->disks[i]);
|
||||
virDomainDiskDef *defdisk = domdef->disks[i];
|
||||
virDomainDiskDef *defdisk = virDomainDiskByName(domdef, snapdisk->name, false);
|
||||
|
||||
if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
|
||||
continue;
|
||||
|
||||
if (!defdisk)
|
||||
continue;
|
||||
|
||||
if (!(newsrc = virStorageSourceCopy(snapdisk->src, false)))
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user