{
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+ virHashTablePtr blockstats = NULL;
+ qemuBlockStatsPtr stats;
int ret = -1;
- long long rd_req, rd_bytes, rd_total_times;
- long long wr_req, wr_bytes, wr_total_times;
- long long flush_req, flush_total_times;
- int nparams;
unsigned long long extent;
const char *reply =
/* fill in seven times - we are gonna ask seven times later on */
if (qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0 ||
- qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0 ||
- qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0 ||
- qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0 ||
qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0 ||
qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0 ||
qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0)
goto cleanup;
#define CHECK0(var, value) \
- if (var != value) { \
+ if (stats->var != value) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \
"Invalid " #var " value: %lld, expected %d", \
- var, value); \
+ stats->var, value); \
goto cleanup; \
}
-#define CHECK(RD_REQ, RD_BYTES, RD_TOTAL_TIMES, WR_REQ, WR_BYTES, WR_TOTAL_TIMES, \
- FLUSH_REQ, FLUSH_TOTAL_TIMES) \
+#define CHECK(NAME, RD_REQ, RD_BYTES, RD_TOTAL_TIMES, WR_REQ, WR_BYTES, \
+ WR_TOTAL_TIMES, FLUSH_REQ, FLUSH_TOTAL_TIMES) \
+ if (!(stats = virHashLookup(blockstats, NAME))) { \
+ virReportError(VIR_ERR_INTERNAL_ERROR, \
+ "block stats for device '%s' is missing", NAME); \
+ goto cleanup; \
+ } \
CHECK0(rd_req, RD_REQ) \
CHECK0(rd_bytes, RD_BYTES) \
CHECK0(rd_total_times, RD_TOTAL_TIMES) \
CHECK0(flush_req, FLUSH_REQ) \
CHECK0(flush_total_times, FLUSH_TOTAL_TIMES)
- if (qemuMonitorJSONGetBlockStatsInfo(qemuMonitorTestGetMonitor(test), "virtio-disk0",
- &rd_req, &rd_bytes, &rd_total_times,
- &wr_req, &wr_bytes, &wr_total_times,
- &flush_req, &flush_total_times) < 0)
- goto cleanup;
-
- CHECK(1279, 28505088, 640616474, 174, 2845696, 530699221, 0, 0)
-
- if (qemuMonitorJSONGetBlockStatsInfo(qemuMonitorTestGetMonitor(test), "virtio-disk1",
- &rd_req, &rd_bytes, &rd_total_times,
- &wr_req, &wr_bytes, &wr_total_times,
- &flush_req, &flush_total_times) < 0)
+ if (qemuMonitorGetAllBlockStatsInfo(qemuMonitorTestGetMonitor(test),
+ &blockstats, false) < 0)
goto cleanup;
- CHECK(85, 348160, 8232156, 0, 0, 0, 0, 0)
-
- if (qemuMonitorJSONGetBlockStatsInfo(qemuMonitorTestGetMonitor(test), "ide0-1-0",
- &rd_req, &rd_bytes, &rd_total_times,
- &wr_req, &wr_bytes, &wr_total_times,
- &flush_req, &flush_total_times) < 0)
- goto cleanup;
-
- CHECK(16, 49250, 1004952, 0, 0, 0, 0, 0)
-
- if (qemuMonitorJSONGetBlockStatsParamsNumber(qemuMonitorTestGetMonitor(test),
- &nparams) < 0)
- goto cleanup;
-
- if (nparams != 8) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "Invalid number of stats: %d, expected 8",
- nparams);
+ if (!blockstats) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ "qemuMonitorJSONGetBlockStatsInfo didn't return stats");
goto cleanup;
}
+ CHECK("virtio-disk0", 1279, 28505088, 640616474, 174, 2845696, 530699221, 0, 0)
+ CHECK("virtio-disk1", 85, 348160, 8232156, 0, 0, 0, 0, 0)
+ CHECK("ide0-1-0", 16, 49250, 1004952, 0, 0, 0, 0, 0)
+
if (qemuMonitorJSONGetBlockExtent(qemuMonitorTestGetMonitor(test), "virtio-disk0",
&extent) < 0)
goto cleanup;
cleanup:
qemuMonitorTestFree(test);
+ virHashFree(blockstats);
return ret;
}