blob: 54a2eccef67a87c21defcb9070a0533bc57ae98e [file] [log] [blame]
This document will briefly describe how gvm source code is organized in
emulator(Qemu).
The GVM name itself comes from Google's tradition of gXyz.
The initial source files are made by a complete clone of KVM and rename symbols
from kvm/KVM_xxxx to gvm/GVM_xxxx. The reason of doing so instead of hacking KVM
source files directly is:
1. Avoid massive modifications to KVM source code. Most of them would be
#ifdef CONFIG_GVM
#ifdef _WIN32
This is not reader friendly either.
2. Need to decouple GVM from KVM, although GVM comes from KVM. We don't have to
contantly check whether an KVM change needs to be followed or filtered out by
"#ifdef". There are enough differences between them. So GVM will eventually
diverge from KVM in terms of APIs, features, etc. And GVM won't be regularly
rebased to KVM, which is impossible.
The GVM source files include both dedicated source files and scattered changes
to common QEMU source files.
Dedicated files are:
.
└── gdbstub.c
└─ hw
    └── i386
      └── gvm
         ├── apic.c
         ├── i8259.c
         └── ioapic.c
└── target
    └── i386
      ├── gvm-all.c
      └── gvm.c
First three source files are user space code for in-kernel irq chip. KVM has
additional in-kernel PIT, which isn't important nowadays. So GVM removes that.
The last two are user space code for the GVM hypervisor. This looks pretty
similar with HVF, WHPX, HAX. The reason for two separate files is that they
are inheritted from KVM. KVM has its kvm-all.c placed accel\kvm, which is
shared among i386, arm, ..., etc. GVM only supports i386 so gvm-all.c is
placed here. The only reason for not merging then together is for possible
future ARM support.
Scattered changes typically look like:
#ifdef CONFIG_KVM
#endif
#ifdef CONFIG_GVM
#endif
-------------or-----------------------
if (kvm_enabled()) {
}
if (gvm_enabled()) {
}
The code samples here can explain themselves quite well.