mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu: monitor: Add APIs for refreshing disk capacity when using -blockdev
Disk image size data are not contained in the reply of query-blockstats but need to be gathered from query-block. For use with -blockdev we really need to call 'query-named-block-nodes' and process it to retrieve the correct data. This patch introduces qemuMonitorBlockStatsUpdateCapacityBlockdev which updates the capacity data by nodename rather than device name. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d703306cd9
commit
d593814a9d
@ -2311,6 +2311,17 @@ qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
|
||||
virHashTablePtr stats)
|
||||
{
|
||||
VIR_DEBUG("stats=%p", stats);
|
||||
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
|
||||
return qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(mon, stats);
|
||||
}
|
||||
|
||||
int
|
||||
qemuMonitorBlockResize(qemuMonitorPtr mon,
|
||||
const char *device,
|
||||
|
@ -599,6 +599,10 @@ int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
|
||||
bool backingChain)
|
||||
ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
|
||||
virHashTablePtr stats)
|
||||
ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int qemuMonitorBlockResize(qemuMonitorPtr mon,
|
||||
const char *device,
|
||||
const char *nodename,
|
||||
|
@ -2593,6 +2593,52 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWorker(size_t pos ATTRIBUTE_UNUSED,
|
||||
virJSONValuePtr val,
|
||||
void *opaque)
|
||||
{
|
||||
virHashTablePtr stats = opaque;
|
||||
virJSONValuePtr image;
|
||||
const char *nodename;
|
||||
|
||||
if (!(nodename = virJSONValueObjectGetString(val, "node-name")) ||
|
||||
!(image = virJSONValueObjectGetObject(val, "image"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("query-named-block-nodes entry was not in expected format"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuMonitorJSONBlockStatsUpdateCapacityData(image, nodename, stats) < 0)
|
||||
return -1;
|
||||
|
||||
return 1; /* we don't want to steal the value from the JSON array */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
|
||||
virHashTablePtr stats)
|
||||
{
|
||||
virJSONValuePtr nodes;
|
||||
int ret = -1;
|
||||
|
||||
if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon)))
|
||||
return -1;
|
||||
|
||||
if (virJSONValueArrayForeachSteal(nodes,
|
||||
qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWorker,
|
||||
stats) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(nodes);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
|
||||
const char *device,
|
||||
const char *nodename,
|
||||
|
@ -93,6 +93,9 @@ int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
|
||||
int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
|
||||
virHashTablePtr stats,
|
||||
bool backingChain);
|
||||
int qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
|
||||
virHashTablePtr stats);
|
||||
|
||||
int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
|
||||
const char *device,
|
||||
const char *nodename,
|
||||
|
Loading…
x
Reference in New Issue
Block a user