mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu: monitor: Extract call of 'query-blockstats' and add new API for it
Allow getting the raw data from query-blockstats, so that we can use it to detect the backing chain later on. Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
43e6686c7f
commit
51d243bdbf
@ -2241,6 +2241,21 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuMonitorQueryBlockstats:
|
||||
* @mon: monitor object
|
||||
*
|
||||
* Returns data from a call to 'query-blockstats'.
|
||||
*/
|
||||
virJSONValuePtr
|
||||
qemuMonitorQueryBlockstats(qemuMonitorPtr mon)
|
||||
{
|
||||
QEMU_CHECK_MONITOR_JSON_NULL(mon);
|
||||
|
||||
return qemuMonitorJSONQueryBlockstats(mon);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuMonitorGetAllBlockStatsInfo:
|
||||
* @mon: monitor object
|
||||
|
@ -523,6 +523,8 @@ int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
||||
int qemuMonitorBlockIOStatusToError(const char *status);
|
||||
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);
|
||||
|
||||
virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon);
|
||||
|
||||
typedef struct _qemuBlockStats qemuBlockStats;
|
||||
typedef qemuBlockStats *qemuBlockStatsPtr;
|
||||
struct _qemuBlockStats {
|
||||
|
@ -2061,6 +2061,35 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev,
|
||||
}
|
||||
|
||||
|
||||
virJSONValuePtr
|
||||
qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon)
|
||||
{
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
virJSONValuePtr ret = NULL;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("query-blockstats", NULL)))
|
||||
return NULL;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(ret = virJSONValueObjectStealArray(reply, "return"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("query-blockstats reply was missing device list"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
|
||||
virHashTablePtr hash,
|
||||
@ -2070,25 +2099,11 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
|
||||
int nstats = 0;
|
||||
int rc;
|
||||
size_t i;
|
||||
virJSONValuePtr cmd;
|
||||
virJSONValuePtr reply = NULL;
|
||||
virJSONValuePtr devices;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("query-blockstats", NULL)))
|
||||
if (!(devices = qemuMonitorJSONQueryBlockstats(mon)))
|
||||
return -1;
|
||||
|
||||
if ((rc = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("blockstats reply was missing device list"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < virJSONValueArraySize(devices); i++) {
|
||||
virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
|
||||
const char *dev_name;
|
||||
@ -2120,8 +2135,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
|
||||
ret = nstats;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
virJSONValueFree(devices);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,8 @@ int qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
||||
int period);
|
||||
int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
|
||||
virHashTablePtr table);
|
||||
|
||||
virJSONValuePtr qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon);
|
||||
int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
|
||||
virHashTablePtr hash,
|
||||
bool backingChain);
|
||||
|
Loading…
x
Reference in New Issue
Block a user