diff calculation
Hyper-V
自己做虚拟化研究,却对Hyper-V毫无了解,真是羞愧= =
Hyper-V是Windows的一个组件,开启该功能后,系统会重启进行模块安装,安装完毕后,相当于在内核中加了一个中间层:Hyper-V层。随后所有的,包括原host在内的系统都会变成guest。不同于Xen中domain0还是hypervisor,Hyper-V上原host不过是一个有着特殊权限的guest而已。
综上,Hyper-V会和VirtualBox和VMwareWorkstation冲突,因为Windows变成了guest,无法再支持VT-x了。
Vim显示当前文件名和目录
:file
Ctrl+G
QEMU Documentations
QEMU Emulator User Documentation
"Computers as Components, Second Edition: Principles of Embedded Computing System Design", Wayne Wolf, ISBN-13: 978-0123743978
* QDev = QEMU Device Model
* QOM = QEMU Object Model
* QMP = QEMU Mechine Protocol
* QAPI: Introduce a number of changes to the internal implementation of QMP to simplify maintainability and enable features such as asynchronous command completion and rich error reporting.
* Tiny Code Generator (TCG)
QEMU src directories
- docs/ 包含了一些文档,说实话,对初学者来说,读这些文档压根没有头绪
- hw/ 包含了所有支持的硬件设备
- include/ 包含了一些头文件
- linux-user/ 包含了linux下的用户模式的代码
- target-XXX/ 包含了QEMU目前所支持guset端的处理器架构。包含的代码的主要功能是将该guest架构的指令翻译成TCG OP代码。也就是target-arm下的代码就是将arm架构的指令翻译成TCG OP。这些目录占了源码目录的很大一部分。
- tcg/ 包含了动态翻译工具tcg的源码部分,主要是将TCG OP转化为host binary的部分。这个目录下也包含了多个架构名字命名的目录,每个目录下存放着针对该架构的代码。后续会详细介绍。
- test/ 从名字上可以看出,应该是存放测试部分的代码。
QEMU的机制
Balloon
Guest Kernel
drivers/virtio/virtio_balloon.c
balloon()
diff=towards_target(vb)
towards_target()
virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages,&num_pages);
return num_pages-vb->num_pages
include/linux/virtio_config.h
virtio_cread()
*(num_pages)=virtio_cread64(vdev,offsetof(structname,member));
virtio_cread64()
__virtio_cread_many(vdev, offset, &ret, 1, sizeof(ret));
__virtio_cread_many()
vdev->config->get(vdev, offset + bytes * i,
buf + i * bytes, bytes);
QEMU
hw/virtio/virtio-balloon.c
virtio_balloon_set_config()
qapi_event_send_balloon_change(vm_ram_size -
((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT),&error_abort);
总结
Guest Kernel通过vdev->config->get()获取config信息读取页面数目,这部分的信息由QEMU在virtio_balloon_set_config()设置
问题在于,QEMU中是从哪里调用的这个set_config(),参数中的页面数目是从哪里拿到的?
Virtio
PCI (Peripheral Component Interconnect) 外部设备互连总线
Support PCI devices:
- virtio-net-pci
- virtio-scsi-pci
- virtio-balloon-pci
- virtio-serial-pci
- virtio-rng-pci
ls只显示目录
ls -l | grep ^d
Plan
- QEMU huge page
- Modern Operating System
- Linux Kernel
- Virtualization