qemu: block: Introduce qemuBlockNamedNodeDataGetBitmapByName

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@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa 2019-12-05 15:57:30 +01:00
parent 7dfd5d8d81
commit b7f2cd4652
2 changed files with 37 additions and 0 deletions

View File

@ -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;
}

View File

@ -203,3 +203,8 @@ qemuBlockRemoveImageMetadata(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *diskTarget,
virStorageSourcePtr src);
qemuBlockNamedNodeDataBitmapPtr
qemuBlockNamedNodeDataGetBitmapByName(virHashTablePtr blockNamedNodeData,
virStorageSourcePtr src,
const char *bitmap);