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(a)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.
Jirka