[PATCH 26/31] qemu: Use 'format' nodename accessors for block dirty bitmap operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In most cases the bitmap operations are relevant only on qcow2 images
thus the 'format' layer will be present. Although in certain specific
cases temporary bitmaps can be created on top of other images as well,
thus we use the 'effective' bitmap name in all cases for bitmap
operations.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c      | 27 ++++++++++++++-------------
 src/qemu/qemu_blockjob.c   |  4 ++--
 src/qemu/qemu_checkpoint.c |  9 +++++----
 src/qemu/qemu_driver.c     |  7 ++++---
 src/qemu/qemu_snapshot.c   |  6 ++++--
 5 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 4c1a711dd3..edc8edcb70 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2807,7 +2807,8 @@ qemuBlockNamedNodeDataGetBitmapByName(GHashTable *blockNamedNodeData,
     qemuBlockNamedNodeData *nodedata;
     size_t i;

-    if (!(nodedata = virHashLookup(blockNamedNodeData, src->nodeformat)))
+    if (!(nodedata = virHashLookup(blockNamedNodeData,
+                                   qemuBlockStorageSourceGetEffectiveNodename(src))))
         return NULL;

     for (i = 0; i < nodedata->nbitmaps; i++) {
@@ -2863,7 +2864,7 @@ qemuBlockGetBitmapMergeActionsGetBitmaps(virStorageSource *topsrc,
     /* for now it doesn't make sense to consider bitmaps which are not present
      * in @topsrc as we can't recreate a bitmap for a layer if it's missing */

-    if (!(entry = virHashLookup(blockNamedNodeData, topsrc->nodeformat)))
+    if (!(entry = virHashLookup(blockNamedNodeData, qemuBlockStorageSourceGetEffectiveNodename(topsrc))))
         return NULL;

     for (i = 0; i < entry->nbitmaps; i++) {
@@ -2972,7 +2973,7 @@ qemuBlockGetBitmapMergeActions(virStorageSource *topsrc,
                 granularity = bitmap->granularity;

             if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(merge,
-                                                                 n->nodeformat,
+                                                                 qemuBlockStorageSourceGetEffectiveNodename(n),
                                                                  bitmap->name) < 0)
                 return -1;
         }
@@ -2982,7 +2983,7 @@ qemuBlockGetBitmapMergeActions(virStorageSource *topsrc,
                                                              target, curbitmap))) {

             if (qemuMonitorTransactionBitmapAdd(act,
-                                                target->nodeformat,
+                                                qemuBlockStorageSourceGetEffectiveNodename(target),
                                                 mergebitmapname,
                                                 mergebitmappersistent,
                                                 mergebitmapdisabled,
@@ -2992,18 +2993,18 @@ qemuBlockGetBitmapMergeActions(virStorageSource *topsrc,

         if (writebitmapsrc &&
             qemuMonitorTransactionBitmapMergeSourceAddBitmap(merge,
-                                                             writebitmapsrc->nodeformat,
+                                                             qemuBlockStorageSourceGetEffectiveNodename(writebitmapsrc),
                                                              "libvirt-tmp-activewrite") < 0)
             return -1;

-        if (qemuMonitorTransactionBitmapMerge(act, target->nodeformat,
+        if (qemuMonitorTransactionBitmapMerge(act, qemuBlockStorageSourceGetEffectiveNodename(target),
                                               mergebitmapname, &merge) < 0)
             return -1;
     }

  done:
     if (writebitmapsrc &&
-        qemuMonitorTransactionBitmapRemove(act, writebitmapsrc->nodeformat,
+        qemuMonitorTransactionBitmapRemove(act, qemuBlockStorageSourceGetEffectiveNodename(writebitmapsrc),
                                            "libvirt-tmp-activewrite") < 0)
         return -1;

@@ -3578,8 +3579,8 @@ qemuBlockCommit(virDomainObj *vm,
     rc = qemuMonitorBlockCommit(priv->mon,
                                 qemuDomainDiskGetTopNodename(disk),
                                 job->name,
-                                topSource->nodeformat,
-                                baseSource->nodeformat,
+                                qemuBlockStorageSourceGetEffectiveNodename(topSource),
+                                qemuBlockStorageSourceGetEffectiveNodename(baseSource),
                                 backingPath, bandwidth,
                                 autofinalize);

@@ -3663,7 +3664,7 @@ qemuBlockPivot(virDomainObj *vm,
             bitmapactions = virJSONValueNewArray();

             if (qemuMonitorTransactionBitmapAdd(bitmapactions,
-                                                disk->mirror->nodeformat,
+                                                qemuBlockStorageSourceGetEffectiveNodename(disk->mirror),
                                                 "libvirt-tmp-activewrite",
                                                 false,
                                                 false,
@@ -3684,8 +3685,8 @@ qemuBlockPivot(virDomainObj *vm,
                 reopenactions = virJSONValueNewArray();

                 if (qemuMonitorTransactionSnapshotBlockdev(reopenactions,
-                                                           disk->mirror->backingStore->nodeformat,
-                                                           disk->mirror->nodeformat))
+                                                           qemuBlockStorageSourceGetEffectiveNodename(disk->mirror->backingStore),
+                                                           qemuBlockStorageSourceGetFormatNodename(disk->mirror)))
                     return -1;
             }

@@ -3696,7 +3697,7 @@ qemuBlockPivot(virDomainObj *vm,
         bitmapactions = virJSONValueNewArray();

         if (qemuMonitorTransactionBitmapAdd(bitmapactions,
-                                            job->data.commit.base->nodeformat,
+                                            qemuBlockStorageSourceGetEffectiveNodename(job->data.commit.base),
                                             "libvirt-tmp-activewrite",
                                             false,
                                             false,
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index cb9948ae2a..0913a224e3 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -1301,7 +1301,7 @@ qemuBlockJobProcessEventFailedActiveCommit(virQEMUDriver *driver,
         return;

     qemuMonitorBitmapRemove(priv->mon,
-                            disk->mirror->nodeformat,
+                            qemuBlockStorageSourceGetEffectiveNodename(disk->mirror),
                             "libvirt-tmp-activewrite");

     qemuDomainObjExitMonitor(vm);
@@ -1388,7 +1388,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver *driver,

     if (job->data.backup.bitmap)
         qemuMonitorBitmapRemove(qemuDomainGetMonitor(vm),
-                                job->disk->src->nodeformat,
+                                qemuBlockStorageSourceGetEffectiveNodename(job->disk->src),
                                 job->data.backup.bitmap);

     qemuDomainObjExitMonitor(vm);
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 8449ed176a..ca58da8fcb 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -154,7 +154,7 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSource *src,
         found = true;

         if (qemuMonitorTransactionBitmapRemove(actions,
-                                               n->nodeformat,
+                                               qemuBlockStorageSourceGetEffectiveNodename(n),
                                                bitmapdata->name) < 0)
             return -1;

@@ -395,7 +395,8 @@ qemuCheckpointAddActions(virDomainObj *vm,
             chkdisk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
             continue;

-        if (qemuMonitorTransactionBitmapAdd(actions, domdisk->src->nodeformat,
+        if (qemuMonitorTransactionBitmapAdd(actions,
+                                            qemuBlockStorageSourceGetEffectiveNodename(domdisk->src),
                                             chkdisk->bitmap, true, false, 0) < 0)
             return -1;
     }
@@ -704,7 +705,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
                 recoveractions = virJSONValueNewArray();

             if (qemuMonitorTransactionBitmapRemove(recoveractions,
-                                                   domdisk->src->nodeformat,
+                                                   qemuBlockStorageSourceGetEffectiveNodename(domdisk->src),
                                                    "libvirt-tmp-size-xml") < 0)
                 goto endjob;
         }
@@ -718,7 +719,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm,
             goto endjob;

         if (qemuMonitorTransactionBitmapRemove(cleanupactions,
-                                               domdisk->src->nodeformat,
+                                               qemuBlockStorageSourceGetEffectiveNodename(domdisk->src),
                                                "libvirt-tmp-size-xml") < 0)
             goto endjob;
     }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d1d0bb3e2..b286d94ca1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13634,7 +13634,7 @@ qemuDomainBlockPullCommon(virDomainObj *vm,
         goto endjob;

     if (baseSource) {
-        nodebase = baseSource->nodeformat;
+        nodebase = qemuBlockStorageSourceGetEffectiveNodename(baseSource);
         if (!backingPath &&
             !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
             goto endjob;
@@ -13642,7 +13642,7 @@ qemuDomainBlockPullCommon(virDomainObj *vm,

     qemuDomainObjEnterMonitor(vm);
     ret = qemuMonitorBlockStream(priv->mon,
-                                 disk->src->nodeformat,
+                                 qemuBlockStorageSourceGetEffectiveNodename(disk->src),
                                  job->name,
                                  nodebase,
                                  backingPath,
@@ -14327,7 +14327,8 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,

     ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
                                     qemuDomainDiskGetTopNodename(disk),
-                                    mirror->nodeformat, bandwidth,
+                                    qemuBlockStorageSourceGetEffectiveNodename(mirror),
+                                    bandwidth,
                                     granularity, buf_size, mirror_shallow,
                                     syncWrites);

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index e52d264826..1962ba4027 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -959,7 +959,8 @@ qemuSnapshotDiskBitmapsPropagate(qemuSnapshotDiskData *dd,
     qemuBlockNamedNodeData *entry;
     size_t i;

-    if (!(entry = virHashLookup(blockNamedNodeData, dd->disk->src->nodeformat)))
+    if (!(entry = virHashLookup(blockNamedNodeData,
+                                qemuBlockStorageSourceGetEffectiveNodename(dd->disk->src))))
         return 0;

     for (i = 0; i < entry->nbitmaps; i++) {
@@ -969,7 +970,8 @@ qemuSnapshotDiskBitmapsPropagate(qemuSnapshotDiskData *dd,
         if (!bitmap->persistent || !bitmap->recording || bitmap->inconsistent)
             continue;

-        if (qemuMonitorTransactionBitmapAdd(actions, dd->src->nodeformat,
+        if (qemuMonitorTransactionBitmapAdd(actions,
+                                            qemuBlockStorageSourceGetEffectiveNodename(dd->src),
                                             bitmap->name, true, false,
                                             bitmap->granularity) < 0)
             return -1;
-- 
2.41.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux