kata qemu

 https://github.com/kata-containers/kata-containers/tree/2.0-dev/tools/packaging/qemu/patches/5.1.x

 

 

root@ubuntu:/home/ubuntu/qemu_learn# bash kata_9p.sh 
qemu-system-aarch64: -device vhost-vsock-pci,disable-modern=false,vhostfd=3,id=vsock-1072880509,guest-cid=1072880509: vhost_set_owner failed: Inappropriate ioctl for device (25)
qemu-system-aarch64: -device vhost-vsock-pci,disable-modern=false,vhostfd=3,id=vsock-1072880509,guest-cid=1072880509: vhost-vsock: vhost_dev_init failed: Operation not permitted
没有加patch kata_9p.sh: line
5: -device: command not found root@ubuntu:/home/ubuntu/qemu_learn# cp ../qemu5.1/qemu/build/qemu qemu-img-cmds.h qemu-options.def qemu.syms qemu-system-aarch64 qemu-system-aarch64.p/ qemu-version.h root@ubuntu:/home/ubuntu/qemu_learn# cp ../qemu5.1/qemu/build/qemu-system-aarch64 ./ root@ubuntu:/home/ubuntu/qemu_learn# bash kata_9p.sh qemu-system-aarch64: failed to find romfile "efi-virtio.rom" kata_9p.sh: line 5: -device: command not found root@ubuntu:/home/ubuntu/qemu_learn# cd ../qemu5.1/qemu/build/

 

 不要vhostfd=3参数

-device vhost-vsock-pci,disable-modern=false,id=vsock-1072880509,guest-cid=3,romfile=

 

 

 

 

虚拟机

 

 host

输入

 

 

 

 

Launch QEMU
export VMN=3
export IMAGE=clear-17460-kvm.img
/usr/local/bin/qemu-system-x86_64 \
    -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=${VMN} \
    -enable-kvm \
    -bios OVMF.fd \
    -smp sockets=1,cpus=4,cores=2 -cpu host \
    -m 1024 \
    -vga none -nographic \
    -drive file="$IMAGE",if=virtio,aio=threads,format=raw \
    -netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \
    -device virtio-net-pci,netdev=mynet0 \
    -debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@
How test the vsock connection using socat
Here the CID of the VM is set to 3 and the port set to 1024

In the VM

socat - SOCKET-LISTEN:40:0:x00x00x00x04x00x00x03x00x00x00x00x00x00x00
Note: CID = 3
On the host

