On Fri, May 03, 2013 at 02:12:14PM +0200, Andreas Färber wrote: > Am 03.05.2013 14:01, schrieb Stefan Hajnoczi: > > From: Kazuya Saito <saito.kaz...@jp.fujitsu.com> > > > > This patch adds tracepoints at ioctl to kvm. Tracing these ioctl is > > useful for clarification whether the cause of troubles is qemu or kvm. > > > > Signed-off-by: Kazuya Saito <saito.kaz...@jp.fujitsu.com> > > Reviewed-by: Paolo Bonzini <pbonz...@redhat.com> > > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > > --- > > kvm-all.c | 4 ++++ > > trace-events | 5 +++++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/kvm-all.c b/kvm-all.c > > index f6c0f4a..4f73b98 100644 > > --- a/kvm-all.c > > +++ b/kvm-all.c > > @@ -33,6 +33,7 @@ > > #include "exec/memory.h" > > #include "exec/address-spaces.h" > > #include "qemu/event_notifier.h" > > +#include "trace.h" > > > > /* This check must be after config-host.h is included */ > > #ifdef CONFIG_EVENTFD > > @@ -1687,6 +1688,7 @@ int kvm_ioctl(KVMState *s, int type, ...) > > arg = va_arg(ap, void *); > > va_end(ap); > > > > + trace_kvm_ioctl(type, arg); > > ret = ioctl(s->fd, type, arg); > > if (ret == -1) { > > ret = -errno; > > @@ -1704,6 +1706,7 @@ int kvm_vm_ioctl(KVMState *s, int type, ...) > > arg = va_arg(ap, void *); > > va_end(ap); > > > > + trace_kvm_vm_ioctl(type, arg); > > ret = ioctl(s->vmfd, type, arg); > > if (ret == -1) { > > ret = -errno; > > @@ -1721,6 +1724,7 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...) > > arg = va_arg(ap, void *); > > va_end(ap); > > > > + trace_kvm_vcpu_ioctl(cpu->cpu_index, type, arg); > > ret = ioctl(cpu->kvm_fd, type, arg); > > if (ret == -1) { > > ret = -errno; > > diff --git a/trace-events b/trace-events > > index 55e80be..d5bc7a5 100644 > > --- a/trace-events > > +++ b/trace-events > > @@ -1153,3 +1153,8 @@ virtio_ccw_new_device(int cssid, int ssid, int schid, > > int devno, const char *dev > > > > # migration.c > > migrate_set_state(int new_state) "new state %d" > > + > > +# kvm-all.c > > +kvm_ioctl(int type, void *arg) "type %d, arg %p" > > +kvm_vm_ioctl(int type, void *arg) "type %d, arg %p" > > +kvm_vcpu_ioctl(int cpu_index, int type, void *arg) "cpu_index %d, type %d, > > arg %p" > > Sorry that I'm just seeing this patch now (wasn't CC'ed), but I wonder > whether cpu_index is the best thing to trace here? Can we still change > trace event API or would we have to nack/change now? > > CC'ing Igor since he just introduced a cpu_get_arch_id() and there's > also a kvm_arch_vcpu_id() introduced earlier by Eduardo.
Being kvm_vcpu_ioctl() a very low-level KVM function, I believe the KVM VCPU "id" (the argument passed to KVM_CREATE_VCPU, that needs to be the APIC ID on x86, and is returned by kvm_arch_vcpu_id()) is the best CPU identifier to be included here. cpu_index is the most ambiguous and least reliable CPU identifier we have today. I wouldn't use it in any new code. -- Eduardo