mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-23 06:23:10 +00:00
qemu: checkpoint: tolerate missing disks on checkpoint deletion
If a disk is unplugged and then the user tries to delete a checkpoint the code would try to use NULL node name as it was not checked. Fix this by fetching the whole disk definition object and verifying it was found. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
7973f7d792
commit
f19248a139
@ -125,12 +125,15 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
|
|||||||
|
|
||||||
for (i = 0; i < chkdef->ndisks; i++) {
|
for (i = 0; i < chkdef->ndisks; i++) {
|
||||||
virDomainCheckpointDiskDef *chkdisk = &chkdef->disks[i];
|
virDomainCheckpointDiskDef *chkdisk = &chkdef->disks[i];
|
||||||
const char *node;
|
virDomainDiskDefPtr domdisk = virDomainDiskByTarget(vm->def, chkdisk->name);
|
||||||
|
|
||||||
|
/* domdisk can be missing e.g. when it was unplugged */
|
||||||
|
if (!domdisk)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (chkdisk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
|
if (chkdisk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
node = qemuDomainDiskNodeFormatLookup(vm, chkdisk->name);
|
|
||||||
/* If any ancestor checkpoint has a bitmap for the same
|
/* If any ancestor checkpoint has a bitmap for the same
|
||||||
* disk, then this bitmap must be merged to the
|
* disk, then this bitmap must be merged to the
|
||||||
* ancestor. */
|
* ancestor. */
|
||||||
@ -153,20 +156,28 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
|
|||||||
if (!(arr = virJSONValueNewArray()))
|
if (!(arr = virJSONValueNewArray()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, node, chkdisk->bitmap) < 0)
|
if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr,
|
||||||
|
domdisk->src->nodeformat,
|
||||||
|
chkdisk->bitmap) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (chkcurrent) {
|
if (chkcurrent) {
|
||||||
if (qemuMonitorTransactionBitmapEnable(actions, node, disk2->bitmap) < 0)
|
if (qemuMonitorTransactionBitmapEnable(actions,
|
||||||
|
domdisk->src->nodeformat,
|
||||||
|
disk2->bitmap) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorTransactionBitmapMerge(actions, node, disk2->bitmap, &arr) < 0)
|
if (qemuMonitorTransactionBitmapMerge(actions,
|
||||||
|
domdisk->src->nodeformat,
|
||||||
|
disk2->bitmap, &arr) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorTransactionBitmapRemove(actions, node, chkdisk->bitmap) < 0)
|
if (qemuMonitorTransactionBitmapRemove(actions,
|
||||||
|
domdisk->src->nodeformat,
|
||||||
|
chkdisk->bitmap) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user