libvirt/SOURCES/libvirt-qemu-checkpoint-tolerate-missing-disks-on-checkpoint-deletion.patch
2021-10-08 13:11:20 +00:00

86 lines
3.6 KiB
Diff

From d59261d209da6f3dd4dfef7fab327de7cbb6e7ff Mon Sep 17 00:00:00 2001
Message-Id: <d59261d209da6f3dd4dfef7fab327de7cbb6e7ff@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 4 Feb 2020 15:07:54 +0100
Subject: [PATCH] qemu: checkpoint: tolerate missing disks on checkpoint
deletion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
(cherry picked from commit f19248a1395e59abbd68ac31af3d9bd1273555bf)
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
Message-Id: <bab5a0f3d17855a657a6b7de4699a72e176780d6.1580824112.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_checkpoint.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 03a8321135..326707e098 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -125,12 +125,15 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
for (i = 0; i < chkdef->ndisks; 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)
continue;
- node = qemuDomainDiskNodeFormatLookup(vm, chkdisk->name);
/* If any ancestor checkpoint has a bitmap for the same
* disk, then this bitmap must be merged to the
* ancestor. */
@@ -153,20 +156,28 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
if (!(arr = virJSONValueNewArray()))
return -1;
- if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, node, chkdisk->bitmap) < 0)
+ if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr,
+ domdisk->src->nodeformat,
+ chkdisk->bitmap) < 0)
return -1;
if (chkcurrent) {
- if (qemuMonitorTransactionBitmapEnable(actions, node, disk2->bitmap) < 0)
+ if (qemuMonitorTransactionBitmapEnable(actions,
+ domdisk->src->nodeformat,
+ disk2->bitmap) < 0)
return -1;
}
- if (qemuMonitorTransactionBitmapMerge(actions, node, disk2->bitmap, &arr) < 0)
+ if (qemuMonitorTransactionBitmapMerge(actions,
+ domdisk->src->nodeformat,
+ disk2->bitmap, &arr) < 0)
return -1;
}
}
- if (qemuMonitorTransactionBitmapRemove(actions, node, chkdisk->bitmap) < 0)
+ if (qemuMonitorTransactionBitmapRemove(actions,
+ domdisk->src->nodeformat,
+ chkdisk->bitmap) < 0)
return -1;
}
--
2.25.0