[PATCH 0/2] qemu: fix crash when deleting a dedefined

Peter Krempa (2): qemuCheckpointDiscardBitmaps: Refuse to delete checkpoint with NULL bitmap name virDomainCheckpointRedefinePrep: Assign default bitmap names when domain XML is missing src/conf/checkpoint_conf.c | 3 +++ src/qemu/qemu_checkpoint.c | 7 +++++++ 2 files changed, 10 insertions(+) -- 2.29.2

When a checkpoint is redefined without providing the domain XML, we might end up with a definition where the per-disk bitmap name is not set. Trying to delete such checkpoint would lead to a crash. Refuse such deletion. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1941600 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_checkpoint.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 689a556959..d2a621a52b 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -206,6 +206,13 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm, if (chkdisk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP) continue; + if (!chkdisk->bitmap) { + virReportError(VIR_ERR_INVALID_ARG, + _("missing bitmap name for disk '%s' of checkpoint '%s'"), + chkdisk->name, chkdef->parent.name); + return -1; + } + if (qemuCheckpointDiscardDiskBitmaps(domdisk->src, blockNamedNodeData, chkdisk->bitmap, actions, domdisk->dst, -- 2.29.2

Previously we'd assign the default checkpoint bitmap names in virDomainCheckpointAlignDisks. In cases when the checkpoint is redefined without a domain XML virDomainCheckpointAlignDisks is not called. Add an explicit call to virDomainCheckpointDefAssignBitmapNames to restore functionality. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/checkpoint_conf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index f8704852e0..cd48570b51 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -508,6 +508,9 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, if (virDomainCheckpointAlignDisks(def) < 0) return -1; + } else { + if (virDomainCheckpointDefAssignBitmapNames(def) < 0) + return -1; } if (def->parent.parent_name && -- 2.29.2

On a Monday in 2021, Peter Krempa wrote:
Peter Krempa (2): qemuCheckpointDiscardBitmaps: Refuse to delete checkpoint with NULL bitmap name virDomainCheckpointRedefinePrep: Assign default bitmap names when domain XML is missing
src/conf/checkpoint_conf.c | 3 +++ src/qemu/qemu_checkpoint.c | 7 +++++++ 2 files changed, 10 insertions(+)
Deviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa