1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-30 18:50:18 +03:00

qemu: monitor: Add support for ThrottleGroup operations

This change contains QMP requests for ThrottleGroup

* ThrottleGroup is updated through "qemuMonitorJSONUpdateThrottleGroup"
* ThrottleGroup is retrieved through "qemuMonitorJSONGetThrottleGroup"
* ThrottleGroup is deleted by reusing "qemuMonitorDelObject"
* ThrottleGroup is added by reusing "qemuMonitorAddObject"
* "qemuMonitorMakeThrottleGroupLimits" will be used by building qemu cmd as well

Signed-off-by: Chun Feng Wu <danielwuwy@163.com>

* change throttle group config conversions P to U allow zero.
* Apply suggested coding style changes.

Signed-off-by: Harikumar Rajkumar <harirajkumar230@gmail.com>

* Deleted all getter code.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Chun Feng Wu 2025-02-19 22:27:09 +05:30 committed by Peter Krempa
parent 7b4ea19772
commit 8beb51f23d
4 changed files with 100 additions and 0 deletions

View File

@ -3012,6 +3012,27 @@ qemuMonitorGetBlockIoThrottle(qemuMonitor *mon,
}
int
qemuMonitorThrottleGroupLimits(virJSONValue *limits,
const virDomainThrottleGroupDef *group)
{
return qemuMonitorMakeThrottleGroupLimits(limits, group);
}
int
qemuMonitorUpdateThrottleGroup(qemuMonitor *mon,
const char *qomid,
virDomainBlockIoTuneInfo *info)
{
VIR_DEBUG("qomid=%s, info=%p", qomid, info);
QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONUpdateThrottleGroup(mon, qomid, info);
}
int
qemuMonitorVMStatusToPausedReason(const char *status)
{

View File

@ -1075,6 +1075,15 @@ int qemuMonitorGetBlockIoThrottle(qemuMonitor *mon,
const char *qdevid,
virDomainBlockIoTuneInfo *reply);
int
qemuMonitorThrottleGroupLimits(virJSONValue *limits,
const virDomainThrottleGroupDef *group);
int
qemuMonitorUpdateThrottleGroup(qemuMonitor *mon,
const char *qomid,
virDomainBlockIoTuneInfo *info);
int qemuMonitorSystemWakeup(qemuMonitor *mon);
int qemuMonitorGetVersion(qemuMonitor *mon,

View File

@ -4686,6 +4686,67 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
return qemuMonitorJSONBlockIoThrottleInfo(devices, qdevid, reply);
}
int
qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits,
const virDomainThrottleGroupDef *group)
{
if (virJSONValueObjectAdd(&limits,
"U:bps-total", group->total_bytes_sec,
"U:bps-read", group->read_bytes_sec,
"U:bps-write", group->write_bytes_sec,
"U:iops-total", group->total_iops_sec,
"U:iops-read", group->read_iops_sec,
"U:iops-write", group->write_iops_sec,
"U:bps-total-max", group->total_bytes_sec_max,
"U:bps-read-max", group->read_bytes_sec_max,
"U:bps-write-max", group->write_bytes_sec_max,
"U:iops-total-max", group->total_iops_sec_max,
"U:iops-read-max", group->read_iops_sec_max,
"U:iops-write-max", group->write_iops_sec_max,
"U:iops-size", group->size_iops_sec,
"P:bps-total-max-length", group->total_bytes_sec_max_length,
"P:bps-read-max-length", group->read_bytes_sec_max_length,
"P:bps-write-max-length", group->write_bytes_sec_max_length,
"P:iops-total-max-length", group->total_iops_sec_max_length,
"P:iops-read-max-length", group->read_iops_sec_max_length,
"P:iops-write-max-length", group->write_iops_sec_max_length,
NULL) < 0)
return -1;
return 0;
}
int
qemuMonitorJSONUpdateThrottleGroup(qemuMonitor *mon,
const char *qomid,
virDomainBlockIoTuneInfo *info)
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) result = NULL;
g_autoptr(virJSONValue) limits = virJSONValueNewObject();
if (qemuMonitorMakeThrottleGroupLimits(limits, info) < 0)
return -1;
if (!(cmd = qemuMonitorJSONMakeCommand("qom-set",
"s:property", "limits",
"s:path", qomid,
"a:value", &limits,
NULL)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &result) < 0)
return -1;
if (qemuMonitorJSONCheckError(cmd, result) < 0)
return -1;
return 0;
}
int qemuMonitorJSONSystemWakeup(qemuMonitor *mon)
{
g_autoptr(virJSONValue) cmd = NULL;

View File

@ -376,6 +376,15 @@ qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon,
const char *qomid,
virDomainBlockIoTuneInfo *info);
int
qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits,
const virDomainThrottleGroupDef *group);
int
qemuMonitorJSONUpdateThrottleGroup(qemuMonitor *mon,
const char *qomid,
virDomainBlockIoTuneInfo *info);
int
qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon,
const char *qdevid,