diff --git a/0001-docs-update-readme.md-for-building-via-musl-toolchai.patch b/0001-docs-update-readme.md-for-building-via-musl-toolchai.patch new file mode 100644 index 0000000000000000000000000000000000000000..b534afc2c3bba2f85b22f175187aeac9fc6ed5fd --- /dev/null +++ b/0001-docs-update-readme.md-for-building-via-musl-toolchai.patch @@ -0,0 +1,84 @@ +From 54d88e2b9061cc1846d435e99aa6b474d7282b5f Mon Sep 17 00:00:00 2001 +From: Zhigang Wang +Date: Fri, 7 May 2021 18:26:19 +0800 +Subject: [PATCH] docs: update readme.md for building via musl toolchain + +Signed-off-by: Zhigang Wang +--- + README.md | 33 +++++++++++++++++++++++---------- + 1 file changed, 23 insertions(+), 10 deletions(-) + +diff --git a/README.md b/README.md +index ca9b146..fa361f3 100644 +--- a/README.md ++++ b/README.md +@@ -1,16 +1,24 @@ + # StratoVirt +-StratoVirt is an enterprise-level virtualization platform for cloud data centers in the computing industry. It implements a set of architecture that supports three scenarios: virtual machines, containers, and serverless. StratoVirt has key technological competitive advantages in light weight and low noise, software and hardware coordination, and Rust language-level security. ++StratoVirt is an enterprise-level virtualization platform for cloud data centers ++in the computing industry. It implements a set of architecture that supports ++three scenarios: virtual machines, containers, and serverless computing. + +-StratoVirt reserves interface and design for importing more features, even standard virtualization. ++StratoVirt has competitive advantages in light weight and low noise, software ++and hardware coordination, and Rust language-level security. ++ ++StratoVirt reserves interface and design for importing more features, even ++evaluates to standard virtualization. + + ## How to start + + ### Preparation + Before building StratoVirt, make sure that Rust language and Cargo have already +-been installed. If not, you can find installation guidance from the following link: ++been installed. If not, you can find installation guidance via following link: + + https://www.rust-lang.org/tools/install + ++And it will get smaller memory overhead if you prepare musl toolchain for rust. ++ + ### Build StratoVirt + To build StratoVirt, clone the project and build it first: + ```sh +@@ -39,18 +47,21 @@ $ ./target/release/stratovirt \ + -serial stdio + ``` + +-The detailed guidance of making rootfs, compiling kernel and building StratoVirt can be found +-in [StratoVirt QuickStart](./docs/quickstart.md). ++The detailed guidance of making rootfs, compiling kernel and building StratoVirt ++can be found in [StratoVirt QuickStart](./docs/quickstart.md). + +-StratoVirt supports much more features, the detailed guidance can be found in [Configuration Guidebook](docs/config_guidebook.md). ++StratoVirt supports much more features, the detailed guidance can be found in ++[Configuration Guidebook](docs/config_guidebook.md). + + ## Design + +-To get more details about StratoVirt's core architecture design, refer to [StratoVirt design](./docs/design.md). ++To get more details about StratoVirt's core architecture design, refer to ++[StratoVirt design](./docs/design.md). + + ## How to contribute +-We welcome new contributors! And we are happy to provide guidance and help for new contributors. +-StratoVirt follows Rust formatting conventions, which can be found at: ++We welcome new contributors! And we are happy to provide guidance and help for ++new contributors. StratoVirt follows Rust formatting conventions, which can be ++found at: + + https://github.com/rust-dev-tools/fmt-rfcs/tree/master/guide + https://github.com/rust-lang/rust-clippy +@@ -59,7 +70,9 @@ You can get more information about StratoVirt at: + + https://gitee.com/openeuler/stratovirt/wikis + +-If you find a bug or have some ideas, please send an email to the [virt mailing list](https://mailweb.openeuler.org/postorius/lists/virt.openeuler.org/) or submit an [issue](https://gitee.com/openeuler/stratovirt/issues). ++If you find a bug or have some ideas, please send an email to the ++[virt mailing list](https://mailweb.openeuler.org/postorius/lists/virt.openeuler.org/) ++or submit an [issue](https://gitee.com/openeuler/stratovirt/issues). + + ## Licensing + StratoVirt is licensed under the Mulan PSL v2. +-- +2.25.1 + diff --git a/0002-docs-turn-on-the-option-switch-of-virtio-rng-for-x86.patch b/0002-docs-turn-on-the-option-switch-of-virtio-rng-for-x86.patch new file mode 100644 index 0000000000000000000000000000000000000000..96c3be48efbc81344fdedcd87f440da8de21462a --- /dev/null +++ b/0002-docs-turn-on-the-option-switch-of-virtio-rng-for-x86.patch @@ -0,0 +1,72 @@ +From 6aed6d53acb4a86f7304b800c08cdfb5ffbba83d Mon Sep 17 00:00:00 2001 +From: Fei Xu +Date: Sat, 8 May 2021 11:38:34 +0800 +Subject: [PATCH] docs: turn on the option switch of virtio rng for x86_64 + kernel configuration and add guest kernel configuration for virtio rng in + config_guidebook.md + +Signed-off-by: Fei Xu +--- + docs/config_guidebook.md | 5 +++++ + docs/kernel_config/config_openeuler_4.19_x86_64 | 5 ++++- + docs/kernel_config/config_openeuler_5.10_x86_64 | 5 ++++- + 3 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/docs/config_guidebook.md b/docs/config_guidebook.md +index f31ec92..4f96aaa 100644 +--- a/docs/config_guidebook.md ++++ b/docs/config_guidebook.md +@@ -414,6 +414,10 @@ This feature can prevent OOM occur in guest. + ### 2.8 Virtio-rng + Virtio rng is a paravirtualized random number generator device, it provides a hardware rng device to the guest. + ++If you want use it, need: ++ ++* Guest kernel config: CONFIG_HW_RANDOM=y CONFIG_HW_RANDOM_VIA=y CONFIG_HW_RANDOM_VIRTIO=y ++ + Only two property is supported for virtio-rng. + * random_file: the path of character device generates with random number in host + * bytes_per_sec: the number of bytes that the character device generates with a random number per second, +@@ -429,6 +433,7 @@ it should satisfy `64<=bytes_per_sec<1000000000` + "bytes_per_sec": 1000000 + }, + } ++``` + + ## 3. StratoVirt Management + +diff --git a/docs/kernel_config/config_openeuler_4.19_x86_64 b/docs/kernel_config/config_openeuler_4.19_x86_64 +index f3e1ad9..a4545ea 100644 +--- a/docs/kernel_config/config_openeuler_4.19_x86_64 ++++ b/docs/kernel_config/config_openeuler_4.19_x86_64 +@@ -1302,7 +1302,10 @@ CONFIG_SERIAL_CORE_CONSOLE=y + CONFIG_HVC_DRIVER=y + CONFIG_VIRTIO_CONSOLE=y + # CONFIG_IPMI_HANDLER is not set +-# CONFIG_HW_RANDOM is not set ++CONFIG_HW_RANDOM=y ++# CONFIG_HW_RANDOM_TIMERIOMEM is not set ++CONFIG_HW_RANDOM_VIA=y ++CONFIG_HW_RANDOM_VIRTIO=y + # CONFIG_NVRAM is not set + # CONFIG_MWAVE is not set + # CONFIG_RAW_DRIVER is not set +diff --git a/docs/kernel_config/config_openeuler_5.10_x86_64 b/docs/kernel_config/config_openeuler_5.10_x86_64 +index 71e3480..5ff42d2 100644 +--- a/docs/kernel_config/config_openeuler_5.10_x86_64 ++++ b/docs/kernel_config/config_openeuler_5.10_x86_64 +@@ -1369,7 +1369,10 @@ CONFIG_HVC_DRIVER=y + # CONFIG_SERIAL_DEV_BUS is not set + CONFIG_VIRTIO_CONSOLE=y + # CONFIG_IPMI_HANDLER is not set +-# CONFIG_HW_RANDOM is not set ++CONFIG_HW_RANDOM=y ++# CONFIG_HW_RANDOM_TIMERIOMEM is not set ++CONFIG_HW_RANDOM_VIA=y ++CONFIG_HW_RANDOM_VIRTIO=y + # CONFIG_MWAVE is not set + # CONFIG_DEVMEM is not set + # CONFIG_DEVKMEM is not set +-- +2.25.1 + diff --git a/0003-doc-fix-an-uncorrect-link-for-build_guide-in-quickst.patch b/0003-doc-fix-an-uncorrect-link-for-build_guide-in-quickst.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b3eeb849c4f06fb5434be1c471543cd197d84e9 --- /dev/null +++ b/0003-doc-fix-an-uncorrect-link-for-build_guide-in-quickst.patch @@ -0,0 +1,41 @@ +From d14ed26839876832318aedfc638628d23091f2f4 Mon Sep 17 00:00:00 2001 +From: Wei Gao +Date: Mon, 17 May 2021 09:32:50 +0800 +Subject: [PATCH] doc: fix an uncorrect link for `build_guide` in + `quickstart.md`. + +Signed-off-by: Wei Gao +--- + docs/boot_source.md | 2 +- + docs/quickstart.md | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/docs/boot_source.md b/docs/boot_source.md +index a4e4389..22b2935 100644 +--- a/docs/boot_source.md ++++ b/docs/boot_source.md +@@ -65,7 +65,7 @@ Rootfs image is a file system image. An EXT4-format image with `/sbin/init` can + + ```shell + $ 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 ++ $ wget http://dl-cdn.alpinelinux.org/alpine/v3.13/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 + ``` +diff --git a/docs/quickstart.md b/docs/quickstart.md +index 842c3ca..5a2b194 100644 +--- a/docs/quickstart.md ++++ b/docs/quickstart.md +@@ -26,7 +26,7 @@ $ sudo yum install stratovirt + + Now you can find StratoVirt binary with path: `/usr/bin/stratovirt`. + +-If you'd like to build StratoVirt yourself, you should check out the [build_guide](../build_guide.md). ++If you'd like to build StratoVirt yourself, you should check out the [build_guide](./build_guide.md). + + ## 3. Running StratoVirt + +-- +2.25.1 + diff --git a/0004-update-rootfs-disk-image-description-in-README.ch.md.patch b/0004-update-rootfs-disk-image-description-in-README.ch.md.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf1fed2bc15e355351f94b828fc16ccd9a79ca45 --- /dev/null +++ b/0004-update-rootfs-disk-image-description-in-README.ch.md.patch @@ -0,0 +1,25 @@ +From cb7bc20a6a9f09d50f5021aef2332c20efa7c457 Mon Sep 17 00:00:00 2001 +From: KuhnChen +Date: Mon, 17 May 2021 16:42:01 +0800 +Subject: [PATCH] update rootfs disk image description in README.ch.md + +--- + README.ch.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/README.ch.md b/README.ch.md +index 2637baf..50aec7b 100644 +--- a/README.ch.md ++++ b/README.ch.md +@@ -22,7 +22,7 @@ $ cargo build --release + ### 运行软件 + 为了快速上手StratoVirt,需要准备 + * PE格式或bzImage格式(仅x86_64)的Linux内核镜像 +-* EXT4格式的rootfs镜像 ++* ext4文件系统,raw格式rootfs的镜像 + + 可以通过以下链接获取我们准备好的linux内核镜像和rootfs镜像: + +-- +2.25.1 + diff --git a/0005-update-rootfs-disk-image-description-in-README.md.patch b/0005-update-rootfs-disk-image-description-in-README.md.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d399e978d46de8de793404529bdc70962a7ebee --- /dev/null +++ b/0005-update-rootfs-disk-image-description-in-README.md.patch @@ -0,0 +1,25 @@ +From 3bd60055b7b34edbc67e8f46e34e2153a165569e Mon Sep 17 00:00:00 2001 +From: KuhnChen +Date: Mon, 17 May 2021 17:41:17 +0800 +Subject: [PATCH] update rootfs disk image description in README.md. + +--- + README.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/README.md b/README.md +index fa361f3..44f4bcd 100644 +--- a/README.md ++++ b/README.md +@@ -31,7 +31,7 @@ Now you can find StratoVirt binary in `target/release/stratovirt`. + ### Run a VM with StratoVirt + To run StratoVirt quickly, requires + * A PE or bzImage (only x86_64) format Linux kernel +-* An EXT4-format rootfs image ++* An EXT4 filesystem, raw format rootfs disk image + + You can get kernel and rootfs image from the following link: + +-- +2.25.1 + diff --git a/0006-StratoVirt-clear-clippy-warnings-for-updating-rust-1.patch b/0006-StratoVirt-clear-clippy-warnings-for-updating-rust-1.patch new file mode 100644 index 0000000000000000000000000000000000000000..c06460bc055f861c4c163327733bd699604319f1 --- /dev/null +++ b/0006-StratoVirt-clear-clippy-warnings-for-updating-rust-1.patch @@ -0,0 +1,880 @@ +From ed34a5a14129691ff62122405071192e7ce9180e Mon Sep 17 00:00:00 2001 +From: Fei Xu +Date: Tue, 25 May 2021 09:13:30 +0800 +Subject: [PATCH] StratoVirt: clear clippy warnings for updating rust 1.51.0 + +Signed-off-by: Fei Xu +--- + address_space/src/region.rs | 1 + + boot_loader/src/lib.rs | 1 + + boot_loader/src/x86_64/mptable.rs | 2 + + cpu/src/aarch64/mod.rs | 34 ++++++++-------- + cpu/src/lib.rs | 8 +++- + cpu/src/x86_64/mod.rs | 2 + + devices/src/interrupt_controller/mod.rs | 2 + + devices/src/legacy/pl031.rs | 3 +- + machine_manager/src/qmp/mod.rs | 27 ++++++------- + machine_manager/src/qmp/qmp_schema.rs | 52 +++++++++++++------------ + machine_manager/src/socket.rs | 1 + + micro_vm/src/lib.rs | 22 ++++++----- + util/src/aio/libaio.rs | 14 +++---- + util/src/aio/mod.rs | 8 ++-- + util/src/arg_parser.rs | 20 +++++----- + util/src/device_tree.rs | 1 + + util/src/logger.rs | 6 +-- + virtio/src/balloon.rs | 4 +- + virtio/src/block.rs | 11 +++--- + virtio/src/net.rs | 2 +- + virtio/src/vhost/kernel/net.rs | 2 +- + virtio/src/vhost/kernel/vsock.rs | 3 +- + 22 files changed, 119 insertions(+), 107 deletions(-) + +diff --git a/address_space/src/region.rs b/address_space/src/region.rs +index 86f807c..235b195 100644 +--- a/address_space/src/region.rs ++++ b/address_space/src/region.rs +@@ -18,6 +18,7 @@ use crate::errors::{ErrorKind, Result, ResultExt}; + use crate::{AddressRange, AddressSpace, FileBackend, GuestAddress, HostMemMapping, RegionOps}; + + /// Types of Region. ++#[allow(clippy::upper_case_acronyms)] + #[derive(Debug, PartialEq, Eq, Copy, Clone)] + pub enum RegionType { + /// Ram type. +diff --git a/boot_loader/src/lib.rs b/boot_loader/src/lib.rs +index 2687377..4be04be 100644 +--- a/boot_loader/src/lib.rs ++++ b/boot_loader/src/lib.rs +@@ -78,6 +78,7 @@ extern crate log; + #[macro_use] + extern crate error_chain; + ++#[allow(clippy::upper_case_acronyms)] + #[cfg(target_arch = "aarch64")] + mod aarch64; + #[cfg(target_arch = "x86_64")] +diff --git a/boot_loader/src/x86_64/mptable.rs b/boot_loader/src/x86_64/mptable.rs +index b8b7bf6..9d0d3f0 100644 +--- a/boot_loader/src/x86_64/mptable.rs ++++ b/boot_loader/src/x86_64/mptable.rs +@@ -163,6 +163,7 @@ impl BusEntry { + } + + #[repr(C)] ++#[allow(clippy::upper_case_acronyms)] + #[derive(Debug, Default, Copy, Clone)] + pub struct IOApicEntry { + type_: u8, +@@ -189,6 +190,7 @@ impl IOApicEntry { + } + + #[repr(C)] ++#[allow(clippy::upper_case_acronyms)] + #[derive(Debug, Default, Copy, Clone)] + pub struct IOInterruptEntry { + type_: u8, +diff --git a/cpu/src/aarch64/mod.rs b/cpu/src/aarch64/mod.rs +index ef4c912..d717912 100644 +--- a/cpu/src/aarch64/mod.rs ++++ b/cpu/src/aarch64/mod.rs +@@ -62,62 +62,62 @@ pub enum Arm64CoreRegs { + USER_FPSIMD_STATE_RES(usize), + } + +-#[allow(clippy::zero_ptr)] +-impl Into for Arm64CoreRegs { +- fn into(self) -> u64 { ++impl From for u64 { ++ fn from(elem: Arm64CoreRegs) -> u64 { + let register_size; +- let regid = match self { ++ let regid; ++ match elem { + Arm64CoreRegs::KVM_USER_PT_REGS => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, regs) ++ regid = offset_of!(kvm_regs, regs) + } + Arm64CoreRegs::KVM_SP_EL1 => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, sp_el1) ++ regid = offset_of!(kvm_regs, sp_el1) + } + Arm64CoreRegs::KVM_ELR_EL1 => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, elr_el1) ++ regid = offset_of!(kvm_regs, elr_el1) + } + Arm64CoreRegs::KVM_SPSR(idx) if idx < KVM_NR_SPSR as usize => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, spsr) + idx * 8 ++ regid = offset_of!(kvm_regs, spsr) + idx * 8 + } + Arm64CoreRegs::KVM_USER_FPSIMD_STATE => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, fp_regs) ++ regid = offset_of!(kvm_regs, fp_regs) + } + Arm64CoreRegs::USER_PT_REG_REGS(idx) if idx < 31 => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, regs, user_pt_regs, regs) + idx * 8 ++ regid = offset_of!(kvm_regs, regs, user_pt_regs, regs) + idx * 8 + } + Arm64CoreRegs::USER_PT_REG_SP => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, regs, user_pt_regs, sp) ++ regid = offset_of!(kvm_regs, regs, user_pt_regs, sp) + } + Arm64CoreRegs::USER_PT_REG_PC => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, regs, user_pt_regs, pc) ++ regid = offset_of!(kvm_regs, regs, user_pt_regs, pc) + } + Arm64CoreRegs::USER_PT_REG_PSTATE => { + register_size = KVM_REG_SIZE_U64; +- offset_of!(kvm_regs, regs, user_pt_regs, pstate) ++ regid = offset_of!(kvm_regs, regs, user_pt_regs, pstate) + } + Arm64CoreRegs::USER_FPSIMD_STATE_VREGS(idx) if idx < 32 => { + register_size = KVM_REG_SIZE_U128; +- offset_of!(kvm_regs, fp_regs, user_fpsimd_state, vregs) + idx * 16 ++ regid = offset_of!(kvm_regs, fp_regs, user_fpsimd_state, vregs) + idx * 16 + } + Arm64CoreRegs::USER_FPSIMD_STATE_FPSR => { + register_size = KVM_REG_SIZE_U32; +- offset_of!(kvm_regs, fp_regs, user_fpsimd_state, fpsr) ++ regid = offset_of!(kvm_regs, fp_regs, user_fpsimd_state, fpsr) + } + Arm64CoreRegs::USER_FPSIMD_STATE_FPCR => { + register_size = KVM_REG_SIZE_U32; +- offset_of!(kvm_regs, fp_regs, user_fpsimd_state, fpcr) ++ regid = offset_of!(kvm_regs, fp_regs, user_fpsimd_state, fpcr) + } + Arm64CoreRegs::USER_FPSIMD_STATE_RES(idx) if idx < 2 => { + register_size = 128; +- offset_of!(kvm_regs, fp_regs, user_fpsimd_state, __reserved) + idx * 8 ++ regid = offset_of!(kvm_regs, fp_regs, user_fpsimd_state, __reserved) + idx * 8 + } + _ => panic!("No such Register"), + }; +diff --git a/cpu/src/lib.rs b/cpu/src/lib.rs +index b32c709..eb489dc 100644 +--- a/cpu/src/lib.rs ++++ b/cpu/src/lib.rs +@@ -37,6 +37,7 @@ extern crate machine_manager; + #[macro_use] + extern crate util; + ++#[allow(clippy::upper_case_acronyms)] + #[cfg(target_arch = "aarch64")] + mod aarch64; + #[cfg(target_arch = "x86_64")] +@@ -164,6 +165,7 @@ thread_local! { + } + + /// Trait to handle `CPU` lifetime. ++#[allow(clippy::upper_case_acronyms)] + pub trait CPUInterface { + /// Realize `CPU` structure, set registers value for `CPU`. + fn realize(&self, vm_fd: &Arc, boot: &CPUBootConfig) -> Result<()>; +@@ -198,6 +200,7 @@ pub trait CPUInterface { + } + + /// `CPU` is a wrapper around creating and using a kvm-based VCPU. ++#[allow(clippy::upper_case_acronyms)] + pub struct CPU { + /// ID of this virtual CPU, `0` means this cpu is primary `CPU`. + id: u8, +@@ -417,11 +420,11 @@ impl CPUInterface for CPU { + } + + if QmpChannel::is_connected() { +- let shutdown_msg = schema::SHUTDOWN { ++ let shutdown_msg = schema::Shutdown { + guest: true, + reason: "guest-shutdown".to_string(), + }; +- event!(SHUTDOWN; shutdown_msg); ++ event!(Shutdown; shutdown_msg); + } + + Ok(()) +@@ -513,6 +516,7 @@ impl CPUInterface for CPU { + } + + /// The struct to handle events in cpu thread. ++#[allow(clippy::upper_case_acronyms)] + struct CPUThreadWorker { + thread_cpu: Arc, + } +diff --git a/cpu/src/x86_64/mod.rs b/cpu/src/x86_64/mod.rs +index 2880778..83635d4 100644 +--- a/cpu/src/x86_64/mod.rs ++++ b/cpu/src/x86_64/mod.rs +@@ -42,6 +42,7 @@ const MSR_LIST: &[u32] = &[ + const MSR_IA32_MISC_ENABLE: u32 = 0x01a0; + const MSR_IA32_MISC_ENABLE_FAST_STRING: u64 = 0x1; + ++#[allow(clippy::upper_case_acronyms)] + #[derive(Default)] + /// X86 CPU booting configure information + pub struct X86CPUBootConfig { +@@ -61,6 +62,7 @@ pub struct X86CPUBootConfig { + pub pml4_start: u64, + } + ++#[allow(clippy::upper_case_acronyms)] + #[derive(Default, Copy, Clone)] + pub struct X86CPU { + id: u32, +diff --git a/devices/src/interrupt_controller/mod.rs b/devices/src/interrupt_controller/mod.rs +index 2a00aa8..123c552 100644 +--- a/devices/src/interrupt_controller/mod.rs ++++ b/devices/src/interrupt_controller/mod.rs +@@ -23,6 +23,8 @@ + //! ## Platform Support + //! + //! - `aarch64` ++ ++#[allow(clippy::upper_case_acronyms)] + #[cfg(target_arch = "aarch64")] + mod aarch64; + +diff --git a/devices/src/legacy/pl031.rs b/devices/src/legacy/pl031.rs +index 9eefa2b..023c04a 100644 +--- a/devices/src/legacy/pl031.rs ++++ b/devices/src/legacy/pl031.rs +@@ -51,6 +51,7 @@ const RTC_ICR: u64 = 0x1c; + const RTC_PERIPHERAL_ID: [u8; 8] = [0x31, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1]; + + /// Pl031 structure. ++#[allow(clippy::upper_case_acronyms)] + pub struct PL031 { + /// Match register value. + mr: u32, +@@ -131,7 +132,7 @@ impl PL031 { + impl SysBusDevOps for PL031 { + /// Read data from registers by guest. + fn read(&mut self, data: &mut [u8], _base: GuestAddress, offset: u64) -> bool { +- if offset >= 0xFE0 && offset < 0x1000 { ++ if (0xFE0..0x1000).contains(&offset) { + let value = u32::from(RTC_PERIPHERAL_ID[((offset - 0xFE0) >> 2) as usize]); + match data.len() { + 1 => data[0] = value as u8, +diff --git a/machine_manager/src/qmp/mod.rs b/machine_manager/src/qmp/mod.rs +index a680512..d86c3b4 100644 +--- a/machine_manager/src/qmp/mod.rs ++++ b/machine_manager/src/qmp/mod.rs +@@ -70,9 +70,9 @@ static mut QMP_CHANNEL: Option> = None; + /// #[macro_use] + /// use machine_manager::qmp::*; + /// +-/// event!(SHUTDOWN; shutdown_msg); +-/// event!(STOP); +-/// event!(RESUME); ++/// event!(Shutdown; shutdown_msg); ++/// event!(Stop); ++/// event!(Resume); + /// ``` + #[macro_export] + macro_rules! event { +@@ -364,11 +364,11 @@ pub fn handle_qmp( + + // handle shutdown command + if shutdown_flag { +- let shutdown_msg = schema::SHUTDOWN { ++ let shutdown_msg = schema::Shutdown { + guest: false, + reason: "host-qmp-quit".to_string(), + }; +- event!(SHUTDOWN; shutdown_msg); ++ event!(Shutdown; shutdown_msg); + TempCleaner::clean(); + + std::io::stdin() +@@ -497,10 +497,7 @@ impl QmpChannel { + /// + /// * `name` - Name of file descriptor. + pub fn get_fd(name: &str) -> Option { +- match Self::inner().fds.read().unwrap().get(name) { +- Some(fd) => Some(*fd), +- None => None, +- } ++ Self::inner().fds.read().unwrap().get(name).copied() + } + + /// Send a `QmpEvent` to client. +@@ -603,7 +600,7 @@ mod tests { + r#"{"event":"STOP","data":{},"timestamp":{"seconds":1575531524,"microseconds":91519}}"#; + let qmp_event: schema::QmpEvent = serde_json::from_str(&event_json).unwrap(); + match qmp_event { +- schema::QmpEvent::STOP { ++ schema::QmpEvent::Stop { + data: _, + timestamp: _, + } => { +@@ -646,12 +643,12 @@ mod tests { + QmpChannel::bind_writer(SocketRWHandler::new(socket.get_stream_fd())); + + // 1.send no-content event +- event!(STOP); ++ event!(Stop); + let length = client.read(&mut buffer).unwrap(); + let qmp_event: schema::QmpEvent = + serde_json::from_str(&(String::from_utf8_lossy(&buffer[..length]))).unwrap(); + match qmp_event { +- schema::QmpEvent::STOP { ++ schema::QmpEvent::Stop { + data: _, + timestamp: _, + } => { +@@ -661,16 +658,16 @@ mod tests { + } + + // 2.send with-content event +- let shutdown_event = schema::SHUTDOWN { ++ let shutdown_event = schema::Shutdown { + guest: true, + reason: "guest-shutdown".to_string(), + }; +- event!(SHUTDOWN; shutdown_event); ++ event!(Shutdown; shutdown_event); + let length = client.read(&mut buffer).unwrap(); + let qmp_event: schema::QmpEvent = + serde_json::from_str(&(String::from_utf8_lossy(&buffer[..length]))).unwrap(); + match qmp_event { +- schema::QmpEvent::SHUTDOWN { data, timestamp: _ } => { ++ schema::QmpEvent::Shutdown { data, timestamp: _ } => { + assert_eq!(data.guest, true); + assert_eq!(data.reason, "guest-shutdown".to_string()); + } +diff --git a/machine_manager/src/qmp/qmp_schema.rs b/machine_manager/src/qmp/qmp_schema.rs +index 340945e..c02ecbf 100644 +--- a/machine_manager/src/qmp/qmp_schema.rs ++++ b/machine_manager/src/qmp/qmp_schema.rs +@@ -19,6 +19,7 @@ pub use serde_json::Value as Any; + use crate::qmp::{Command, Empty, Event, TimeStamp}; + + /// A error enum for qmp ++#[allow(clippy::upper_case_acronyms)] + #[derive(Debug, Clone, Serialize, Deserialize)] + pub enum QmpErrorClass { + #[serde(rename = "GenericError")] +@@ -538,6 +539,7 @@ impl Command for query_hotpluggable_cpus { + } + } + ++#[allow(clippy::upper_case_acronyms)] + #[derive(Default, Debug, Clone, Serialize, Deserialize)] + pub struct HotpluggableCPU { + #[serde(rename = "type")] +@@ -772,7 +774,7 @@ impl Command for getfd { + } + } + +-/// SHUTDOWN ++/// Shutdown + /// + /// Emitted when the virtual machine has shut down, indicating that StratoVirt is + /// about to exit. +@@ -783,7 +785,7 @@ impl Command for getfd { + /// will not exit, and a STOP event will eventually follow the SHUTDOWN event + #[derive(Debug, Clone, Serialize, Deserialize)] + #[serde(deny_unknown_fields)] +-pub struct SHUTDOWN { ++pub struct Shutdown { + /// If true, the shutdown was triggered by a guest request (such as + /// a guest-initiated ACPI shutdown request or other hardware-specific + /// action) rather than a host request (such as sending StratoVirt a SIGINT). +@@ -792,16 +794,16 @@ pub struct SHUTDOWN { + pub reason: String, + } + +-impl Event for SHUTDOWN { ++impl Event for Shutdown { + const NAME: &'static str = "SHUTDOWN"; + } + +-/// RESET ++/// Reset + /// + /// Emitted when the virtual machine is reset + #[derive(Debug, Clone, Serialize, Deserialize)] + #[serde(deny_unknown_fields)] +-pub struct RESET { ++pub struct Reset { + /// If true, the reset was triggered by a guest request (such as + /// a guest-initiated ACPI reboot request or other hardware-specific action + /// ) rather than a host request (such as the QMP command system_reset). +@@ -809,33 +811,33 @@ pub struct RESET { + pub guest: bool, + } + +-impl Event for RESET { ++impl Event for Reset { + const NAME: &'static str = "RESET"; + } + +-/// STOP ++/// Stop + /// + /// Emitted when the virtual machine is stopped + #[derive(Debug, Clone, Serialize, Deserialize, Default)] + #[serde(deny_unknown_fields)] +-pub struct STOP {} ++pub struct Stop {} + +-impl Event for STOP { ++impl Event for Stop { + const NAME: &'static str = "STOP"; + } + +-/// RESUME ++/// Resume + /// + /// Emitted when the virtual machine resumes execution + #[derive(Debug, Clone, Serialize, Deserialize, Default)] + #[serde(deny_unknown_fields)] +-pub struct RESUME {} ++pub struct Resume {} + +-impl Event for RESUME { ++impl Event for Resume { + const NAME: &'static str = "RESUME"; + } + +-/// DEVICE_DELETED ++/// DeviceDeleted + /// + /// Emitted whenever the device removal completion is acknowledged by the guest. + /// At this point, it's safe to reuse the specified device ID. Device removal can +@@ -851,7 +853,7 @@ impl Event for RESUME { + /// ``` + #[derive(Debug, Clone, Serialize, Deserialize)] + #[serde(deny_unknown_fields)] +-pub struct DEVICE_DELETED { ++pub struct DeviceDeleted { + /// Device name. + #[serde(rename = "device", default, skip_serializing_if = "Option::is_none")] + pub device: Option, +@@ -860,7 +862,7 @@ pub struct DEVICE_DELETED { + pub path: String, + } + +-impl Event for DEVICE_DELETED { ++impl Event for DeviceDeleted { + const NAME: &'static str = "DEVICE_DELETED"; + } + +@@ -868,31 +870,31 @@ impl Event for DEVICE_DELETED { + #[serde(tag = "event")] + pub enum QmpEvent { + #[serde(rename = "SHUTDOWN")] +- SHUTDOWN { +- data: SHUTDOWN, ++ Shutdown { ++ data: Shutdown, + timestamp: TimeStamp, + }, + #[serde(rename = "RESET")] +- RESET { data: RESET, timestamp: TimeStamp }, ++ Reset { data: Reset, timestamp: TimeStamp }, + #[serde(rename = "STOP")] +- STOP { ++ Stop { + #[serde(default)] +- data: STOP, ++ data: Stop, + timestamp: TimeStamp, + }, + #[serde(rename = "RESUME")] +- RESUME { ++ Resume { + #[serde(default)] +- data: RESUME, ++ data: Resume, + timestamp: TimeStamp, + }, + #[serde(rename = "DEVICE_DELETED")] +- DEVICE_DELETED { +- data: DEVICE_DELETED, ++ DeviceDeleted { ++ data: DeviceDeleted, + timestamp: TimeStamp, + }, + #[serde(rename = "BALLOON_CHANGED")] +- BALLOON_CHANGED { ++ BalloonChanged { + data: BalloonInfo, + timestamp: TimeStamp, + }, +diff --git a/machine_manager/src/socket.rs b/machine_manager/src/socket.rs +index 37dd176..d7b1205 100644 +--- a/machine_manager/src/socket.rs ++++ b/machine_manager/src/socket.rs +@@ -330,6 +330,7 @@ impl SocketStream { + /// Ok(()) + /// } + /// ``` ++#[allow(clippy::upper_case_acronyms)] + pub struct SocketRWHandler { + /// Socket fd to read and write message + socket_fd: RawFd, +diff --git a/micro_vm/src/lib.rs b/micro_vm/src/lib.rs +index 6380e43..7188f21 100644 +--- a/micro_vm/src/lib.rs ++++ b/micro_vm/src/lib.rs +@@ -270,16 +270,19 @@ impl LightMachine { + /// On x86_64, there is a gap ranged from (4G - 768M) to 4G, which will be skipped. + fn arch_ram_ranges(mem_size: u64) -> Vec<(u64, u64)> { + // ranges is the vector of (start_addr, size) +- let mut ranges = Vec::<(u64, u64)>::new(); ++ #[allow(unused_mut)] ++ let mut ranges; + + #[cfg(target_arch = "aarch64")] +- ranges.push((MEM_LAYOUT[LayoutEntryType::Mem as usize].0, mem_size)); +- ++ { ++ let mem_start = MEM_LAYOUT[LayoutEntryType::Mem as usize].0; ++ ranges = vec![(mem_start, mem_size)]; ++ } + #[cfg(target_arch = "x86_64")] + { + let gap_start = MEM_LAYOUT[LayoutEntryType::MemBelow4g as usize].0 + + MEM_LAYOUT[LayoutEntryType::MemBelow4g as usize].1; +- ranges.push((0, std::cmp::min(gap_start, mem_size))); ++ ranges = vec![(0, std::cmp::min(gap_start, mem_size))]; + if mem_size > gap_start { + let gap_end = MEM_LAYOUT[LayoutEntryType::MemAbove4g as usize].0; + ranges.push((gap_end, mem_size - gap_start)); +@@ -976,7 +979,7 @@ impl LightMachine { + impl MachineLifecycle for LightMachine { + fn pause(&self) -> bool { + if self.notify_lifecycle(KvmVmState::Running, KvmVmState::Paused) { +- event!(STOP); ++ event!(Stop); + + true + } else { +@@ -989,7 +992,7 @@ impl MachineLifecycle for LightMachine { + return false; + } + +- event!(RESUME); ++ event!(Resume); + + true + } +@@ -1268,11 +1271,11 @@ impl DeviceInterface for LightMachine { + fn device_del(&self, device_id: String) -> Response { + match self.del_replaceable_device(&device_id) { + Ok(path) => { +- let block_del_event = qmp_schema::DEVICE_DELETED { ++ let block_del_event = qmp_schema::DeviceDeleted { + device: Some(device_id), + path, + }; +- event!(DEVICE_DELETED; block_del_event); ++ event!(DeviceDeleted; block_del_event); + + Response::create_empty_response() + } +@@ -1548,6 +1551,7 @@ fn generate_virtio_devices_node(fdt: &mut Vec, res: &SysRes) -> util::errors + } + + /// Trait that helps to generate all nodes in device-tree. ++#[allow(clippy::upper_case_acronyms)] + #[cfg(target_arch = "aarch64")] + trait CompileFDTHelper { + /// Function that helps to generate cpu nodes. +@@ -1578,7 +1582,7 @@ impl CompileFDTHelper for LightMachine { + let clster = format!("/cpus/cpu-map/cluster{}", cluster); + device_tree::add_sub_node(fdt, &clster)?; + +- for i in 0..2 as u32 { ++ for i in 0..2_u32 { + let sub_cluster = format!("{}/cluster{}", clster, i); + device_tree::add_sub_node(fdt, &sub_cluster)?; + +diff --git a/util/src/aio/libaio.rs b/util/src/aio/libaio.rs +index b07a699..b7e4d33 100644 +--- a/util/src/aio/libaio.rs ++++ b/util/src/aio/libaio.rs +@@ -43,13 +43,13 @@ pub struct IoCb { + #[allow(non_camel_case_types)] + #[derive(Copy, Clone)] + pub enum IoCmd { +- PREAD = 0, +- PWRITE = 1, +- FSYNC = 2, +- FDSYNC = 3, +- NOOP = 6, +- PREADV = 7, +- PWRITEV = 8, ++ Pread = 0, ++ Pwrite = 1, ++ Fsync = 2, ++ Fdsync = 3, ++ Noop = 6, ++ Preadv = 7, ++ Pwritev = 8, + } + + #[repr(C)] +diff --git a/util/src/aio/mod.rs b/util/src/aio/mod.rs +index f0b0401..e5b5e01 100644 +--- a/util/src/aio/mod.rs ++++ b/util/src/aio/mod.rs +@@ -46,7 +46,7 @@ impl AioCb { + AioCb { + last_aio: true, + file_fd: 0, +- opcode: IoCmd::NOOP, ++ opcode: IoCmd::Noop, + iovec: Vec::new(), + offset: 0, + process: false, +@@ -155,7 +155,7 @@ impl Aio { + + pub fn rw_sync(&mut self, cb: AioCb) -> Result<()> { + let ret = match cb.opcode { +- IoCmd::PREADV => { ++ IoCmd::Preadv => { + let mut r = 0; + let mut off = cb.offset; + for iov in cb.iovec.iter() { +@@ -164,7 +164,7 @@ impl Aio { + } + r + } +- IoCmd::PWRITEV => { ++ IoCmd::Pwritev => { + let mut r = 0; + let mut off = cb.offset; + for iov in cb.iovec.iter() { +@@ -173,7 +173,7 @@ impl Aio { + } + r + } +- IoCmd::FDSYNC => raw_datasync(cb.file_fd)?, ++ IoCmd::Fdsync => raw_datasync(cb.file_fd)?, + _ => -1, + }; + (self.complete_func)(&cb, ret); +diff --git a/util/src/arg_parser.rs b/util/src/arg_parser.rs +index 9240a22..de051ae 100644 +--- a/util/src/arg_parser.rs ++++ b/util/src/arg_parser.rs +@@ -34,11 +34,11 @@ type ArgsMap = BTreeMap>; + #[derive(PartialEq, Debug)] + pub enum HelpType { + /// Argument as a Flag. +- FLAGS, ++ Flags, + /// Argument as a Option. +- OPTION, ++ Optional, + /// Argument will not output in help message. +- HIDDEN, ++ Hidden, + } + + /// Structure to store `ArgParser` information, which contains a command line +@@ -222,13 +222,13 @@ impl<'a> ArgParser<'a> { + for arg in self.args.values() { + let (help_str, help_type) = (*arg).help_message(); + match help_type { +- HelpType::FLAGS => { ++ HelpType::Flags => { + output_flags.push(help_str); + } +- HelpType::OPTION => { ++ HelpType::Optional => { + output_options.push(help_str); + } +- HelpType::HIDDEN => {} ++ HelpType::Hidden => {} + } + } + +@@ -452,7 +452,7 @@ impl<'a> Arg<'a> { + /// Produce help message for argument. + fn help_message(&self) -> (String, HelpType) { + if self.hiddable { +- (String::new(), HelpType::HIDDEN) ++ (String::new(), HelpType::Hidden) + } else if self.short.is_some() { + let font_str = format!( + "{}{}{}, {}{}", +@@ -465,7 +465,7 @@ impl<'a> Arg<'a> { + let mut help_str = format!("{}{}", TWENTY_FOUT_BLANK, self.help.unwrap_or("")); + let font_offset = font_str.len(); + help_str.replace_range(..font_offset, &font_str); +- (help_str, HelpType::FLAGS) ++ (help_str, HelpType::Flags) + } else { + let font_str = if self.values.is_some() { + format!( +@@ -497,7 +497,7 @@ impl<'a> Arg<'a> { + } else { + help_str.replace_range(..font_offset, &font_str); + } +- (help_str, HelpType::OPTION) ++ (help_str, HelpType::Optional) + } + } + +@@ -766,7 +766,7 @@ mod tests { + assert_eq!(arg.value.as_ref().unwrap(), "vm1"); + + let (help_msg, help_type) = arg.help_message(); +- assert_eq!(help_type, HelpType::FLAGS); ++ assert_eq!(help_type, HelpType::Flags); + assert_eq!( + help_msg, + format!( +diff --git a/util/src/device_tree.rs b/util/src/device_tree.rs +index 59f9642..120fd7c 100644 +--- a/util/src/device_tree.rs ++++ b/util/src/device_tree.rs +@@ -209,6 +209,7 @@ pub fn dump_dtb(fdt: &[u8], file_path: &str) { + } + + /// Trait for devices to be added to the Flattened Device Tree. ++#[allow(clippy::upper_case_acronyms)] + pub trait CompileFDT { + /// function to generate fdt node + /// +diff --git a/util/src/logger.rs b/util/src/logger.rs +index 015c9ab..da155b4 100644 +--- a/util/src/logger.rs ++++ b/util/src/logger.rs +@@ -89,11 +89,7 @@ pub fn init_vm_logger( + level: Option, + logfile: Option>, + ) -> Result<(), log::SetLoggerError> { +- let buffer = match logfile { +- Some(x) => Some(Mutex::new(x)), +- None => None, +- }; +- ++ let buffer = logfile.map(Mutex::new); + let logger = VmLogger { + level: level.unwrap_or(Level::Info), + handler: buffer, +diff --git a/virtio/src/balloon.rs b/virtio/src/balloon.rs +index 167cbe0..86af9b1 100644 +--- a/virtio/src/balloon.rs ++++ b/virtio/src/balloon.rs +@@ -511,7 +511,7 @@ impl BalloonIoHandler { + let msg = BalloonInfo { + actual: ram_size - balloon_size, + }; +- event!(BALLOON_CHANGED; msg); ++ event!(BalloonChanged; msg); + } + + /// Get the memory size of balloon. +@@ -687,7 +687,7 @@ impl Balloon { + let msg = BalloonInfo { + actual: self.get_guest_memory_size(), + }; +- event!(BALLOON_CHANGED; msg); ++ event!(BalloonChanged; msg); + Ok(()) + } + +diff --git a/virtio/src/block.rs b/virtio/src/block.rs +index 70f50c6..4377fda 100644 +--- a/virtio/src/block.rs ++++ b/virtio/src/block.rs +@@ -258,7 +258,7 @@ impl Request { + let mut aiocb = AioCb { + last_aio, + file_fd: disk.as_raw_fd(), +- opcode: IoCmd::NOOP, ++ opcode: IoCmd::Noop, + iovec: Vec::new(), + offset: (self.out_header.sector << SECTOR_SHIFT) as usize, + process: true, +@@ -276,7 +276,7 @@ impl Request { + + match self.out_header.request_type { + VIRTIO_BLK_T_IN => { +- aiocb.opcode = IoCmd::PREADV; ++ aiocb.opcode = IoCmd::Preadv; + if direct { + (*aio).as_mut().rw_aio(aiocb).chain_err(|| { + "Failed to process block request for reading asynchronously" +@@ -288,7 +288,7 @@ impl Request { + } + } + VIRTIO_BLK_T_OUT => { +- aiocb.opcode = IoCmd::PWRITEV; ++ aiocb.opcode = IoCmd::Pwritev; + if direct { + (*aio).as_mut().rw_aio(aiocb).chain_err(|| { + "Failed to process block request for writing asynchronously" +@@ -300,7 +300,7 @@ impl Request { + } + } + VIRTIO_BLK_T_FLUSH => { +- aiocb.opcode = IoCmd::FDSYNC; ++ aiocb.opcode = IoCmd::Fdsync; + (*aio) + .as_mut() + .rw_sync(aiocb) +@@ -843,8 +843,7 @@ impl VirtioDevice for Block { + return Err(ErrorKind::DevConfigOverflow(offset, config_len as u64).into()); + } + +- self.config_space[(offset as usize)..(offset as usize + data_len)] +- .copy_from_slice(&data[..]); ++ self.config_space[(offset as usize)..(offset as usize + data_len)].copy_from_slice(data); + + Ok(()) + } +diff --git a/virtio/src/net.rs b/virtio/src/net.rs +index 41b68cd..43545f5 100644 +--- a/virtio/src/net.rs ++++ b/virtio/src/net.rs +@@ -638,7 +638,7 @@ impl VirtioDevice for Net { + return Err(ErrorKind::DevConfigOverflow(offset, config_len as u64).into()); + } + +- config_slice[(offset as usize)..(offset as usize + data_len)].copy_from_slice(&data[..]); ++ config_slice[(offset as usize)..(offset as usize + data_len)].copy_from_slice(data); + + Ok(()) + } +diff --git a/virtio/src/vhost/kernel/net.rs b/virtio/src/vhost/kernel/net.rs +index 1251ede..45221b9 100644 +--- a/virtio/src/vhost/kernel/net.rs ++++ b/virtio/src/vhost/kernel/net.rs +@@ -205,7 +205,7 @@ impl VirtioDevice for Net { + return Err(ErrorKind::DevConfigOverflow(offset, config_len as u64).into()); + } + +- config_slice[(offset as usize)..(offset as usize + data_len)].copy_from_slice(&data[..]); ++ config_slice[(offset as usize)..(offset as usize + data_len)].copy_from_slice(data); + + Ok(()) + } +diff --git a/virtio/src/vhost/kernel/vsock.rs b/virtio/src/vhost/kernel/vsock.rs +index c464149..979670f 100644 +--- a/virtio/src/vhost/kernel/vsock.rs ++++ b/virtio/src/vhost/kernel/vsock.rs +@@ -162,8 +162,7 @@ impl VirtioDevice for Vsock { + return Err(ErrorKind::DevConfigOverflow(offset, config_len as u64).into()); + } + +- self.config_space[(offset as usize)..(offset as usize + data_len)] +- .copy_from_slice(&data[..]); ++ self.config_space[(offset as usize)..(offset as usize + data_len)].copy_from_slice(data); + + Ok(()) + } +-- +2.25.1 + diff --git a/0007-testcases-virtio_blk-decrease-hot-plugged-blk-number.patch b/0007-testcases-virtio_blk-decrease-hot-plugged-blk-number.patch new file mode 100644 index 0000000000000000000000000000000000000000..3c03fefe1c7672098145c6114bfdbf987b507f5b --- /dev/null +++ b/0007-testcases-virtio_blk-decrease-hot-plugged-blk-number.patch @@ -0,0 +1,54 @@ +From 9d9625192d5aebb4d2bc668cabf36ceb1abf3824 Mon Sep 17 00:00:00 2001 +From: Zhu huankai +Date: Wed, 12 May 2021 15:00:29 +0800 +Subject: [PATCH] testcases:virtio_blk: decrease hot plugged blk number + +stratovirt supports only 4 block devices to hot plugged at present. + +Signed-off-by: Zhu huankai +--- + .../microvm/functional/test_microvm_virtio_blk.py | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/tests/hydropper/testcases/microvm/functional/test_microvm_virtio_blk.py b/tests/hydropper/testcases/microvm/functional/test_microvm_virtio_blk.py +index d93fe78..dea710d 100644 +--- a/tests/hydropper/testcases/microvm/functional/test_microvm_virtio_blk.py ++++ b/tests/hydropper/testcases/microvm/functional/test_microvm_virtio_blk.py +@@ -66,14 +66,14 @@ def test_microvm_virtio_blk_at_dt(test_session_root_path, microvm, testtimes): + """ + Test virtio-blk hotplug and unplug: + +- 1) Generate 5 temp disks and add them to test_vm. ++ 1) Generate 3 temp disks and add them to test_vm. + 2) Assert disks' name and size as expect. + 3) Delete temp disks from test_vm. + 4) Assert temp disks are deleted. + """ + test_vm = microvm + test_vm.launch() +- disknum = 5 ++ disknum = 3 + disklist = [] + for index in range(disknum): + temp_disk = os.path.join(test_session_root_path, "test_image%d" % (index + 1)) +@@ -90,7 +90,7 @@ def test_microvm_virtio_blk_at_dt(test_session_root_path, microvm, testtimes): + blkinfo = test_vm.get_lsblk_info() + logging.debug("blkinfo is %s", blkinfo) + +- for devid in ["vdb", "vdc", "vdd", "vde", "vdf"]: ++ for devid in ["vdb", "vdc", "vdd"]: + assert devid in blkinfo + assert blkinfo[devid]["size"] == "16M" + +@@ -100,7 +100,7 @@ def test_microvm_virtio_blk_at_dt(test_session_root_path, microvm, testtimes): + index += 1 + + blkinfo = test_vm.get_lsblk_info() +- for devid in ["vdb", "vdc", "vdd", "vde", "vdf"]: ++ for devid in ["vdb", "vdc", "vdd"]: + assert devid not in blkinfo + + @pytest.mark.acceptance +-- +2.25.1 + diff --git a/0008-testscases-vmlife-decrease-test-blk-number.patch b/0008-testscases-vmlife-decrease-test-blk-number.patch new file mode 100644 index 0000000000000000000000000000000000000000..5655c50301114289fafe43f0e04d692e148d576f --- /dev/null +++ b/0008-testscases-vmlife-decrease-test-blk-number.patch @@ -0,0 +1,28 @@ +From 922431085a748e5420190782d138df5482095904 Mon Sep 17 00:00:00 2001 +From: Zhu huankai +Date: Wed, 12 May 2021 16:05:20 +0800 +Subject: [PATCH] testscases/vmlife: decrease test blk number + +stratovirt supports only 4 block devices at present. + +Signed-off-by: Zhu huankai +--- + .../testcases/microvm/functional/test_microvm_vmlife.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/hydropper/testcases/microvm/functional/test_microvm_vmlife.py b/tests/hydropper/testcases/microvm/functional/test_microvm_vmlife.py +index 6e015a3..ff9bc00 100644 +--- a/tests/hydropper/testcases/microvm/functional/test_microvm_vmlife.py ++++ b/tests/hydropper/testcases/microvm/functional/test_microvm_vmlife.py +@@ -30,7 +30,7 @@ def test_microvm_start(microvm, vcpu_count, memsize, vnetnums): + logging.debug("current vmhwinfo is %s", vmhwinfo) + assert vmhwinfo["cpu"]["vcpu_count"] == vcpu_count + assert vmhwinfo["mem"]["memsize"] > (memsize * 1024 * 90 / 100) +- assert len(vmhwinfo["virtio"]["virtio_blk"]) == 6 ++ assert len(vmhwinfo["virtio"]["virtio_blk"]) == 4 + assert len(vmhwinfo["virtio"]["virtio_net"]) == 2 + assert len(vmhwinfo["virtio"]["virtio_console"]) == 1 + test_vm.shutdown() +-- +2.25.1 + diff --git a/0009-README-update-readme.patch b/0009-README-update-readme.patch new file mode 100644 index 0000000000000000000000000000000000000000..fc4a9bfa0daad8d4ab2b1ffd6faeb4e4135fbcc8 --- /dev/null +++ b/0009-README-update-readme.patch @@ -0,0 +1,168 @@ +From 6caa22c9928e2450032c1359922e4e87e1e798ce Mon Sep 17 00:00:00 2001 +From: Zhu Huankai +Date: Tue, 18 May 2021 10:11:48 +0800 +Subject: [PATCH] README: update readme + +Update Preparation and add Log module. + +Signed-off-by: Zhu Huankai +--- + tests/hydropper/README.cn.md | 34 ++++++++++++++++++++++++++-------- + tests/hydropper/README.md | 30 ++++++++++++++++++++++++------ + 2 files changed, 50 insertions(+), 14 deletions(-) + +diff --git a/tests/hydropper/README.cn.md b/tests/hydropper/README.cn.md +index 8d397cf..c74493d 100644 +--- a/tests/hydropper/README.cn.md ++++ b/tests/hydropper/README.cn.md +@@ -3,9 +3,10 @@ hydropper是一个基于pytest的轻量级测试框架,在其基础上封装 + + ## 如何开始 + +- + ### 环境准备 +-requirements.txt里面包含了python3依赖包。 ++1. 请确保你的openEuler系统已经安装python3。 ++ ++2. requirements.txt里面包含了hydropper的依赖包。 + + - pytest>5.0.0 + - aexpect>1.5.0 +@@ -13,15 +14,26 @@ requirements.txt里面包含了python3依赖包。 + + 你可以通过下面的命令来安装这些包: + ```sh +-$ pip install -r config/requirements.txt ++$ pip3 install -r requirements.txt + ``` + +-网络依赖包: ++3. 请在你的openEuler系统上安装下列网络依赖包,以支持用例执行: ++ + ```sh + $ yum install nmap + $ yum install iperf3 + ``` + ++4. 网络配置(可参考以下模板): ++ ++```sh ++brctl addbr strato_br0 ++ifconfig strato_br0 up ++ifconfig strato_br0 1.1.1.1 ++``` ++ ++5. 构建测试镜像请参考 docs/IMAGE_BUILD.md。 ++ + ### 参数配置 + 请在config目录下的config.ini里配置参数和对应路径,通常的用例都需要配置好kernel和rootfs: + ```ini +@@ -39,16 +51,17 @@ STRATOVIRT_ROOTFS = /path/to/rootfs + + 请在config.ini中配置好IP_PREFIX和IP_3RD,这两项表示虚拟机IPv4地址的前24位, + 最后8位会由hydropper来自动配置。请注意虚拟机需要和主机在同一网段。 ++ + ```ini + [network.params] + # such as 'IP_PREFIX.xxx.xxx' +-IP_PREFIX = xxx.xxx ++IP_PREFIX = 1.1 + # such as 'xxx.xxx.IP_3RD.xxx' +-IP_3RD = xxx ++IP_3RD = 1 + ``` + + ### 运行测试用例 +-你可以hydropper目录下通过以下的命令来执行用例: ++你可以在hydropper目录下通过以下的命令来执行用例: + ```sh + # 执行所有用例 + $ pytest +@@ -95,4 +108,9 @@ def test_microvm_xxx(microvm): + test_vm = microvm + test_vm.basic_config(vcpu_count=4, mem_size='4G') + test_vm.launch() +-``` +\ No newline at end of file ++``` ++ ++### 日志 ++ ++- pytest默认日志路径:/var/log/pytest.log ++- stratovirt默认日志路径:/var/log/stratovirt +\ No newline at end of file +diff --git a/tests/hydropper/README.md b/tests/hydropper/README.md +index 3bdb169..a44ab42 100644 +--- a/tests/hydropper/README.md ++++ b/tests/hydropper/README.md +@@ -5,7 +5,9 @@ Hydropper is a lightweight test framework based on pytest. It encapsulates virtu + + + ### Preparation +-The requirements.txt file contains the Python3 dependency package. ++1. Ensure that python3 has been installed on your openEuler system. ++ ++2. The requirements.txt file contains the Python3 dependency package. + + - pytest>5.0.0 + - aexpect>1.5.0 +@@ -13,15 +15,25 @@ The requirements.txt file contains the Python3 dependency package. + + You can install these packages by running the following commands: + ```sh +-$ pip install -r config/requirements.txt ++$ pip3 install -r requirements.txt + ``` + +-Network dependency package: ++3. Network dependency package: + ```sh + $ yum install nmap + $ yum install iperf3 + ``` + ++4. Network configuration(template) ++ ++```sh ++brctl addbr strato_br0 ++ifconfig strato_br0 up ++ifconfig strato_br0 1.1.1.1 ++``` ++ ++5. For details about how to build a test image, see docs/IMAGE_BUILD.md. ++ + ### Parameter configuration + Set parameters and corresponding paths in the config/config.ini. Generally, the kernel and rootfs must be configured for test cases. + ```ini +@@ -41,12 +53,13 @@ Configure IP_PREFIX and IP_3RD in the "config.ini" file, + which indicate the first 24 bits of the VM IPv4 address, + The last 8 bits are automatically configured by the hydropper. + Note that the VM and the host must be in the same network segment. ++ + ```ini + [network.params] + # such as 'IP_PREFIX.xxx.xxx' +-IP_PREFIX = xxx.xxx ++IP_PREFIX = 1.1 + # such as 'xxx.xxx.IP_3RD.xxx' +-IP_3RD = xxx ++IP_3RD = 1 + ``` + + ### Run testcases +@@ -97,4 +110,9 @@ def test_microvm_xxx(microvm): + test_vm = microvm + test_vm.basic_config(vcpu_count=4, mem_size='4G') + test_vm.launch() +-``` +\ No newline at end of file ++``` ++ ++### Log ++ ++- pytest default log path: /var/log/pytest.log ++- stratovirt default log path: /var/log/stratovirt +\ No newline at end of file +-- +2.25.1 + diff --git a/0010-docs-add-IMAGE_BUILD.md.patch b/0010-docs-add-IMAGE_BUILD.md.patch new file mode 100644 index 0000000000000000000000000000000000000000..fffd430392a989a3d1d6060a122d80eb2f570acf --- /dev/null +++ b/0010-docs-add-IMAGE_BUILD.md.patch @@ -0,0 +1,76 @@ +From 74a0d73ae3658e075bf946e2e90e0d6a9785ac3c Mon Sep 17 00:00:00 2001 +From: Zhu Huankai +Date: Tue, 18 May 2021 10:27:52 +0800 +Subject: [PATCH] docs: add IMAGE_BUILD.md + +This markdown tells users how to build a test image. + +Signed-off-by: Zhu Huankai +--- + tests/hydropper/docs/IMAGE_BUILD.md | 54 +++++++++++++++++++++++++++++ + 1 file changed, 54 insertions(+) + create mode 100644 tests/hydropper/docs/IMAGE_BUILD.md + +diff --git a/tests/hydropper/docs/IMAGE_BUILD.md b/tests/hydropper/docs/IMAGE_BUILD.md +new file mode 100644 +index 0000000..1e29fb2 +--- /dev/null ++++ b/tests/hydropper/docs/IMAGE_BUILD.md +@@ -0,0 +1,54 @@ ++# 构建测试镜像 ++ ++1. 请于openEuler官网,下载所需版本的stratovirt_img和vmlinux.bin。(以下以openEuler-21.03-stratovirt-x86_64.img为例) ++ ++- 地址:https://openeuler.org/zh/download/ ++ ++2. 扩容镜像 ++ ++- 创建一个2G大小的空镜像文件extend.img ++ ++ ```shell ++ dd if=/dev/zero of=extend.img bs=50M count=40 ++ ``` ++ ++- 扩容stratovirt_img ++ ++ ```shell ++ cat extend.img >> openEuler-21.03-stratovirt-x86_64.img ++ ``` ++ ++- 调整文件系统大小 ++ ++ ```shell ++ e2fsck -f openEuler-21.03-stratovirt-x86_64.img && resize2fs openEuler-21.03-stratovirt-x86_64.img ++ ``` ++ ++3. 添加依赖包 ++ ++- 挂载镜像 ++ ++ ```shell ++ mount openEuler-21.03-stratovirt-x86_64.img /mnt ++ ``` ++ ++- 配置在线yum源,请参考: [开发环境准备.md](https://gitee.com/openeuler/docs/blob/stable2-21.03/docs/zh/docs/ApplicationDev/开发环境准备.md)。由于stratovirt_img内没有vi等编辑工具,建议先在主机上创建文件openEuler.repo,并配置好yum源,完成后将openEuler.repo拷贝到镜像内。 ++ ++ ```shell ++ cp ./openEuler.repo /mnt/etc/yum.repos.d ++ ``` ++ ++- 进入镜像挂载目录,通过yum命令安装依赖包。 ++ ++ ```shell ++ cd /mnt ++ chroot . ++ yum -y install openSSH ++ ``` ++ ++- 离开当前目录后,使用umount命令卸载镜像。 ++ ++ ```shell ++ exit ++ umount /mnt ++ ``` +-- +2.25.1 + diff --git a/stratovirt.spec b/stratovirt.spec index b35337c620450ae2c0ee1008943aa838548abb14..8434256fbb74aa826b831da67c4599e3a04e703e 100644 --- a/stratovirt.spec +++ b/stratovirt.spec @@ -6,13 +6,24 @@ Name: stratovirt Version: 0.3.0 -Release: 2 +Release: 3 Summary: StratoVirt is an opensource VMM(Virtual Machine Manager) which aims to perform next generation virtualization. License: Mulan PSL v2 URL: https://gitee.com/openeuler/StratoVirt Source0: %{name}-%{version}.tar.gz +Patch0001: 0001-docs-update-readme.md-for-building-via-musl-toolchai.patch +Patch0002: 0002-docs-turn-on-the-option-switch-of-virtio-rng-for-x86.patch +Patch0003: 0003-doc-fix-an-uncorrect-link-for-build_guide-in-quickst.patch +Patch0004: 0004-update-rootfs-disk-image-description-in-README.ch.md.patch +Patch0005: 0005-update-rootfs-disk-image-description-in-README.md.patch +Patch0006: 0006-StratoVirt-clear-clippy-warnings-for-updating-rust-1.patch +Patch0007: 0007-testcases-virtio_blk-decrease-hot-plugged-blk-number.patch +Patch0008: 0008-testscases-vmlife-decrease-test-blk-number.patch +Patch0009: 0009-README-update-readme.patch +Patch0010: 0010-docs-add-IMAGE_BUILD.md.patch + ExclusiveArch: x86_64 aarch64 @@ -57,6 +68,12 @@ sed -i 's/rustflags = \[/rustflags = \["-Clink-arg=-lgcc", "-Clink-arg=-lfdt", / chmod 550 ${RPM_BUILD_ROOT}/usr/bin/stratovirt %changelog +* Sun May 28 2021 XuFei - 0.3.0-3 +- Type:NA +- ID:NA +- SUG:NA +- DESC:modify docs,modify testcases and clear clippy warnings for updating rust 1.51.0 + * Sun Apr 25 2021 LiangZhang - 0.3.0-2 - Type:NA - ID:NA