This function looks up a named bitmap for a virStorageSource in the data
returned from query-named-block-nodes.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 32 ++++++++++++++++++++++++++++++++
src/qemu/qemu_block.h | 5 +++++
2 files changed, 37 insertions(+)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index ada2c52947..629a09b897 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2612,3 +2612,35 @@ qemuBlockRemoveImageMetadata(virQEMUDriverPtr driver,
return ret;
}
+
+
+/**
+ * qemuBlockNamedNodeDataGetBitmapByName:
+ * @blockNamedNodeData: hash table returned by qemuMonitorBlockGetNamedNodeData
+ * @src: disk source to find the bitmap for
+ * @bitmap: name of the bitmap to find
+ *
+ * Looks up a bitmap named @bitmap of the @src image.
+ */
+qemuBlockNamedNodeDataBitmapPtr
+qemuBlockNamedNodeDataGetBitmapByName(virHashTablePtr blockNamedNodeData,
+ virStorageSourcePtr src,
+ const char *bitmap)
+{
+ qemuBlockNamedNodeDataPtr nodedata;
+ size_t i;
+
+ if (!(nodedata = virHashLookup(blockNamedNodeData, src->nodeformat)))
+ return NULL;
+
+ for (i = 0; i < nodedata->nbitmaps; i++) {
+ qemuBlockNamedNodeDataBitmapPtr bitmapdata = nodedata->bitmaps[i];
+
+ if (STRNEQ(bitmapdata->name, bitmap))
+ continue;
+
+ return bitmapdata;
+ }
+
+ return NULL;
+}
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index 5854641027..1a38e0eccf 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -203,3 +203,8 @@ qemuBlockRemoveImageMetadata(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *diskTarget,
virStorageSourcePtr src);
+
+qemuBlockNamedNodeDataBitmapPtr
+qemuBlockNamedNodeDataGetBitmapByName(virHashTablePtr blockNamedNodeData,
+ virStorageSourcePtr src,
+ const char *bitmap);
--
2.23.0