Re: Naive questions regarding KVM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/23/2014 12:57 PM, Mathew Li wrote:

> Hi All,
> 
> I want to learn KVM code. Apologies for asking really simple
> questions. I have Ubuntu 12.04 32bit installed on my laptop. As I
> understand there are two modules of the KVM. One is called kvm.ko and
> other arch specific e.g. in my case it is kvm-intel.ko. These modules
> are already present in my system. I can do modinfo and it lists them.
> 
> What I want to do is modify KVM code to add print statements to
> understand things better. But I don't know what code to modify and how
> to rebuild these two modules for my system, so that they have my print
> statements. Could you please guide me what code do I need to download
> and how to compile that to get the modules regenerated for my system?
> If I need to download the whole Linux kernel then where in Linux
> kernel KVM code lives? I don't want to compile the whole linux kernel,
> I just want to compile these modules for my system.
> 
> Thanks a lot for any help you could provide.
>


Hi Li:

I happend to have an similar example for kernel-3.3.3.
If you want to build kvm modules out of a kernel tree you can copy files in kernel root dirs:
'arch/x86/kvm' and 'virt/kvm' to a dedicated dir like '/home/wrok/kvm_debug'.
Its Makefile could be like below.
Building command is some command like "make -C ../linux-3.3.3 M=`pwd` modules" in dir 'kvm_debug'

And trace.h & mmutrace.h need a littile change:
# [root@chaiw kvm_debug]# diff -U 5 trace.h ../linux-3.3.3/arch/x86/kvm/trace.h
# --- trace.h   2014-05-05 15:25:16.319200716 +0800
# +++ ../linux-3.3.3/arch/x86/kvm/trace.h       2012-04-23 06:39:43.000000000 +0800
# @@ -820,11 +820,11 @@
#                 __entry->gpa_match ? "GPA" : "GVA")
#  );
#  #endif /* _TRACE_KVM_H */
#
#  #undef TRACE_INCLUDE_PATH
# -#define TRACE_INCLUDE_PATH /home/work/kvm_debug
# +#define TRACE_INCLUDE_PATH arch/x86/kvm
#  #undef TRACE_INCLUDE_FILE
#  #define TRACE_INCLUDE_FILE trace
#
#  /* This part must be outside protection */
#  #include <trace/define_trace.h>
#
# [root@chaiw kvm_debug]# diff -U 5 mmutrace.h ../linux-3.3.3/arch/x86/kvm/mmutrace.h
# --- mmutrace.h        2014-05-05 15:28:19.300189943 +0800
# +++ ../linux-3.3.3/arch/x86/kvm/mmutrace.h    2012-04-23 06:39:43.000000000 +0800
# @@ -244,11 +244,11 @@
#                 __entry->access)
#  );
#  #endif /* _TRACE_KVMMMU_H */
#
#  #undef TRACE_INCLUDE_PATH
# -#define TRACE_INCLUDE_PATH /home/work/kvm_debug
# +#define TRACE_INCLUDE_PATH .
#  #undef TRACE_INCLUDE_FILE
#  #define TRACE_INCLUDE_FILE mmutrace
#
#  /* This part must be outside protection */
#  #include <trace/define_trace.h>


------- Makefile ---------
# depended on kernel-3.3.3
# for kvm module
kvm-y += kvm_main.o ioapic.o coalesced_mmio.o irq_comm.o eventfd.o \
         assigned-dev.o
kvm-$(CONFIG_IOMMU_API) += iommu.o
kvm-$(CONFIG_KVM_ASYNC_PF) += async_pf.o
kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o i8254.o timer.o \
         cpuid.o pmu.o
obj-m := kvm.o

# for kvm_intel & kvm_amd modules
kvm_intel-y += vmx.o
kvm_amd-y += svm.o
obj-m += kvm_intel.o
obj-m += kvm_amd.o

clean:
        @-rm -f *.o
        @-rm -f *mod*
        @-rm -f *.ko


thanks
chai wen

 
> Thanks!
> Matt
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



-- 
Regards

Chai Wen
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux