render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From d59261d209da6f3dd4dfef7fab327de7cbb6e7ff Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <d59261d209da6f3dd4dfef7fab327de7cbb6e7ff@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 4 Feb 2020 15:07:54 +0100
a41c76
Subject: [PATCH] qemu: checkpoint: tolerate missing disks on checkpoint
a41c76
 deletion
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
If a disk is unplugged and then the user tries to delete a checkpoint
a41c76
the code would try to use NULL node name as it was not checked.
a41c76
a41c76
Fix this by fetching the whole disk definition object and verifying it
a41c76
was found.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit f19248a1395e59abbd68ac31af3d9bd1273555bf)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
a41c76
Message-Id: <bab5a0f3d17855a657a6b7de4699a72e176780d6.1580824112.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_checkpoint.c | 23 +++++++++++++++++------
a41c76
 1 file changed, 17 insertions(+), 6 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
a41c76
index 03a8321135..326707e098 100644
a41c76
--- a/src/qemu/qemu_checkpoint.c
a41c76
+++ b/src/qemu/qemu_checkpoint.c
a41c76
@@ -125,12 +125,15 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
a41c76
 
a41c76
     for (i = 0; i < chkdef->ndisks; i++) {
a41c76
         virDomainCheckpointDiskDef *chkdisk = &chkdef->disks[i];
a41c76
-        const char *node;
a41c76
+        virDomainDiskDefPtr domdisk = virDomainDiskByTarget(vm->def, chkdisk->name);
a41c76
+
a41c76
+        /* domdisk can be missing e.g. when it was unplugged */
a41c76
+        if (!domdisk)
a41c76
+            continue;
a41c76
 
a41c76
         if (chkdisk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
a41c76
             continue;
a41c76
 
a41c76
-        node = qemuDomainDiskNodeFormatLookup(vm, chkdisk->name);
a41c76
         /* If any ancestor checkpoint has a bitmap for the same
a41c76
          * disk, then this bitmap must be merged to the
a41c76
          * ancestor. */
a41c76
@@ -153,20 +156,28 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
a41c76
                 if (!(arr = virJSONValueNewArray()))
a41c76
                     return -1;
a41c76
 
a41c76
-                if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr, node, chkdisk->bitmap) < 0)
a41c76
+                if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr,
a41c76
+                                                                     domdisk->src->nodeformat,
a41c76
+                                                                     chkdisk->bitmap) < 0)
a41c76
                     return -1;
a41c76
 
a41c76
                 if (chkcurrent) {
a41c76
-                    if (qemuMonitorTransactionBitmapEnable(actions, node, disk2->bitmap) < 0)
a41c76
+                    if (qemuMonitorTransactionBitmapEnable(actions,
a41c76
+                                                           domdisk->src->nodeformat,
a41c76
+                                                           disk2->bitmap) < 0)
a41c76
                         return -1;
a41c76
                 }
a41c76
 
a41c76
-                if (qemuMonitorTransactionBitmapMerge(actions, node, disk2->bitmap, &arr) < 0)
a41c76
+                if (qemuMonitorTransactionBitmapMerge(actions,
a41c76
+                                                      domdisk->src->nodeformat,
a41c76
+                                                      disk2->bitmap, &arr) < 0)
a41c76
                     return -1;
a41c76
             }
a41c76
         }
a41c76
 
a41c76
-        if (qemuMonitorTransactionBitmapRemove(actions, node, chkdisk->bitmap) < 0)
a41c76
+        if (qemuMonitorTransactionBitmapRemove(actions,
a41c76
+                                               domdisk->src->nodeformat,
a41c76
+                                               chkdisk->bitmap) < 0)
a41c76
             return -1;
a41c76
     }
a41c76
 
a41c76
-- 
a41c76
2.25.0
a41c76