render / rpms / libvirt

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