Preparing the Environment

Usage

  • StratoVirt can run on VMs with the x86_64 or AArch64 processor architecture.
  • You are advised to compile, commission, and deploy StratoVirt on openEuler 20.03 SP2.
  • StratoVirt can run with non-root permissions.

Environment Requirements

The following are required in the environment for running StratoVirt:

  • /dev/vhost-vsock device (for implementing the MMIO)
  • nmap tool
  • Kernel and rootfs images

Preparing Devices and Tools

  • To run StratoVirt, the MMIO device must be implemented. Therefore, before running StratoVirt, ensure that the /dev/vhost-vsock device exists.

    Check whether the device exists.

    $ ls /dev/vhost-vsock
    /dev/vhost-vsock
    

    If the device does not exist, run the following command to generate it:

    $ modprobe vhost_vsock
    
  • To use QMP commands, install the nmap tool first. After configuring the yum source, run the following command to install the tool:

    # yum install nmap
    

Preparing Images

Creating the Kernel Image

StratoVirt of the current version supports only the PE kernel image of the x86_64 and AArch64 platforms. The kernel image in PE format can be generated by using the following method:

  1. Run the following commands to obtain the kernel source code of openEuler:

    $ git clone https://gitee.com/openeuler/kernel
    $ cd kernel
    
  2. Run the following command to check and switch the kernel version to 4.19:

    $ git checkout kernel-4.19
    
  3. Configure and compile the Linux kernel. It is better to use the recommended configuration file (Obtain configuration file). Copy it to the kernel directory, and rename it as .config. You can also run the following command to configure the kernel as prompted:

    $ make menuconfig
    
  4. Run the following command to create and convert the kernel image to the PE format. The converted image is vmlinux.bin.

    $ make -j vmlinux && objcopy -O binary vmlinux vmlinux.bin
    
  5. If you want to use the kernel in bzImzge format on the x86 platform, run the following command:

    $ make -j bzImage
    

Creating the Rootfs Image

The rootfs image is a file system image. When StratoVirt is started, the ext4 image with init can be loaded. To create an ext4 rootfs image, perform the following steps:

  1. Prepare a file with a proper size (for example, create a file with the size of 10 GiB in /home).

    $ cd /home
    $ dd if=/dev/zero of=./rootfs.ext4 bs=1G count=10
    
  2. Create an empty ext4 file system on this file.

    $ mkfs.ext4 ./rootfs.ext4
    
  3. Mount the file image. Create the /mnt/rootfs directory and mount rootfs.ext4 to the directory as user root.

    $ mkdir /mnt/rootfs
    # Return to the directory where the file system is created, for example, **/home**.
    $ cd /home
    $ sudo mount ./rootfs.ext4 /mnt/rootfs && cd /mnt/rootfs
    
  4. Obtain the latest alpine-mini rootfs of the corresponding processor architecture.

    $ arch=`uname -m`
    $ wget http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/$arch/alpine-   minirootfs-3.13.0-$arch.tar.gz -O alpine-minirootfs.tar.gz
    $ tar -zxvf alpine-minirootfs.tar.gz
    $ rm alpine-minirootfs.tar.gz
    
  5. Run the following command to create a simple /sbin/init for the ext4 file image:

    $ rm sbin/init; touch sbin/init && cat > sbin/init <<EOF
    #! /bin/sh
    mount -t devtmpfs dev /dev
    mount -t proc proc /proc
    mount -t sysfs sysfs /sys
    ip link set up dev lo
    
    exec /sbin/getty -n -l /bin/sh 115200 /dev/ttyS0
    poweroff -f
    EOF
    
    sudo chmod +x sbin/init
    
  6. Uninstall the rootfs image.

    $ cd /home; umount /mnt/rootfs
    

    The rootfs is created successfully. You can use the ext4 rootfs image file rootfs.ext4, which is stored in the /home directory.

有奖捉虫

“有虫”文档片段

存在的问题

提交类型 issue
有点复杂...
找人问问吧。
PR
小问题,全程线上修改...
一键搞定!
问题类型
规范和低错类

● 错别字或拼写错误;标点符号使用错误;

● 链接错误、空单元格、格式错误;

● 英文中包含中文字符;

● 界面和描述不一致,但不影响操作;

● 表述不通顺,但不影响理解;

● 版本号不匹配:如软件包名称、界面版本号;

易用性

● 关键步骤错误或缺失,无法指导用户完成任务;

● 缺少必要的前提条件、注意事项等;

● 图形、表格、文字等晦涩难懂;

● 逻辑不清晰,该分类、分项、分步骤的没有给出;

正确性

● 技术原理、功能、规格等描述和软件不一致,存在错误;

● 原理图、架构图等存在错误;

● 命令、命令参数等错误;

● 代码片段错误;

● 命令无法完成对应功能;

● 界面错误,无法指导操作;

风险提示

● 对重要数据或系统存在风险的操作,缺少安全提示;

内容合规

● 违反法律法规,涉及政治、领土主权等敏感词;

● 内容侵权;

您对文档的总体满意度

非常不满意
非常满意
创Issue赢奖品
根据您的反馈,会自动生成issue模板。您只需点击按钮,创建issue即可。