Commit Graph

253 Commits

Author SHA1 Message Date
Anatol Belski
56b9149325 tests: Pull common code into a separate method
Yet another small refactoring step for WindowsGuest
after f56471566b.

For this particular case - there's currently neither overloading nor
default argument support in Rust (except a macro or other tricky stuff),
so keep the timeout and other options default for now.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-05-19 16:41:08 +01:00
Anatol Belski
01e2826f26 tests: Implement disk hotplug test
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-05-19 10:39:46 +02:00
Sebastien Boeuf
ae4e01adc9 tests: vfio: Increase time for memory hotplug
Bump the sleep time before checking the guest RAM size from 10 to 30
seconds. This will help the VFIO baremetal CI passing more consistently.

Fixes #2606

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-07 18:44:31 +02:00
Rob Bradford
6d6cafafb2 tests: Fix clippy issues in integration tests
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-05-07 14:31:57 +02:00
Sebastien Boeuf
5268bf5a8c tests: Re-enable virtiofsd tests
Re-enable virtiofsd testing now that issues with capstone repository
have been resolved.

This reverts commit 2aec0a92a5.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-07 11:16:36 +02:00
Wei Liu
c439324451 tests: add a Windows multiple queues test
Create as many queues as there are boot CPUs for block and twice as many
for net.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-05-07 08:57:13 +02:00
Sebastien Boeuf
66b46a277e tests: Remove unused code from Windows integration tests
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-07 08:57:13 +02:00
Sebastien Boeuf
9adfc04f75 tests: Wait for dnsmasq process to terminate
Make sure the dnsmasq process terminates after we sent the kill signal.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-07 08:57:13 +02:00
Sebastien Boeuf
0a00df2e7e tests: Dynamically assign IPs for Windows integration tests
Relying on dnsmasq running on the host, the Windows guest are now
getting allocated with the expected IP addresses. This allows for
multiple VMs, therefore multiple tests to run in parallel.

The end goal is to reduce the time spent running Windows integration
tests.

Fixes #1891

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-06 17:27:33 +02:00
Sebastien Boeuf
aa76c9db2e tests: Rename Windows specific functions
Let's keep the function names as simple as possible.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-06 15:17:27 +02:00
Sebastien Boeuf
f56471566b tests: Introduce WindowsGuest structure for further factorization
This new wrapping structure allows for a better factorization of the
Windows specific code. This makes each test simpler and easier to read.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-06 15:17:27 +02:00
Sebastien Boeuf
14544d64e4 tests: Factorize shutdown and reboot functions for Windows
Add some factorization for both functions rebooting and shutting down a
Windows guest.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-06 15:17:27 +02:00
Sebastien Boeuf
2646b24047 tests: Remove references from Guest and DiskConfig
By using a Box around the DiskConfig trait, it becomes Sized. For that
reason, we can pass the DiskConfig to the Guest so that it can own it.
This allows for further simplification as the Guest does not need to be
bound to a specific lifetime, which makes things easier.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-06 15:17:27 +02:00
Sebastien Boeuf
b2b577257f tests: Add integration test for vhost-user-net client mode
Refactor the existing vhost-user-net integration tests in order to
extend it with an extra test for vhost-user client mode.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-05 16:05:51 +02:00
Sebastien Boeuf
b5be62a167 tests: Extend VFIO baremetal integration tests
Relying on guest Ubuntu image 21.04, including a 5.11 kernel, this patch
adds some additional tests to the VFIO baremetal integration tests. It
adds a test for ACPI memory hotplug, another one for virtio-mem memory
hotplug, and finally a test for hotplugging the NVIDIA card.

The existing test already taking care of the reboot has been renamed.

The script running "cargo test" has been modified to run only one thread
at a time, so that each test run sequentially. This is mandatory since
the card can't be shared across multiple VMs.

