mirror of https://gitee.com/openkylin/libvirt.git
qemu: stats: Display the block threshold size in bulk stats
Management tools may want to check whether the threshold is still set if they missed an event. Add the data to the bulk stats API where they can also query the current backing size at the same time.
This commit is contained in:
parent
51c4b744d8
commit
91c3d430c9
|
@ -11206,6 +11206,9 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
|
|||
* backing image as unsigned long long.
|
||||
* "block.<num>.physical" - physical size in bytes of the container of the
|
||||
* backing image as unsigned long long.
|
||||
* "block.<num>.threshold" - current threshold for delivering the
|
||||
* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
|
||||
* event in bytes. See virDomainSetBlockThreshold.
|
||||
*
|
||||
* VIR_DOMAIN_STATS_PERF:
|
||||
* Return perf event statistics.
|
||||
|
|
|
@ -19206,6 +19206,32 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver,
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainGetStatsOneBlockNode(virDomainStatsRecordPtr record,
|
||||
int *maxparams,
|
||||
virStorageSourcePtr src,
|
||||
size_t block_idx,
|
||||
virHashTablePtr nodedata)
|
||||
{
|
||||
virJSONValuePtr data;
|
||||
unsigned long long tmp;
|
||||
int ret = -1;
|
||||
|
||||
if (src->nodebacking &&
|
||||
(data = virHashLookup(nodedata, src->nodebacking))) {
|
||||
if (virJSONValueObjectGetNumberUlong(data, "write_threshold", &tmp) == 0 &&
|
||||
tmp > 0)
|
||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
||||
"threshold", tmp);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
|
@ -19216,7 +19242,8 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
|||
virStorageSourcePtr src,
|
||||
size_t block_idx,
|
||||
unsigned int backing_idx,
|
||||
virHashTablePtr stats)
|
||||
virHashTablePtr stats,
|
||||
virHashTablePtr nodedata)
|
||||
{
|
||||
qemuBlockStats *entry;
|
||||
int ret = -1;
|
||||
|
@ -19285,6 +19312,10 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
|||
}
|
||||
}
|
||||
|
||||
if (qemuDomainGetStatsOneBlockNode(record, maxparams, src, block_idx,
|
||||
nodedata) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(alias);
|
||||
|
@ -19303,8 +19334,12 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|||
int ret = -1;
|
||||
int rc;
|
||||
virHashTablePtr stats = NULL;
|
||||
virHashTablePtr nodestats = NULL;
|
||||
virJSONValuePtr nodedata = NULL;
|
||||
qemuDomainObjPrivatePtr priv = dom->privateData;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
bool fetchnodedata = virQEMUCapsGet(priv->qemuCaps,
|
||||
QEMU_CAPS_QUERY_NAMED_BLOCK_NODES);
|
||||
int count_index = -1;
|
||||
size_t visited = 0;
|
||||
bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING);
|
||||
|
@ -19316,14 +19351,22 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|||
if (rc >= 0)
|
||||
ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats,
|
||||
visitBacking));
|
||||
|
||||
if (fetchnodedata)
|
||||
nodedata = qemuMonitorQueryNamedBlockNodes(priv->mon);
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, dom) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* failure to retrieve stats is fine at this point */
|
||||
if (rc < 0)
|
||||
if (rc < 0 || (fetchnodedata && !nodedata))
|
||||
virResetLastError();
|
||||
}
|
||||
|
||||
if (nodedata &&
|
||||
!(nodestats = qemuBlockGetNodeData(nodedata)))
|
||||
goto cleanup;
|
||||
|
||||
/* When listing backing chains, it's easier to fix up the count
|
||||
* after the iteration than it is to iterate twice; but we still
|
||||
* want count listed first. */
|
||||
|
@ -19338,7 +19381,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|||
while (src && (backing_idx == 0 || visitBacking)) {
|
||||
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, record, maxparams,
|
||||
disk, src, visited, backing_idx,
|
||||
stats) < 0)
|
||||
stats, nodestats) < 0)
|
||||
goto cleanup;
|
||||
visited++;
|
||||
backing_idx++;
|
||||
|
@ -19351,6 +19394,8 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|||
|
||||
cleanup:
|
||||
virHashFree(stats);
|
||||
virHashFree(nodestats);
|
||||
virJSONValueFree(nodedata);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1005,6 +1005,9 @@ Information listed includes:
|
|||
"block.<num>.allocation" - offset of highest written sector in bytes
|
||||
"block.<num>.capacity" - logical size of source file in bytes
|
||||
"block.<num>.physical" - physical size of source file in bytes
|
||||
"block.<num>.threshold" - threshold (in bytes) for delivering the
|
||||
VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event
|
||||
See domblkthreshold.
|
||||
|
||||
Selecting a specific statistics groups doesn't guarantee that the
|
||||
daemon supports the selected group of stats. Flag I<--enforce>
|
||||
|
|
Loading…
Reference in New Issue