mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
cputune_event: queue the event for cputune updates
Now we have universal tunable event so we can use it for reporting changes to user. The cputune values will be prefixed with "cputune" to distinguish it from other tunable events. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
9e734ab73e
commit
0dce260cc8
@ -5203,6 +5203,66 @@ typedef void (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
|
|||||||
const char *devAlias,
|
const char *devAlias,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN:
|
||||||
|
*
|
||||||
|
* Macro represents formatted pinning for one vcpu specified by id which is
|
||||||
|
* appended to the parameter name, for example "cputune.vcpupin1",
|
||||||
|
* as VIR_TYPED_PARAM_STRING.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN "cputune.vcpupin%u"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN:
|
||||||
|
*
|
||||||
|
* Macro represents formatted pinning for emulator process,
|
||||||
|
* as VIR_TYPED_PARAM_STRING.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN "cputune.emulatorpin"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES:
|
||||||
|
*
|
||||||
|
* Macro represents proportional weight of the scheduler used on the
|
||||||
|
* host cpu, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES "cputune.cpu_shares"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD:
|
||||||
|
*
|
||||||
|
* Macro represents the enforcement period for a quota, in microseconds,
|
||||||
|
* for vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD "cputune.vcpu_period"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA:
|
||||||
|
*
|
||||||
|
* Macro represents the maximum bandwidth to be used within a period for
|
||||||
|
* vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA "cputune.vcpu_quota"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD:
|
||||||
|
*
|
||||||
|
* Macro represents the enforcement period for a quota in microseconds,
|
||||||
|
* when using the posix scheduler, for all emulator activity not tied to
|
||||||
|
* vcpus, as VIR_TYPED_PARAM_ULLONG.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD "cputune.emulator_period"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA:
|
||||||
|
*
|
||||||
|
* Macro represents the maximum bandwidth to be used within a period for
|
||||||
|
* all emulator activity not tied to vcpus, when using the posix scheduler,
|
||||||
|
* as an VIR_TYPED_PARAM_LLONG.
|
||||||
|
*/
|
||||||
|
#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA "cputune.emulator_quota"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virConnectDomainEventTunableCallback:
|
* virConnectDomainEventTunableCallback:
|
||||||
* @conn: connection object
|
* @conn: connection object
|
||||||
@ -5215,6 +5275,9 @@ typedef void (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
|
|||||||
* be freed in the callback handler as it's done internally after the callback
|
* be freed in the callback handler as it's done internally after the callback
|
||||||
* handler is executed.
|
* handler is executed.
|
||||||
*
|
*
|
||||||
|
* Currently supported name spaces:
|
||||||
|
* "cputune.*"
|
||||||
|
*
|
||||||
* The callback signature to use when registering for an event of type
|
* The callback signature to use when registering for an event of type
|
||||||
* VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
|
* VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "virscsi.h"
|
#include "virscsi.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
|
#include "virtypedparam.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||||
|
|
||||||
@ -676,6 +677,10 @@ static int
|
|||||||
qemuSetupCpuCgroup(virDomainObjPtr vm)
|
qemuSetupCpuCgroup(virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
virObjectEventPtr event = NULL;
|
||||||
|
virTypedParameterPtr eventParams = NULL;
|
||||||
|
int eventNparams = 0;
|
||||||
|
int eventMaxparams = 0;
|
||||||
|
|
||||||
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
|
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
|
||||||
if (vm->def->cputune.sharesSpecified) {
|
if (vm->def->cputune.sharesSpecified) {
|
||||||
@ -694,7 +699,19 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
|
|||||||
|
|
||||||
if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (vm->def->cputune.shares != val) {
|
||||||
vm->def->cputune.shares = val;
|
vm->def->cputune.shares = val;
|
||||||
|
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
||||||
|
&eventMaxparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
|
||||||
|
val) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event)
|
||||||
|
qemuDomainEventQueue(vm->privateData, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4538,6 +4538,12 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
virBitmapPtr pcpumap = NULL;
|
virBitmapPtr pcpumap = NULL;
|
||||||
virQEMUDriverConfigPtr cfg = NULL;
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
|
virObjectEventPtr event = NULL;
|
||||||
|
char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = "";
|
||||||
|
char *str = NULL;
|
||||||
|
virTypedParameterPtr eventParams = NULL;
|
||||||
|
int eventNparams = 0;
|
||||||
|
int eventMaxparams = 0;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
||||||
@ -4645,6 +4651,18 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN, vcpu) < 0) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = virBitmapFormat(pcpumap);
|
||||||
|
if (virTypedParamsAddString(&eventParams, &eventNparams,
|
||||||
|
&eventMaxparams, paramField, str) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
@ -4680,6 +4698,9 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
virCgroupFree(&cgroup_vcpu);
|
virCgroupFree(&cgroup_vcpu);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
if (event)
|
||||||
|
qemuDomainEventQueue(driver, event);
|
||||||
|
VIR_FREE(str);
|
||||||
virBitmapFree(pcpumap);
|
virBitmapFree(pcpumap);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
@ -4804,6 +4825,12 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
|||||||
virBitmapPtr pcpumap = NULL;
|
virBitmapPtr pcpumap = NULL;
|
||||||
virQEMUDriverConfigPtr cfg = NULL;
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
|
virObjectEventPtr event = NULL;
|
||||||
|
char * str = NULL;
|
||||||
|
virTypedParameterPtr eventParams = NULL;
|
||||||
|
int eventNparams = 0;
|
||||||
|
int eventMaxparams = 0;
|
||||||
|
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
||||||
@ -4909,6 +4936,15 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
|||||||
|
|
||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
str = virBitmapFormat(pcpumap);
|
||||||
|
if (virTypedParamsAddString(&eventParams, &eventNparams,
|
||||||
|
&eventMaxparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN,
|
||||||
|
str) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
@ -4938,6 +4974,9 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (cgroup_emulator)
|
if (cgroup_emulator)
|
||||||
virCgroupFree(&cgroup_emulator);
|
virCgroupFree(&cgroup_emulator);
|
||||||
|
if (event)
|
||||||
|
qemuDomainEventQueue(driver, event);
|
||||||
|
VIR_FREE(str);
|
||||||
virBitmapFree(pcpumap);
|
virBitmapFree(pcpumap);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -9202,6 +9241,10 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
virQEMUDriverConfigPtr cfg = NULL;
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
|
virObjectEventPtr event = NULL;
|
||||||
|
virTypedParameterPtr eventParams = NULL;
|
||||||
|
int eventNparams = 0;
|
||||||
|
int eventMaxNparams = 0;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
||||||
@ -9272,6 +9315,12 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
vm->def->cputune.shares = val;
|
vm->def->cputune.shares = val;
|
||||||
vm->def->cputune.sharesSpecified = true;
|
vm->def->cputune.sharesSpecified = true;
|
||||||
|
|
||||||
|
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
||||||
|
&eventMaxNparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
|
||||||
|
val) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
@ -9289,6 +9338,12 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
vm->def->cputune.period = value_ul;
|
vm->def->cputune.period = value_ul;
|
||||||
|
|
||||||
|
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
||||||
|
&eventMaxNparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD,
|
||||||
|
value_ul) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
||||||
@ -9303,6 +9358,12 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
vm->def->cputune.quota = value_l;
|
vm->def->cputune.quota = value_l;
|
||||||
|
|
||||||
|
if (virTypedParamsAddLLong(&eventParams, &eventNparams,
|
||||||
|
&eventMaxNparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA,
|
||||||
|
value_l) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
||||||
@ -9318,6 +9379,12 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
vm->def->cputune.emulator_period = value_ul;
|
vm->def->cputune.emulator_period = value_ul;
|
||||||
|
|
||||||
|
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
||||||
|
&eventMaxNparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD,
|
||||||
|
value_ul) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
||||||
@ -9333,6 +9400,12 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
vm->def->cputune.emulator_quota = value_l;
|
vm->def->cputune.emulator_quota = value_l;
|
||||||
|
|
||||||
|
if (virTypedParamsAddLLong(&eventParams, &eventNparams,
|
||||||
|
&eventMaxNparams,
|
||||||
|
VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA,
|
||||||
|
value_l) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
||||||
@ -9343,6 +9416,12 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (eventNparams) {
|
||||||
|
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
||||||
|
eventNparams = 0;
|
||||||
|
if (event)
|
||||||
|
qemuDomainEventQueue(driver, event);
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||||
rc = virDomainSaveConfig(cfg->configDir, vmdef);
|
rc = virDomainSaveConfig(cfg->configDir, vmdef);
|
||||||
@ -9359,6 +9438,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
virDomainDefFree(vmdef);
|
virDomainDefFree(vmdef);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
if (eventNparams)
|
||||||
|
virTypedParamsFree(eventParams, eventNparams);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user