mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
qemu: monitor: Add handlers for 'block-latency-histogram-set'
Add QMP monitor code for setting up latency histogram configuration. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
1 parent
237e49127a
commit
ad4830ce68
5 files changed
+108
No files matched your search
@@ -4569,3 +4569,24 @@ qemuMonitorBlockdevSetActive(qemuMonitor *mon,
|
||||
|
||||
return qemuMonitorJSONBlockdevSetActive(mon, nodename, active);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorBlockLatencyHistogramSet(qemuMonitor *mon,
|
||||
const char *id,
|
||||
unsigned int *boundaries,
|
||||
unsigned int *boundaries_read,
|
||||
unsigned int *boundaries_write,
|
||||
unsigned int *boundaries_zone,
|
||||
unsigned int *boundaries_flush)
|
||||
{
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
VIR_DEBUG("id='%s'", id);
|
||||
|
||||
return qemuMonitorJSONBlockLatencyHistogramSet(mon, id,
|
||||
boundaries,
|
||||
boundaries_read,
|
||||
boundaries_write,
|
||||
boundaries_zone,
|
||||
boundaries_flush);
|
||||
}
|
||||
@@ -1985,3 +1985,12 @@ int
|
||||
qemuMonitorBlockdevSetActive(qemuMonitor *mon,
|
||||
const char *nodename,
|
||||
bool active);
|
||||
|
||||
int
|
||||
qemuMonitorBlockLatencyHistogramSet(qemuMonitor *mon,
|
||||
const char *id,
|
||||
unsigned int *boundaries,
|
||||
unsigned int *boundaries_read,
|
||||
unsigned int *boundaries_write,
|
||||
unsigned int *boundaries_zone,
|
||||
unsigned int *boundaries_flush);
|
||||
@@ -9167,3 +9167,63 @@ qemuMonitorJSONBlockdevSetActive(qemuMonitor *mon,
|
||||
|
||||
return qemuMonitorJSONCheckError(cmd, reply);
|
||||
}
|
||||
|
||||
|
||||
static virJSONValue *
|
||||
qemuMonitorJSONBlockLatencyHistogramBoundary(unsigned int *bound)
|
||||
{
|
||||
g_autoptr(virJSONValue) ret = virJSONValueNewArray();
|
||||
|
||||
if (!bound)
|
||||
return NULL;
|
||||
|
||||
for (; *bound > 0; bound++) {
|
||||
g_autoptr(virJSONValue) val = virJSONValueNewNumberUint(*bound);
|
||||
|
||||
/* the only error is if the first argument is not an array */
|
||||
ignore_value(virJSONValueArrayAppend(ret, &val));
|
||||
}
|
||||
|
||||
return g_steal_pointer(&ret);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockLatencyHistogramSet(qemuMonitor *mon,
|
||||
const char *id,
|
||||
unsigned int *boundaries,
|
||||
unsigned int *boundaries_read,
|
||||
unsigned int *boundaries_write,
|
||||
unsigned int *boundaries_zone,
|
||||
unsigned int *boundaries_flush)
|
||||
{
|
||||
g_autoptr(virJSONValue) cmd = NULL;
|
||||
g_autoptr(virJSONValue) reply = NULL;
|
||||
|
||||
g_autoptr(virJSONValue) bound = NULL;
|
||||
g_autoptr(virJSONValue) bound_read = NULL;
|
||||
g_autoptr(virJSONValue) bound_write = NULL;
|
||||
g_autoptr(virJSONValue) bound_zone = NULL;
|
||||
g_autoptr(virJSONValue) bound_flush = NULL;
|
||||
|
||||
bound = qemuMonitorJSONBlockLatencyHistogramBoundary(boundaries);
|
||||
bound_read = qemuMonitorJSONBlockLatencyHistogramBoundary(boundaries_read);
|
||||
bound_write = qemuMonitorJSONBlockLatencyHistogramBoundary(boundaries_write);
|
||||
bound_zone = qemuMonitorJSONBlockLatencyHistogramBoundary(boundaries_zone);
|
||||
bound_flush = qemuMonitorJSONBlockLatencyHistogramBoundary(boundaries_flush);
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("block-latency-histogram-set",
|
||||
"s:id", id,
|
||||
"A:boundaries", &bound,
|
||||
"A:boundaries-read", &bound_read,
|
||||
"A:boundaries-write", &bound_write,
|
||||
"A:boundaries-zap", &bound_zone,
|
||||
"A:boundaries-flush", &bound_flush,
|
||||
NULL)))
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
return -1;
|
||||
|
||||
return qemuMonitorJSONCheckError(cmd, reply);
|
||||
}
|
||||
@@ -818,3 +818,12 @@ int
|
||||
qemuMonitorJSONBlockdevSetActive(qemuMonitor *mon,
|
||||
const char *nodename,
|
||||
bool active);
|
||||
|
||||
int
|
||||
qemuMonitorJSONBlockLatencyHistogramSet(qemuMonitor *mon,
|
||||
const char *id,
|
||||
unsigned int *boundaries,
|
||||
unsigned int *boundaries_read,
|
||||
unsigned int *boundaries_write,
|
||||
unsigned int *boundaries_zone,
|
||||
unsigned int *boundaries_flush);
|
||||
@@ -1130,6 +1130,14 @@ GEN_TEST_FUNC(qemuMonitorJSONSetAction,
|
||||
GEN_TEST_FUNC(qemuMonitorJSONSetLaunchSecurityState, "sev_secret_header",
|
||||
"sev_secret", 0, true)
|
||||
|
||||
unsigned int testHistogramBoundaries[] = {10, 30, 50, 0};
|
||||
GEN_TEST_FUNC(qemuMonitorJSONBlockLatencyHistogramSet, "devid",
|
||||
testHistogramBoundaries,
|
||||
testHistogramBoundaries,
|
||||
testHistogramBoundaries,
|
||||
testHistogramBoundaries,
|
||||
testHistogramBoundaries)
|
||||
|
||||
static int
|
||||
testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque)
|
||||
{
|
||||
@@ -2971,6 +2979,7 @@ mymain(void)
|
||||
DO_TEST_GEN(qemuMonitorJSONBlockJobCancel);
|
||||
DO_TEST_GEN(qemuMonitorJSONSetAction);
|
||||
DO_TEST_GEN(qemuMonitorJSONSetLaunchSecurityState);
|
||||
DO_TEST_GEN(qemuMonitorJSONBlockLatencyHistogramSet);
|
||||
DO_TEST(qemuMonitorJSONGetBalloonInfo);
|
||||
DO_TEST(qemuMonitorJSONGetBlockInfo);
|
||||
DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo);
|
||||
|
||||
Reference in new issue
Block a user