Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a fixture for Qemu vhost-user-blk backend #4156

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cpu_templates/boot-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ and MSR_IA32_MISC_ENABLE is set to `1`.

On aarch64, the following registers are set:

- PSTATE to PSR_MODE_EL1h | PSR_A_BIT | PSR_F_BIT | PSR_I_BIT | PSR_D_BIT
- PSTATE to PSR_MODE_EL1h \| PSR_A_BIT \| PSR_F_BIT \| PSR_I_BIT \| PSR_D_BIT
- PC to kernel load address (vCPU0 only)
- X0 to DTB/FDT address (vCPU0 only)
10 changes: 5 additions & 5 deletions docs/network-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Scope of the measurements is to illustrate the limits for the emulation thread.

## TCP Throughput

Segment size/ Direction | 1460bytes | 256bytes | 128bytes | 96bytes
--- | --- | --- | --- |---
Ingress| 25Gbps | 23Gbps | 20Gbps | 18Gbps
Egress | 25Gbps | 23Gbps | 20Gbps | 18Gbps
Bidirectional | 18Gbps | 18Gbps | 18Gbps | 18Gbps
| Segment size/ Direction | 1460bytes | 256bytes | 128bytes | 96bytes |
| --- | --- | --- | --- |--- |
| Ingress| 25Gbps | 23Gbps | 20Gbps | 18Gbps |
| Egress | 25Gbps | 23Gbps | 20Gbps | 18Gbps |
| Bidirectional | 18Gbps | 18Gbps | 18Gbps | 18Gbps |

**Setup and test description**
Throughput measurements were done using [iperf3](https://iperf.fr/). The target
Expand Down
8 changes: 4 additions & 4 deletions docs/snapshotting/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ A microVM state file is further split into four different fields:

| Field | Bits| Description |
|----|----|----|
| magic_id | 64 | Firecracker snapshot, architecture (x86_64/aarch64) and storage version.
| version | 16 | The snapshot version number internally mapped 1:1 to a specific Firecracker version.
| state | N | Bincode blob containing the microVM state.
| crc| 64 | Optional CRC64 sum of magic_id, version and state fields.
| magic_id | 64 | Firecracker snapshot, architecture (x86_64/aarch64) and storage version. |
| version | 16 | The snapshot version number internally mapped 1:1 to a specific Firecracker version. |
| state | N | Bincode blob containing the microVM state. |
| crc| 64 | Optional CRC64 sum of magic_id, version and state fields. |

**Note**: the last 16 bits of `magic_id` encode the storage version which specifies
the encoding used for the `version` and `state` fields. The current
Expand Down
47 changes: 47 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from pathlib import Path

import pytest
import requests

import host_tools.cargo_build as build_tools
from framework import defs, utils
Expand All @@ -58,6 +59,11 @@


METRICS = get_metrics_logger()
QEMU_PUB_KEY_URL = "https://keys.openpgp.org/vks/v1/by-fingerprint/CEACC9E15534EBABB82D3FA03353C9CEF108B584"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ubuntu packages don't have the vhost-user-blk binary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was my first guess too, but I wasn't able to find it.

QEMU_VERSION = "8.1.1"
QEMU_TARBALL = f"qemu-{QEMU_VERSION}.tar.xz"
QEMU_URL = f"https://download.qemu.org/{QEMU_TARBALL}"
QEMU_SIG_URL = f"https://download.qemu.org/{QEMU_TARBALL}.sig"


def pytest_addoption(parser):
Expand Down Expand Up @@ -196,6 +202,47 @@ def bin_vsock_path(test_fc_session_root_path):
yield vsock_helper_bin_path


@pytest.fixture(scope="session")
def bin_vhost_user_blk_backend(test_fc_session_root_path):
"""Build a Qemu vhost-user-blk backend."""
# Fetch and import the public key
resp = requests.get(QEMU_PUB_KEY_URL, timeout=5)
resp.raise_for_status()
pk = Path(test_fc_session_root_path) / "qemu_pub_key"
pk.write_bytes(resp.content)
utils.run_cmd(["gpg", "--import", pk])

# Fetch the Qemu tarball
resp = requests.get(QEMU_URL, timeout=30)
resp.raise_for_status()
tarball_path = Path(test_fc_session_root_path) / QEMU_TARBALL
tarball_path.write_bytes(resp.content)

# Fetch the Qemu tarball signature
resp = requests.get(QEMU_SIG_URL, timeout=5)
resp.raise_for_status()
sig_path = Path(test_fc_session_root_path) / f"{QEMU_TARBALL}.sig"
sig_path.write_bytes(resp.content)

# Verify the signature
utils.run_cmd(["gpg", "--verify", sig_path, tarball_path])

# Unpack the Qemu tarball
utils.run_cmd(["tar", "xf", tarball_path, "-C", test_fc_session_root_path])

# Configure Qemu and build only the vhost-user-blk backend target.
backend_build_relpath = "contrib/vhost-user-blk/vhost-user-blk"
compile_cmd = f"./configure && make -j {backend_build_relpath}"
qemu_dir = Path(test_fc_session_root_path) / f"qemu-{QEMU_VERSION}"
utils.run_cmd(compile_cmd, cwd=qemu_dir)

# Note that the make target does not include the `build` part of the path,
# but the actual binary path does.
bin_path = qemu_dir / f"build/{backend_build_relpath}"

yield bin_path


@pytest.fixture(scope="session")
def change_net_config_space_bin(test_fc_session_root_path):
"""Build a binary that changes the MMIO config space."""
Expand Down
10 changes: 10 additions & 0 deletions tools/devctr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ RUN apt-get update \
dmidecode \
# for aws-lc-rs
cmake \
# for verifying GPG signature of a Qemu release
gpg \
gpg-agent \
# for Qemu vhost-user-blk backend build, mostly inspired by
# https://en.wikibooks.org/wiki/QEMU/QEMU_Hello_World:_Installing_QEMU_and_getting_it_up_and_running
bison \
flex \
libglib2.0-dev \
libpixman-1-dev \
ninja-build \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --upgrade pip poetry \
&& gem install mdl
Expand Down
Loading