mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
qemu: block: Rename qemuBlockFillNodeData and move it to the top
The same operation will become useful in other places so rename the function to be more generic and move it to the top so that it can be reused earlier in the file. Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
f0cbe201b8
commit
4a58dfc24e
@ -27,6 +27,24 @@
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockNamedNodesArrayToHash(size_t pos ATTRIBUTE_UNUSED,
|
||||
virJSONValuePtr item,
|
||||
void *opaque)
|
||||
{
|
||||
virHashTablePtr table = opaque;
|
||||
const char *name;
|
||||
|
||||
if (!(name = virJSONValueObjectGetString(item, "node-name")))
|
||||
return 1;
|
||||
|
||||
if (virHashAddEntry(table, name, item) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data)
|
||||
{
|
||||
@ -384,24 +402,6 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBlockFillNodeData(size_t pos ATTRIBUTE_UNUSED,
|
||||
virJSONValuePtr item,
|
||||
void *opaque)
|
||||
{
|
||||
virHashTablePtr table = opaque;
|
||||
const char *name;
|
||||
|
||||
if (!(name = virJSONValueObjectGetString(item, "node-name")))
|
||||
return 1;
|
||||
|
||||
if (virHashAddEntry(table, name, item) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuBlockGetNodeData:
|
||||
* @data: JSON object returned from query-named-block-nodes
|
||||
@ -419,7 +419,8 @@ qemuBlockGetNodeData(virJSONValuePtr data)
|
||||
if (!(ret = virHashCreate(50, virJSONValueHashFree)))
|
||||
return NULL;
|
||||
|
||||
if (virJSONValueArrayForeachSteal(data, qemuBlockFillNodeData, ret) < 0)
|
||||
if (virJSONValueArrayForeachSteal(data,
|
||||
qemuBlockNamedNodesArrayToHash, ret) < 0)
|
||||
goto error;
|
||||
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user