[libvirt] [PATCH 3/8] perf: implement the public APIs for perf event

Ren, Qiaowei qiaowei.ren at intel.com
Tue Nov 24 02:15:53 UTC 2015


> -----Original Message-----
> From: Jiri Denemark [mailto:jdenemar at redhat.com]
> Sent: Tuesday, November 24, 2015 12:25 AM
> To: Ren, Qiaowei
> Cc: libvir-list at redhat.com
> Subject: Re: [libvirt] [PATCH 3/8] perf: implement the public APIs for perf event
> 
> On Tue, Nov 17, 2015 at 16:00:43 +0800, Qiaowei Ren wrote:
> > * src/libvirt-domain.c: Implement virDomainGetPerfEvents and
> > virDomainSetPerfEvents.
> >
> > Signed-off-by: Qiaowei Ren <qiaowei.ren at intel.com>
> > ---
> >  src/libvirt-domain.c | 106
> > +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 106 insertions(+)
> >
> > diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index
> > de7eb04..e767606 100644
> > --- a/src/libvirt-domain.c
> > +++ b/src/libvirt-domain.c
> > @@ -9572,6 +9572,112 @@ virDomainOpenChannel(virDomainPtr dom,
> >
> >
> >  /**
> > + * virDomainGetPerfEvents:
> > + * @domain: pointer to domain object
> > + * @params: pointer to perf events parameter object
> > + *          (return value, allocated by the caller)
> > + * @nparams: pointer to number of perf event parameters
> > + *
> > + * Get all perf events setting. On input, @nparams gives the size of
> > + the
> > + * @params array; on output, @nparams gives how many slots were
> > + filled
> > + * with parameter information, which might be less but will not
> > + exceed
> > + * the input value.
> > + *
> > + * As a special case, calling with @params as NULL and @nparams as 0
> > + on
> > + * input will cause @nparams on output to contain the number of
> > + parameters
> > + * supported by the hypervisor. The caller should then allocate
> > + @params
> > + * array, i.e. (sizeof(@virTypedParameter) * @nparams) bytes and call
> > + the
> > + * API again.
> > + *
> > + * See virDomainGetMemoryParameters() for an equivalent usage example.
> 
> You took a wrong API to copy. Requiring the caller to run the API with @params
> == NULL to get the number of parameters and then pass the allocated @params
> to get the values is the original design which we do not use for new APIs. The
> API should just allocate @params, fill it with all the values it knows about, and
> return the count in @nparams. In other words, no caller allocated arrays, please.
> You can look at, e.g., virDomainGetJobStats to see how it works.
> 

Thanks, Jirka. I will update this patch according to new API design.

Thanks,
Qiaowei




More information about the libvir-list mailing list