sudo socat - SOCKET-CONNECT:40:0:x00x00x00x04x00x00x03x00x00x00x00x00x00x00

 

 

 

 

    QEMU_PATCHES_PATH="${GOPATH}/src/${packaging_repo}/qemu/patches/${QEMU_PATCHES_TAG}.x"
    for patch in ${QEMU_PATCHES_PATH}/*.patch; do
        echo "Applying patch: $patch"
        git apply "$patch"
    done

 

$ go get -d github.com/kata-containers/packaging
$ cd $your_qemu_directory
$ ${GOPATH}/src/github.com/kata-containers/packaging/scripts/configure-hypervisor.sh qemu > kata.cfg
$ eval ./configure "$(cat kata.cfg)"
$ make -j $(nproc)
$ sudo -E make install

 

解决方法

    1. 在Makefile中找到 -Werror项,删除即可。删除后重新编译。
    2. 或设置环境变量 c工程设置
      export CFLAGS = "-Wno-error"
      c++工程设置
      export CXXFLAGS = "-Wno-error"

    3. 或自动化配置工具添加选项 ./config -no-warnings-are-errors


cc -Ilibqemu-aarch64-softmmu.fa.p -I. -I.. -Itarget/arm -I../target/arm -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -pipe -Wall -Winvalid-pch -Werror -std=gnu99 -O2 -g -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -O3 -fno-semantic-interposition -falign-functions=32 -D_FORTIFY_SOURCE=2 -fPIE -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wno-missing-include-dirs -Wno-psabi -fstack-protector-strong -isystem /home/ubuntu/qemu5.1/qemu/linux-headers -isystem linux-headers -iquote /home/ubuntu/qemu5.1/qemu/tcg/aarch64 -iquote . -iquote /home/ubuntu/qemu5.1/qemu -iquote /home/ubuntu/qemu5.1/qemu/accel/tcg -iquote /home/ubuntu/qemu5.1/qemu/include -iquote /home/ubuntu/qemu5.1/qemu/disas/libvixl -pthread -fPIC -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="aarch64-softmmu-config-target.h"' '-DCONFIG_DEVICES="aarch64-softmmu-config-devices.h"' -MD -MQ libqemu-aarch64-softmmu.fa.p/target_arm_translate-a64.c.o -MF libqemu-aarch64-softmmu.fa.p/target_arm_translate-a64.c.o.d -o libqemu-aarch64-softmmu.fa.p/target_arm_translate-a64.c.o -c ../target/arm/translate-a64.c
../target/arm/translate-a64.c: In function ‘disas_simd_two_reg_misc_fp16’:
../target/arm/translate-a64.c:13151:21: error: ‘rmode’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
^
cc1: all warnings being treated as errors
[2329/2336] Compiling C object tests/fp/fp-test.p/.._.._fpu_softfloat.c.o
[2330/2336] Compiling C object tests/fp/fp-bench.p/.._.._fpu_softfloat.c.o
[2331/2336] Compiling C object libqemu-aarch64-softmmu.fa.p/target_arm_translate-sve.c.o
[2332/2336] Compiling C object libqemu-aarch64-softmmu.fa.p/target_arm_translate.c.o
[2333/2336] Compiling C object libqemu-aarch64-softmmu.fa.p/target_arm_sve_helper.c.o
ninja: build stopped: subcommand failed.
Makefile:171: recipe for target 'run-ninja' failed
make: *** [run-ninja] Error 1
root@ubuntu:/home/ubuntu/qemu5.1/qemu/build# sed -i 's/Werror/Wno-error/g' build.ninja






git fetch --all --tags

 

 

 

 

/opt/gopath/src/github.com/qemu/qemu /opt/gopath/src/github.com/kata-containers/tests/.ci
Applying patch: /opt/gopath/src/github.com/kata-containers/packaging/obs-packaging/qemu-aarch64/patches/0001-arm-enable-cold-plug-nvdimm-using-DT.patch
patching file hw/arm/boot.c
Hunk #1 succeeded at 19 with fuzz 2 (offset -1 lines).
Hunk #2 succeeded at 492 with fuzz 2 (offset -33 lines).
Hunk #3 succeeded at 641 with fuzz 1 (offset -21 lines).
patching file hw/arm/virt.c
Hunk #1 FAILED at 2189.
Hunk #2 FAILED at 2224.
2 out of 2 hunks FAILED -- saving rejects to file hw/arm/virt.c.rej
Failed at 68: patch -p1 < "$patch"

 

root@ubuntu:/opt/gopath/src/github.com/kata-containers# rm packaging -rf
root@ubuntu:/opt/gopath/src/github.com/kata-containers# cd -
bash: cd: /opt/gopath/src/github.com/kata-containers/packaging: No such file or directory
root@ubuntu:/opt/gopath/src/github.com/kata-containers# cd /home/ubuntu
root@ubuntu:/home/ubuntu# git clone https://github.com/kata-containers/packaging.git
Cloning into 'packaging'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 7676 (delta 6), reused 21 (delta 3), pack-reused 7639
Receiving objects: 100% (7676/7676), 7.35 MiB | 5.73 MiB/s, done.
Resolving deltas: 100% (4291/4291), done.
root@ubuntu:/home/ubuntu# ls
anotherping     cup   dirB  eoan-arm64.img                  go              kata-linux-5.4.60-89  kernel_module  nfsroot  packaging  qemu_learn      qemu.sh      runc       soft_s   test            txt    work
containerddemo  dirA  dirC  eoan-server-cloudimg-arm64.img  image_build.sh  kata.log              mysock         overlay  qemu5.1    qemu_learn.tgz  qemu.sh.bak  server.py  stat.sh  test_container  v1.18
root@ubuntu:/home/ubuntu# cd packaging/
root@ubuntu:/home/ubuntu/packaging# go get -d -v ./...
github.com/marcov/obsgo (download)

 

root@ubuntu:/home/ubuntu/packaging# go get -d -v ./...
github.com/marcov/obsgo (download)
unrecognized import path "golang.org/x/sys/unix": https fetch: Get "https://golang.org/x/sys/unix?go-get=1": dial tcp 216.239.37.1:443: i/o timeout
get "gopkg.in/cheggaaa/pb.v1": found meta tag get.metaImport{Prefix:"gopkg.in/cheggaaa/pb.v1", VCS:"git", RepoRoot:"https://gopkg.in/cheggaaa/pb.v1"} at //gopkg.in/cheggaaa/pb.v1?go-get=1
gopkg.in/cheggaaa/pb.v1 (download)
github.com/mattn/go-runewidth (download)
github.com/mlafeldt/pkgcloud (download)
github.com/peterhellberg/link (download)
root@ubuntu:/home/ubuntu/packaging# cd  /opt/gopath/src/github.com/kata-containers/packaging
bash: cd: /opt/gopath/src/github.com/kata-containers/packaging: No such file or directory
root@ubuntu:/home/ubuntu/packaging# ls
artifact-list.sh  ccloudvm  cmd  CODE_OF_CONDUCT.md  CODEOWNERS  CONTRIBUTING.md  Jenkinsfiles  kata-deploy  kernel  LICENSE  Makefile  obs-packaging  qemu  README.md  release  scripts  snap  static-build  tests  VERSION
root@ubuntu:/home/ubuntu/packaging# cd ..
root@ubuntu:/home/ubuntu# mv packaging/ /opt/gopath/src/github.com/kata-containers/
root@ubuntu:/home/ubuntu# cd qemu5.1/qemu/
root@ubuntu:/home/ubuntu/qemu5.1/qemu#  ${GOPATH}/src/github.com/kata-containers/packaging/scripts/configure-hypervisor.sh qemu > kata.cfg
root@ubuntu:/home/ubuntu/qemu5.1/qemu# 

 

The following packages were automatically installed and are no longer required:
  golang-1.10-go golang-1.10-src golang-src
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  ninja-build
0 upgraded, 1 newly installed, 0 to remove and 180 not upgraded.
Need to get 82.2 kB of archives.
After this operation, 271 kB of additional disk space will be used.
Get:1 http://hk.ports.ubuntu.com/ubuntu-ports bionic/universe arm64 ninja-build arm64 1.8.2-1 [82.2 kB]
Fetched 82.2 kB in 2s (35.1 kB/s)                     
Selecting previously unselected package ninja-build.
(Reading database ... 127105 files and directories currently installed.)
Preparing to unpack .../ninja-build_1.8.2-1_arm64.deb ...
Unpacking ninja-build (1.8.2-1) ...

 

 

Install a hypervisor
When setting up Kata using a packaged installation method, the QEMU VMM is installed automatically. Cloud-Hypervisor and Firecracker VMMs are available from the release tarballs. You may choose to manually build your VMM/hypervisor.

Build a custom QEMU
Kata Containers makes use of upstream QEMU branch. The exact version and repository utilized can be found by looking at the runtime's versions file

Kata often utilizes patches for not-yet-upstream fixes for components, including QEMU. These can be found in the packaging repository in the QEMU directory.

To build utilizing the same options as Kata, you should make use of the configure-hypervisor.sh script. For example:

$ go get -d github.com/kata-containers/packaging
$ cd $your_qemu_directory
$ ${GOPATH}/src/github.com/kata-containers/packaging/scripts/configure-hypervisor.sh qemu > kata.cfg
$ eval ./configure "$(cat kata.cfg)"
$ make -j $(nproc)
$ sudo -E make install
See the static-build script for QEMU for a reference on how to get, setup, configure and build QEMU for Kata.

Build a custom QEMU for aarch64/arm64 - REQUIRED
Note:

You should only do this step if you are on aarch64/arm64.
You should include Eric Auger's latest PCDIMM/NVDIMM patches which are under upstream review for supporting NVDIMM on aarch64.
You could build the custom qemu-system-aarch64 as required with the following command:

$ go get -d github.com/kata-containers/tests
$ script -fec 'sudo -E ${GOPATH}/src/github.com/kata-containers/tests/.ci/install_qemu.sh'

 

 apt-get install gcc-5 g++-5
root@cloud:/home/ubuntu/glib-2.40.0# rm /usr/bin/gcc
root@cloud:/home/ubuntu/glib-2.40.0# rm /usr/bin/g++
root@cloud:/home/ubuntu/glib-2.40.0# ln -s /usr/bin/gcc-5 /usr/bin/gcc
root@cloud:/home/ubuntu/glib-2.40.0# ln -s /usr/bin/g++-5 /usr/bin/g++
root@cloud:/home/ubuntu/glib-2.40.0# 

 其他版本gcc有问题

posted on 2020-12-09 17:58  tycoon3  阅读(616)  评论(0编辑  收藏  举报

导航