Fixes #2404

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-04 15:01:29 +02:00
Sebastien Boeuf
6eaf44ec61 tests: Update journalctl command to get reboot count
In order to support most recent Ubuntu distributions, we must update
the way of detecting a reboot through the journal since there is no
more "-- Reboot --" logs.

Using the `--list-boots` option is the preferred way for getting the
boot count information from journalctl command. We simply need to add 1
to the count in order to get the reboot count.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-04 15:01:29 +02:00
Sebastien Boeuf
8ee0377456 tests: Update VFIO baremetal test to rely on Ubuntu 21.04
Moving to latest Ubuntu version as the guest image is needed to move to
more recent guest kernel (5.11). With more recent kernels, we'll be able
to add hotplug and virtio-mem tests to the VFIO baremetal CI.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-05-04 15:01:29 +02:00
Rob Bradford
2aec0a92a5 tests: Don't test virtiofsd
The CI is failing due the git server that the submodules required for
this fork of QEMU need to build from is unavailable.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-05-04 12:14:37 +01:00
Rob Bradford
1f4a34ffc8 tests: Remove last tests using bzImage
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-04-30 16:16:48 +02:00
Sebastien Boeuf
ed54036bfb tests: Fix reboot by allowing specifying the custom timeout
test_reboot became flaky after the refactoring of the VM reboot code.
This is because we removed the ability to specify a custom timeout.
This patch fixes the issue by allowing a custom timeout of 120s to be
set.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-29 11:10:40 +01:00
Sebastien Boeuf
b31589f6bc tests: Factorize memory hotplug enabling
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-28 17:48:10 +02:00
Sebastien Boeuf
d30de8ecee tests: Add reboot validation to VFIO baremetal testing
Make sure the VFIO baremetal tests are still passing correctly after the
guest is rebooted.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-28 17:48:10 +02:00
Sebastien Boeuf
d203c62b42 tests: Factorize a few functions
Factorize NVIDIA GPU checks into its own function so that it can be
reused.

Factorize linux guest reboot into its own function to reduce the amount
of code.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-28 17:48:10 +02:00
Rob Bradford
7367ca70c2 tests: Don't build separate pvh/non-pvh vmlinux binary
Use the PVH vmlinux for all tests (with the exception of the specific
bzImage test.)

See: #2231

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-04-28 10:40:31 +02:00
Sebastien Boeuf
fdcfec081b tests: Fix test_vfio
The new kernel 5.12 requires the devices to be manually bound to
vfio-pci while adding a new_id is only needed once per
device_id:vendor_id pair.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-28 09:02:01 +02:00
Anatol Belski
87a4f4ae32 tests: Disable test_windows_* for mshv
It appears that mshv is not yet there to succeed with these tests. It is
suggested to ignore them and enable later one by one as the
functionality gets fixed.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-04-23 17:57:28 +02:00
Anatol Belski
ac3414503c tests: Implement test for net dev hotplug for Windows guest
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-04-22 11:42:43 -07:00
Rob Bradford
fd72612e91 tests: Extend test_tap_from_fd to reboot
Check that the VM comes back with the correct network setup after a
reboot.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-04-22 12:19:01 +02:00
Bo Chen
99694cf5c1 tests: Simplify 'test_memory_mergeable'
We now reply on the value from '/sys/kernel/mm/ksm/shared_pages' to
validate our "--memory mergeable=on|off" option. For `mergeable=on`,
we are expecting to see more 'shared_pages' reported by the kernel when
we start more VMs with this option. For `mergeable=off`, we are
expecting the 'shared_pages' value to be always 0, as we are assuming
the rest of the system (in our CI) is not using mergeable memory.

Fixes: #2138

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-04-13 09:00:00 +02:00
Anatol Belski
e1cc702327 memory_manager: Fix address range calculation in MemorySlot
The MCRS method returns a 64-bit memory range descriptor. The
calculation is supposed to be done as follows:

max = min + len - 1

However, every operand is represented not as a QWORD but as combination
of two DWORDs for high and low part. Till now, the calculation was done
this way, please see also inline comments:

