[libvirt] [RFC PATCH 06/16] qemu: checkpoint: tolerate missing disks on checkpoint deletion

Peter Krempa pkrempa at redhat.com
Thu Jan 9 18:21:12 UTC 2020


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 at 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.24.1




More information about the libvir-list mailing list