1 |
|
-M
Libnvdimm
1 |
|
1 |
|
1 |
|
-M
Libnvdimm
1 |
|
1 |
|
主机环境:Windows 11 64位 core i9 12900p
此次使用VMWare Workstation pro 16进行操作
win+r 打开cmd
sysinfo
查看是否开启了Hyper-V,如果开启应将其关闭
关闭方式
- 【启用或关闭Windows功能】-> 将虚拟机平台和windows虚拟机监控程序平台关闭
- 如果看到了Hyper-V的选项框,将其取消勾选
- 然后重启生效修改
VMware 中启动Ubuntu16.04
配置为
内核: Linux4.15.0-112,磁盘分配>40G,在CPU设置中启用嵌套虚拟化
1
2
3 sudo apt-get install build-essential openssl libncurses5-dev libssl-dev
sudo apt-get install zlibc minizip libidn11-dev libidn11 bison flex
1 git clone https://github.com/GiantVM/Linux-DSM.git
1 cd Linux-DSM
1 make menuconfig
Virtualization
–>KVM distributed software memory support
–>press 'Y' to include the option
Save
–>Exit
make -jN
[N 是]
wait for about three hour(or more)之前的失败经历: Environment: win11 wsl2 Ubuntu16.04 LinuxKernel version 5.10 output : makefile:976: recipe for target 'vmlinux' failed
1
2 sudo make modules_install
sudo make install
[在我的尝试中,这时候应当先打开grub这个文件]
[gedit 比较方便看,用vi也可以]
1 | sudo gedit /etc/default/grub |
[然后将GRUB_HIDDEN_TIMEOUT 这个属性置为0,不然之后重启的时候没时间换系统]
这自己操作
[然后是核心操作 ]
1 | sudo update-grub |
[之后重启]
1 | reboot |
[重启后看到下面界面,按照图片选择]
[之后等待,启动后,在shell里输入]
1 | uname -a |
[可以看到版本为ubuntu 4.9.76+]
sudo apt-get install python pkg-config libglib2.0-dev zlib1g-dev libpixman-1-dev libfdt-dev
git clone https://github.com/GiantVM/QEMU.git
cd QEMU
1 ./configure --target-list=x86_64-softmmu --enable-kvm
1 make -jN
1
2 cd ..
wget http://ftp.sjtu.edu.cn/ubuntu-cd/16.04.7/ubuntu-16.04.7-server-amd64.iso[如果找不到,可以直接输入http://ftp.sjtu.edu.cn/ubuntu-cd/16.04.7,在里面找到Ubuntu-16.x-server.iso ,然后wget]
[这里就是得用apt下一个qemu,选择不下,用底下x86-64_softmmu/ 底下的qemu-system-x86_64会卡死]
1
2
3 /qemu-img create -f qcow2 ubuntu-server.img 10G
sudo apt-get install qemu
qemu-system-x86_64 -m 1024 ubuntu-server.img -cdrom ../ubuntu-16.04.7-server-amd64.iso -enable-kvm[上面会跳出系统设置,基本设置一下用户名和密码,然后会问是否要装载GRUB,选择yes,其他无所谓]
1 | wget https://www.realvnc.com/download/file/viewer.files/VNC-Viewer-6.19.325-Linux-x64.deb |
如果下面报错说内存不够,把虚拟机关掉,多分配给它一点内存(>8G)
terminal 1 :
1
2
3 cd QEMU/
sudo x86_64-softmmu/qemu-system-x86_64 --nographic -hda ubuntu-server.img -cpu host -machine kernel-irqchip=off -smp 4 -m 4096 --enable-kvm -serial mon:stdio -local-cpu 2,start=0,iplist="127.0.0.1 127.0.0.1" -vnc :0
terminal 2:
1
2 cd QEMU/
sudo x86_64-softmmu/qemu-system-x86_64 --nographic -hda ubuntu-server.img -cpu host -machine kernel-irqchip=off -smp 4 -m 2048 --enable-kvm -serial mon:stdio -local-cpu 2,start=2,iplist="127.0.0.1 127.0.0.1"
terminal 3:[启动 vncviewer]
冒号后面的0和前面 terminal1 后面-vnc 后面的数字对应
1 vncviewer :0如果启动之后看到 nobootable device ,可能需要检查2 QEMU 最后一步的 qemu-system-x86_64 那段是不是正常
挑战来源: 基于 陷入-模拟 机制的虚拟化架构只能在所有敏感指令都是特权指令的架构中被建立
敏感指令: 操作敏感物理资源的指令,如I/O指令、页表基地址切换指令等
特权指令; 必须运行在最高特权级的指令,在非特权级中执行这些指令将会触发特权级切换。
解决方案:
软件方案: 解释执行【无脑解释执行所有指令,效率较低】,二进制翻译【将敏感指令替换为其他指令,会增加指令数量】,扫描与修补【在执行前,将敏感指令替换为特权指令,代码局部性较差】,半虚拟化【在执行敏感指令的时候通过超调用主动陷入Hypervisor中,避免扫描二进制代码引入的开销,但是打破了虚拟机和Hypervisor之间的界限】
硬件辅助方案: Intel VT-x,AMD SVM, ARM EL2, RISC-V H-Extension
将所有敏感指令转化为特权指令【可能存在兼容性问题】
引入虚拟化模式
类似进程上下文,虚拟机发生退出时需要保持各寄存器的状态
发生虚拟CPU调度时,需要保存当前虚拟CPU的上下文兵加载待调度虚拟CPU上下文
模拟方式:为每一个虚拟机维护一个虚拟中断控制器