max.lo = min.lo + len.lo //this may overflow, need to carry over to high
max.hi = min.hi + len.hi
max.hi = max.hi - 1 // subtraction needs to happen on the low part

This calculation has been corrected the following way:

max.lo = min.lo + len.lo
max.hi = min.hi + len.hi + (max.lo < min.lo) // check for overflow
max.lo = max.lo - 1 // subtract from low part

The relevant part from the generated ASL for the MCRS method:
```
Method (MCRS, 1, Serialized)
{
    Acquire (MLCK, 0xFFFF)
    \_SB.MHPC.MSEL = Arg0
    Name (MR64, ResourceTemplate ()
    {
	QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
	    0x0000000000000000, // Granularity
	    0x0000000000000000, // Range Minimum
	    0xFFFFFFFFFFFFFFFE, // Range Maximum
	    0x0000000000000000, // Translation Offset
	    0xFFFFFFFFFFFFFFFF, // Length
	    ,, _Y00, AddressRangeMemory, TypeStatic)
    })
    CreateQWordField (MR64, \_SB.MHPC.MCRS._Y00._MIN, MINL)  // _MIN: Minimum Base Address
    CreateDWordField (MR64, 0x12, MINH)
    CreateQWordField (MR64, \_SB.MHPC.MCRS._Y00._MAX, MAXL)  // _MAX: Maximum Base Address
    CreateDWordField (MR64, 0x1A, MAXH)
    CreateQWordField (MR64, \_SB.MHPC.MCRS._Y00._LEN, LENL)  // _LEN: Length
    CreateDWordField (MR64, 0x2A, LENH)
    MINL = \_SB.MHPC.MHBL
    MINH = \_SB.MHPC.MHBH
    LENL = \_SB.MHPC.MHLL
    LENH = \_SB.MHPC.MHLH
    MAXL = (MINL + LENL) /* \_SB_.MHPC.MCRS.LENL */
    MAXH = (MINH + LENH) /* \_SB_.MHPC.MCRS.LENH */
    If ((MAXL < MINL))
    {
	MAXH += One /* \_SB_.MHPC.MCRS.MAXH */
    }

    MAXL -= One
    Release (MLCK)
    Return (MR64) /* \_SB_.MHPC.MCRS.MR64 */
}
```

Fixes #1800.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-04-12 16:20:19 +02:00
Sebastien Boeuf
7e2c4b63c2 ci: Update SGX test to rely on vmlinux
Since using bzImage is now deprecated, let's update the SGX integration
test to rely on vmlinux instead.

Fixes #2476

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-07 17:40:10 +02:00
Anatol Belski
3f5ecbd326 tests: Extend Windows guest CPU hotplug test and update doc
Both changes aim to document the absence of the CPU hot-remove
functionality on Windows.

Closes #2457.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-04-07 14:44:29 +01:00
Sebastien Boeuf
e5211a6e1d ci: Update Ubuntu Focal custom image
Update the Ubuntu Focal image used as the guest image. It's based on the
latest Focal image released on April 1st 2021, and customized to include
all the utilities we need. As usual, snapd and pollinate services have
been removed.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-04-07 10:26:15 +01:00
Rob Bradford
9a8a34a8a9 tests: Only use bzImage in integration tests that require it
i.e. test_bzimage_boot and test_bzimage_reboot

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-04-06 13:30:59 +02:00
Anatol Belski
1bb0e54e92 tests: Add test for CPU hotplug for Windows guest
Also, add a note on hotplug support to windows.md.

Closes #2438.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2021-04-01 16:07:50 +01:00
Sebastien Boeuf
73e8fd4d72 clippy: Fix codebase to compile with beta toolchain
Fixes the current codebase so that every cargo clippy can be run with
the beta toolchain without any error.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-03-29 15:56:23 +01:00
Rob Bradford
5c010d489d tests: Address Rust 1.51.0 clippy issue (needless_question_mark)
error: Question mark operator is useless here
   --> tests/integration.rs:494:13
    |
