x86 架构构建ARM虚拟机

Running VMs on Fedora/AArch64
There are moments when more than one machine would be handy. But AArch64 computers are not yet available in shop around a corner we have to go for other options. So this time let check how to get virtual machines working.

Requirements
For this I would use Fedora 22 on APM Mustang (other systems will be fine too). What else will be needed:

libvirtd running
virt-manager 1.1.0-7 (or higher) installed on AArch64 machine
UEFI for AArch64 from Gerd’s Hoffmann firmware repository
Fedora or Debian installation iso (Ubuntu does not provide such)
computer with X11 working (to control virt-manager)
UPDATE: starting from Fedora 23 UEFI package is in distribution repository. Packages are ‘edk2-arm’ for 32bit arm, ‘edk2-aarch64’ for 64bit arm and ‘edk2-ovmf’ for x86-64 architecture.

Is KVM working?
First we need to get KVM working — run “dmesg|grep -i kvm” after system boot. It should look like this:

hrw@pinkiepie-f22:~$ dmesg|grep -i kvm
[ 0.261904] kvm [1]: interrupt-controller@780c0000 IRQ5
[ 0.262011] kvm [1]: timer IRQ3
[ 0.262026] kvm [1]: Hyp mode initialized successfully
But you can also get this:

[ 0.343796] kvm [1]: GICV size 0x2000 not a multiple of page size 0x10000
[ 0.343802] kvm [1]: error: no compatible GIC info found
[ 0.343909] kvm [1]: error initializing Hyp mode: -6
In such case fixed DeviceTree blob from bug #1165290 would be needed. Fetch attached DTB, store as “/boot/mustang.dtb” and then edit “/etc/grub2-efi.cfg” file so kernel entry will look like this:

menuentry ‘Fedora (4.0.0-0.rc5.git4.1.fc22.aarch64) 22 (Twenty Two)’ --class fedora --class gnu-linux --class gnu --class os --unrestricted KaTeX parse error: Expected '}', got 'EOF' at end of input: … if [ xfeature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt32 --hint-efi=hd1,gpt32 --hint-baremetal=ahci1,gpt32 13e42c65-e2eb-4986-abf9-262e287842e4
else
search --no-floppy --fs-uuid --set=root 13e42c65-e2eb-4986-abf9-262e287842e4
fi
linux /boot/vmlinuz-4.0.0-0.rc5.git4.1.fc22.aarch64 root=UUID=13e42c65-e2eb-4986-abf9-262e287842e4 ro LANG=en_GB.UTF-8
initrd /boot/initramfs-4.0.0-0.rc5.git4.1.fc22.aarch64.img
devicetree /boot/mustang.dtb
}
After reboot KVM should work.

Software installation
Next step is installing VM software: “dnf install libvirt-daemon* virt-manager” will handle that. But to run Virt Manager we also need a way to see it. X11 forwarding over ssh to the rescue ;D After ssh connection I usually cheat with “sudo ln -sf ~hrw/.Xauthority /root/.Xauthority” to be able to run UI apps as root user.

download and install qemu
wget https://download.qemu.org/qemu-4.11.0.tar.xz
tar xvJf qemu-4.11.0.tar.xz
cd qemu-4.11.0
./configure --enable-spice --target-list=aarch.x86.64
make
make instal

UEFI firmware
Next phase is UEFI which allows us to boot virtual machine with ISO installation images (compared to kernel/initrd combo when there is no firmware/bootloader possibility). We will install one from repository provided by Gerd Hoffmann:

hrw@pinkiepie-f22:~$ sudo -s
root@pinkiepie-f22:hrw$ cd /etc/yum.repos.d/
root@pinkiepie-f22:yum.repos.d$ wget https://www.kraxel.org/repos/firmware.repo
root@pinkiepie-f22:yum.repos.d$ dnf install edk2.git-aarch64
Then libvirtd config change to give path for just installed firmware. Edit “/etc/libvirt/qemu.conf” file and at the end of file add this:

nvram = [
“/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw:/usr/share/edk2.git/aarch64/vars-template-pflash.raw”
]
Restart libvirtd via “systemctl restart libvirtd“.

Running Virtual Machine Manager
Now we can connect via “ssh -X” and run “sudo virt-manager“:

Next step is connection to libvirtd:

Now we are ready for creating VMs. After pressing “Create a new VM” button we should see this:

And then creation of VM goes nearly like on x86 machines as there is no graphics only serial console.

But if you forgot to setup UEFI firmware then you will get this:

In such case get back to UEFI firmware step.

Installing Fedora 22 in VM
So let’s test how it works. Fedora 22 is in Beta phase now so why not test it?

2GB ram and 3 cpu cores should be more than enough ;D

And 10GB for minimal system:

But when it went to serial console it did not look good 😦

I realized that I forgot to install fonts, but quick “dnf install dejavu*fonts” sorted that out:

Go for VNC controller installation.

After installation finish system runs just fine:

Summary
As you can see Fedora 22 has everything in place to get VM running on AArch64. UEFI firmware is the only thing out of distribution but that’s due to some license stuff on vfat implementation or something like that. I was running virtual machines with Debian ‘jessie’ and Fedora 22. Wanted to check Ubuntu but all I found was kernel/initrd combo (which is one of ways to boot in virt-manager) but it did not booted in VM.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值