
-----Original Message----- From: Jiri Denemark [mailto:jdenemar@redhat.com] Sent: Monday, November 30, 2015 7:09 PM To: Ren, Qiaowei Cc: libvir-list@redhat.com Subject: Re: [libvirt] [PATCH 6/8] qemu_driver: add support to perf event
On Mon, Nov 30, 2015 at 08:17:05 +0000, Ren, Qiaowei wrote:
-----Original Message----- From: Jiri Denemark [mailto:jdenemar@redhat.com] Sent: Tuesday, November 24, 2015 9:01 PM To: Ren, Qiaowei Cc: libvir-list@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@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.
Oh, sorry for the confusion then. I actually wanted the code to be something like
if (virTypedParamsValidate(params, nparams, VIR_PERF_PARAMS) < 0) return -1;
and VIR_PERF_PARAMS would be a macro defined in virparams.h:
# define VIR_PERF_PARAMS \ VIR_DOMAIN_PERF_CMT, VIR_TYPED_PARAM_BOOLEAN, \ NULL
Similar to QEMU_MIGRATION_PARAMETERS and few others.
Got it! Thanks, Jirka. Qiaowei