[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 4/4] cputune_event: queue the event for cputune updates




On 08/28/2014 02:38 PM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina redhat com>
> ---
>  src/qemu/qemu_cgroup.c |  6 ++++++
>  src/qemu/qemu_driver.c | 27 +++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> index 43d14d4..95cc4d4 100644
> --- a/src/qemu/qemu_cgroup.c
> +++ b/src/qemu/qemu_cgroup.c
> @@ -676,6 +676,7 @@ static int
>  qemuSetupCpuCgroup(virDomainObjPtr vm)
>  {
>      qemuDomainObjPrivatePtr priv = vm->privateData;
> +    virObjectEventPtr event;
>  
>      if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
>         if (vm->def->cputune.sharesSpecified) {
> @@ -695,6 +696,11 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
>          if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
>              return -1;
>          vm->def->cputune.shares = val;
> +
> +        event = virDomainEventCputuneNewFromObj(vm, vm->def->cputune);
> +
> +        if (event)
> +            qemuDomainEventQueue(vm->privateData, event);

So this is triggered during qemuProcessStart() and only when there's
cputune.sharesSpecified is set and before any cgroups are set up or
virProcessSetAffinity() is called. This is fairly specific, but does not
include when the vcpu or emulator is initially setup.  Since you're
triggering events when emulatorpin/vcpupin are called - I would think
similarly the qemuSetupCgroupForVcpu() and qemuSetupCgroupForEmulator()
would/could be places for events since that's when they are created.

Also, should there be a similar event during qemuProcessReconnect().

IOW: When should this event be triggered and naturally - is that
documented properly or enough?

John

>      }
>  
>      return 0;
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 5d21080..e2fedaf 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4461,6 +4461,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
>      virBitmapPtr pcpumap = NULL;
>      virQEMUDriverConfigPtr cfg = NULL;
>      virCapsPtr caps = NULL;
> +    virObjectEventPtr event = NULL;
>  
>      virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
>                    VIR_DOMAIN_AFFECT_CONFIG, -1);
> @@ -4568,6 +4569,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
>  
>          if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
>              goto cleanup;
> +
> +        event = virDomainEventCputuneNewFromDom(dom, vm->def->cputune);
>      }
>  
>      if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
> @@ -4603,6 +4606,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
>          virCgroupFree(&cgroup_vcpu);
>      if (vm)
>          virObjectUnlock(vm);
> +    if (event)
> +        qemuDomainEventQueue(driver, event);
>      virBitmapFree(pcpumap);
>      virObjectUnref(caps);
>      virObjectUnref(cfg);
> @@ -4727,6 +4732,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
>      virBitmapPtr pcpumap = NULL;
>      virQEMUDriverConfigPtr cfg = NULL;
>      virCapsPtr caps = NULL;
> +    virObjectEventPtr event = NULL;
>  
>      virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
>                    VIR_DOMAIN_AFFECT_CONFIG, -1);
> @@ -4832,6 +4838,8 @@ qemuDomainPinEmulator(virDomainPtr dom,
>  
>          if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
>              goto cleanup;
> +
> +        event = virDomainEventCputuneNewFromDom(dom, vm->def->cputune);
>      }
>  
>      if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
> @@ -4861,6 +4869,8 @@ qemuDomainPinEmulator(virDomainPtr dom,
>   cleanup:
>      if (cgroup_emulator)
>          virCgroupFree(&cgroup_emulator);
> +    if (event)
> +        qemuDomainEventQueue(driver, event);
>      virBitmapFree(pcpumap);
>      virObjectUnref(caps);
>      if (vm)
> @@ -9053,6 +9063,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>      virQEMUDriverConfigPtr cfg = NULL;
>      virCapsPtr caps = NULL;
>      qemuDomainObjPrivatePtr priv;
> +    virObjectEventPtr event = NULL;
> +    bool emitEvent = false;
>  
>      virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
>                    VIR_DOMAIN_AFFECT_CONFIG, -1);
> @@ -9123,6 +9135,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>  
>                  vm->def->cputune.shares = val;
>                  vm->def->cputune.sharesSpecified = true;
> +
> +                emitEvent = true;
>              }
>  
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
> @@ -9140,6 +9154,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>                      goto cleanup;
>  
>                  vm->def->cputune.period = value_ul;
> +
> +                emitEvent = true;
>              }
>  
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG)
> @@ -9154,6 +9170,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>                      goto cleanup;
>  
>                  vm->def->cputune.quota = value_l;
> +
> +                emitEvent = true;
>              }
>  
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG)
> @@ -9169,6 +9187,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>                      goto cleanup;
>  
>                  vm->def->cputune.emulator_period = value_ul;
> +
> +                emitEvent = true;
>              }
>  
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG)
> @@ -9184,6 +9204,8 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>                      goto cleanup;
>  
>                  vm->def->cputune.emulator_quota = value_l;
> +
> +                emitEvent = true;
>              }
>  
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG)
> @@ -9204,12 +9226,17 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
>          vmdef = NULL;
>      }
>  
> +
>      ret = 0;
>  
>   cleanup:
>      virDomainDefFree(vmdef);
>      if (vm)
>          virObjectUnlock(vm);
> +    if (emitEvent)
> +        event = virDomainEventCputuneNewFromDom(dom, vm->def->cputune);
> +    if (event)
> +        qemuDomainEventQueue(driver, event);
>      virObjectUnref(caps);
>      virObjectUnref(cfg);
>      return ret;
> 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]