[libvirt] [PATCH 6/8] qemu_driver: add support to perf event

Ren, Qiaowei qiaowei.ren at intel.com
Mon Nov 30 08:17:05 UTC 2015


> -----Original Message-----
> From: Jiri Denemark [mailto:jdenemar at redhat.com]
> Sent: Tuesday, November 24, 2015 9:01 PM
> To: Ren, Qiaowei
> Cc: libvir-list at redhat.com
> Subject: Re: [libvirt] [PATCH 6/8] qemu_driver: add support to perf event
> 
> On Tue, Nov 17, 2015 at 16:00:46 +0800, Qiaowei Ren wrote:
> > This patch implement the internal driver API for perf event into qemu
> > driver.
> >
> > In addition, this patch extend virDomainListGetStats API to get the
> > statistics for perf event. To do so, we add a 'VIR_DOMAIN_STATS_PERF'
> > enum to causes reporting of all previously enabled perf events.
> >
> > Signed-off-by: Qiaowei Ren <qiaowei.ren at intel.com>
> > ---
> >  include/libvirt/libvirt-domain.h |   1 +
> >  src/qemu/qemu_domain.h           |   3 +
> >  src/qemu/qemu_driver.c           | 181
> +++++++++++++++++++++++++++++++++++++++
> >  #define QEMU_SCHED_MIN_PERIOD              1000LL
> >  #define QEMU_SCHED_MAX_PERIOD           1000000LL
> >  #define QEMU_SCHED_MIN_QUOTA               1000LL
> > @@ -10244,6 +10247,106 @@
> qemuDomainGetNumaParameters(virDomainPtr
> > dom,  }
> >
> >  static int
> > +qemuDomainSetPerfEvents(virDomainPtr dom,
> > +                        virTypedParameterPtr params,
> > +                        int nparams)
> > +{
> > +    size_t i;
> > +    virDomainObjPtr vm = NULL;
> > +    qemuDomainObjPrivatePtr priv;
> > +    int ret = -1;
> > +    bool enabled;
> > +
> > +    if (virTypedParamsValidate(params, nparams,
> > +                               VIR_DOMAIN_PERF_CMT,
> > +                               VIR_TYPED_PARAM_BOOLEAN,
> > +                               NULL) < 0)
> > +        return -1;
> 
> Use virTypedParamsCheck and define the data for it in virperf.h so that you
> don't need to change the code here if new event type is added.
> 

Jirka, I checked the difference between virTypedParamsValidate and virTypedParamsCheck, and found that virTypedParamsCheck just check whether the param is valid through param name, but virTypedParamsValidate will check whether the param type is right.

In addition, virTypedParamsCheck is just used in three functions in libvirt-domain.c, and all driver APIs use virTypedParamsValidate to validate the parms like this patch. What do you think about it? 

Thanks,
Qiaowei




More information about the libvir-list mailing list