mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemuSnapshotDeleteValidate: Fix crash when disk is not found in VM definition
qemuDomainDiskByName() can return a NULL pointer on failure. But this returned value in qemuSnapshotDeleteValidate is not checked.It will make libvirtd crash. Signed-off-by: kaihuan <jungleman759@gmail.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
00f9f2ca1f
commit
c1166be347
@ -4243,8 +4243,19 @@ qemuSnapshotDeleteValidate(virDomainObj *vm,
|
|||||||
virDomainDiskDef *vmdisk = NULL;
|
virDomainDiskDef *vmdisk = NULL;
|
||||||
virDomainDiskDef *disk = NULL;
|
virDomainDiskDef *disk = NULL;
|
||||||
|
|
||||||
vmdisk = qemuDomainDiskByName(vm->def, snapDisk->name);
|
if (!(vmdisk = qemuDomainDiskByName(vm->def, snapDisk->name))) {
|
||||||
disk = qemuDomainDiskByName(snapdef->parent.dom, snapDisk->name);
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
_("disk '%1$s' referenced by snapshot '%2$s' not found in the current definition"),
|
||||||
|
snapDisk->name, snap->def->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(disk = qemuDomainDiskByName(snapdef->parent.dom, snapDisk->name))) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
_("disk '%1$s' referenced by snapshot '%2$s' not found in the VM definition of the deleted snapshot"),
|
||||||
|
snapDisk->name, snap->def->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!virStorageSourceIsSameLocation(vmdisk->src, disk->src)) {
|
if (!virStorageSourceIsSameLocation(vmdisk->src, disk->src)) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user