Author: Zhao Shijie
Profile
KVM and QEMU profiles, please refer to:
qemu : https://zh.wikipedia.org/wiki/QEMU
kvm : https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine
Installation
Ubuntu
Option 1: ubuntu-package-install
|
|
Option 2: ubuntu-compile-install
Install depended-upon package
1apt-get install -y gcc zlib1g-dev libperl-dev libgtk2.0-dev libfdt-dev bridge-utilsCompile
First get the newest qemu code from estuary repository,then enter the QEMU code root directory and execute the following command step by step.
12345mkdir buildcd build../configure --target-list=aarch64-softmmu --enable-fdt --enable-kvm --disable-werrormake -j5make install
Centos
Option 1: centos-package-install
CentOS official source of QEMU(aarch64) support is not good, you need to add linaro source
During the installation if there is an error because of the network,please repeat.
Some of the linaro packages have not been verified by GPG,so close the gpg check.
Option 2: centos-compile-install
Install depended-upon package
1234yum groups mark convertyum groups mark install "Development Tool"yum group install "Development tools" -yyum install glib2-devel zlibrary zlib-devel pixman pixman-devel libfdt-devel libfdt -ycompile
First get the newest qemu code from estuary repository,then enter the QEMU code root directory and execute the following command step by step.
12345mkdir buildcd build../configure --target-list=aarch64-softmmu --enable-fdt --enable-kvm --disable-werrormake -j5make install
Prepare image files
- Build
estuaryproject withqemuoption. - Copy
*.imgandImagefiles generated fromopen-estuary/workspace/distro/to current directory.
Enable virtual bridge
In order to enable virtual bridge, execute the following command:
Verification
There are two scripts that will be used when starting QEMU, put them into current directory.
qemu-ifup.sh:
1234567891011121314151617[root@CentOS ~]# cat qemu-ifup.shswitch=br0if [ -n "$1" ]; then#create a tap interfaceip tuntap add $1 mode tapsleep 1#start up the tap interfaceip link set $1 upsleep 1#add tap interface to the bridgebrctl addif ${switch} $1exit 0elseecho "error: no interface specified"exit 1fiqemu-ifdown.sh:
12345678910111213141516[root@CentOS ~]# cat qemu-ifdown.shswitch=br0if [ -n "$1" ]; then#delete the specified interfaceip tuntap del mode tap $1#rlease tap interface from bridgebrctl delif $(switch) $1#shutdown the tap interfaceip link set $1 downexit 0elseecho "error: no interface specified"exit 1fi[root@CentOS ~]#Execute the following command to start qemu:
1qemu-system-aarch64 -machine virt,gic_version=3 -cpu host -kernel Image -drive if=none,file=ubuntu.img,id=fs -device virtio-blk-device,drive=fs -append "console=ttyAMA0 root=/dev/vda1 rw rootwait" -device virtio-net-device,netdev=net0 -netdev tap,id=net0,script=qemu-ifup.sh,downscript=qemu-ifdown.sh -nographic -D -d -enable-kvmVerify network capabilities, execute the following command in qemu:
12ip addr add 192.168.2.3/24 dev eth0ping 192.168.2.1 -c 3Verify the function of the virtual hard disk, follow these steps:
create a dir in qemu
1mkdir hello-worldrestart the qemu
colse qemu: send
CTRL+a,cto qemu, then input “quit“Confirm whether the newly created directory exists