494 | /             Ok(self
495 | |                 .ssh_command("grep MemTotal /proc/meminfo | grep -o \"[0-9]*\"")?
496 | |                 .trim()
497 | |                 .parse()
498 | |                 .map_err(Error::Parsing)?)
    | |__________________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-03-26 11:32:09 +00:00
Rob Bradford
88c30764e0 tests: Move test_infra from a module to crate
It must be specified as excluded from the workspace as it must not be
built on non-test targets due to issues with the ssh2 dependency and the
musl toolchain.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-03-23 18:04:50 +01:00
Rob Bradford
16cb40733a tests: Extract out generic integration test code
This includes:

* OS disk image management
* Cloud init creation
* SSH to guest access
* Waiting for guest to boot

This will be useful in other projects that want to do similar things in
their integration tests.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-03-17 12:18:04 +00:00
Sebastien Boeuf
04dc496808 ci: Enable baremetal VFIO integration tests
Relying on a NVIDIA Tesla T4 card present in the SGX machine, this patch
enables baremetal VFIO testing, validated by running several NVIDIA
tools in the guest. The guest image has been prepared to include all the
software needed to run these tests.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-03-16 18:59:46 +00:00
Henry Wang
205e587fad tests: Enable test_power_button for AArch64
This commit enables the test_power_button test case for AArch64.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
2021-03-16 20:27:15 +08:00
Henry Wang
9c3b489f0e tests: Switch AArch64 serial test cases to ttyAMA0
This commit switches the serial test cases for AArch64 to ttyAMA0.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
2021-03-16 11:53:51 +08:00
Michael Zhao
c3a75dafc5 tests: Enable serial test cases for AArch64
Enabled all "ttyS0" related test cases:
- test_serial_off
- test_serial_tty
- test_serial_file

Enabled mandatory guest kernel driver for "ns16550a" on AArch64.

Signed-off-by: Michael Zhao <michael.zhao@arm.com>
2021-03-15 20:59:50 +08:00
Rob Bradford
99baee8d37 tests: Move Windows integration test to updated OVMF
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-03-01 22:11:19 +00:00
Rob Bradford
24922ce1e3 tests: Move integration tests to vmm_sys_util::tempdir::TempDir
This removes the dependency on "tempdir" which in turn depends on the
large rand dependency chain.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-23 11:07:48 +00:00
Rob Bradford
d78b2ec8b5 tests: Use vmm_sys_util::tempfile::Tempfile in integration tests
This removes the requirement for an extra crate and simplifies the
dependency chain.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-22 14:29:53 +01:00
Muminul Islam
0ef69fa592 tests: Use constant instead of static value for windows image name
Signed-off-by: Muminul Islam <muislam@microsoft.com>
2021-02-19 10:09:23 +00:00
Bo Chen
a838d0bde1 scripts, tests: Rustify the network setup commands for tests
Fixes: #2218

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-02-15 08:34:23 +00:00
Rob Bradford
9c5be6f660 build: Remove unnecessary Result<> returns
If the function can never return an error this is now a clippy failure:

error: this function's return value is unnecessarily wrapped by `Result`
   --> virtio-devices/src/watchdog.rs:215:5
    |
215 | /     fn set_state(&mut self, state: &WatchdogState) -> io::Result<()> {
216 | |         self.common.avail_features = state.avail_features;
217 | |         self.common.acked_features = state.acked_features;
218 | |         // When restoring enable the watchdog if it was previously enabled. We reset the timer
...   |
223 | |         Ok(())
224 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-02-11 18:18:44 +00:00
Bo Chen
d561b45552 tests: Add integration test test_macvtap
This integration test mimics the instructions from
`docs/macvtap-bridge.md`.

Fixes: #2215

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-02-11 15:25:32 +00:00