Skip to content

Commit

Permalink
Merge pull request #1223 from hermit-os/ci-packed
Browse files Browse the repository at this point in the history
feat(virtio-net): enable `VIRTIO_NET_F_MQ` and test `VIRTIO_F_RING_PACKED`
  • Loading branch information
mkroening committed May 22, 2024
2 parents 0d29aa5 + f0295c3 commit 80f688e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 43 deletions.
44 changes: 24 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ jobs:
hermit-careful: 1
- arch: x86_64
packages: qemu-system-x86 libcap-ng-dev libseccomp-dev uftrace
#flags: --features hermit/pci-ids
- arch: aarch64
packages: qemu-system-aarch64
#flags: --features hermit/pci-ids
- arch: riscv64
packages: qemu-system-misc

Expand Down Expand Up @@ -185,40 +183,46 @@ jobs:
if: matrix.arch == 'x86_64'
- run: cargo +stable install cargo-careful
if: matrix.profile == 'dev'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package hello_world
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package hello_world --no-default-features --microvm
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package hello_world
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package hello_world --no-default-features --microvm
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package rusty_demo --features fs --virtiofsd
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rusty_demo --features fs --virtiofsd
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package rusty_demo --features fs --virtiofsd --smp 4
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rusty_demo --features fs --virtiofsd --smp 4
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package rusty_demo
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package rusty_demo --smp 4
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rusty_demo --features fs --virtiofsd --no-default-virtio-features
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rusty_demo --features fs --virtiofsd --no-default-virtio-features --smp 4
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rusty_demo
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rusty_demo --smp 4
# https://github.com/hermit-os/kernel/issues/737
if: matrix.arch != 'aarch64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package rftrace-example --virtiofsd
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package rftrace-example --virtiofsd
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package httpd --features ci,hermit/dhcpv4 --netdev virtio-net-pci
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package httpd --features ci,hermit/dhcpv4 --netdev virtio-net-pci
if: matrix.arch != 'riscv64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package httpd --features ci,hermit/dhcpv4 --netdev virtio-net-pci --no-default-virtio-features
if: matrix.arch != 'riscv64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package httpd --no-default-features --microvm --features ci,hermit/dhcpv4,hermit/tcp --netdev virtio-net-mmio
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package httpd --no-default-features --microvm --features ci,hermit/dhcpv4,hermit/tcp --netdev virtio-net-mmio
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package httpd --features ci,hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package httpd --features ci,hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package testudp --features hermit/udp,hermit/dhcpv4 --netdev virtio-net-pci
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package testudp --features hermit/udp,hermit/dhcpv4 --netdev virtio-net-pci
if: matrix.arch != 'riscv64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package testudp --features hermit/udp,hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package testudp --features hermit/udp,hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package miotcp --features hermit/dhcpv4 --netdev virtio-net-pci
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package miotcp --features hermit/dhcpv4 --netdev virtio-net-pci
if: matrix.arch != 'riscv64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package miotcp --features hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package miotcp --features hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package poll --features hermit/dhcpv4 --netdev virtio-net-pci
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package poll --features hermit/dhcpv4 --netdev virtio-net-pci
if: matrix.arch != 'riscv64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package poll --features hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package poll --features hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
if: matrix.arch == 'x86_64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package mioudp --features hermit/udp,hermit/dhcpv4 --netdev virtio-net-pci
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package mioudp --features hermit/udp,hermit/dhcpv4 --netdev virtio-net-pci
if: matrix.arch != 'riscv64'
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} ${{ matrix.flags }} --package mioudp --features hermit/udp,hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
- run: cargo xtask ci qemu --arch ${{ matrix.arch }} --profile ${{ matrix.profile }} --package mioudp --features hermit/udp,hermit/dhcpv4 --netdev rtl8139 --features hermit/rtl8139
if: matrix.arch == 'x86_64'

run-x86_64-kvm:
Expand Down
4 changes: 3 additions & 1 deletion src/drivers/net/virtio_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@ impl VirtioNetDriver {
// Driver can merge receive buffers
| virtio_spec::net::F::MRG_RXBUF
// the link status can be announced
| virtio_spec::net::F::STATUS;
| virtio_spec::net::F::STATUS
// Multiqueue support
| virtio_spec::net::F::MQ;

// Currently the driver does NOT support the features below.
// In order to provide functionality for these, the driver
Expand Down
60 changes: 38 additions & 22 deletions xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ pub struct Qemu {
#[arg(long)]
netdev: Option<NetworkDevice>,

/// Do not activate additional virtio features.
#[arg(long)]
no_default_virtio_features: bool,

/// Create multiple vCPUs.
#[arg(long, default_value_t = 1)]
smp: usize,
Expand Down Expand Up @@ -230,38 +234,50 @@ impl Qemu {
["-m".to_string(), format!("{}M", self.memory())]
}

fn netdev_args(&self) -> &'static [&'static str] {
match self.netdev {
Some(NetworkDevice::VirtioNetPci) => &[
"-netdev",
"user,id=u1,hostfwd=tcp::9975-:9975,hostfwd=udp::9975-:9975,net=192.168.76.0/24,dhcpstart=192.168.76.9",
"-device",
"virtio-net-pci,netdev=u1,disable-legacy=on"
],
Some(NetworkDevice::VirtioNetMmio) => &[
"-netdev",
"user,id=u1,hostfwd=tcp::9975-:9975,hostfwd=udp::9975-:9975,net=192.168.76.0/24,dhcpstart=192.168.76.9",
"-device",
"virtio-net-device,netdev=u1"
],
Some(NetworkDevice::Rtl8139) => &[
"-netdev",
"user,id=u1,hostfwd=tcp::9975-:9975,hostfwd=udp::9975-:9975,net=192.168.76.0/24,dhcpstart=192.168.76.9",
"-device",
"rtl8139,netdev=u1"
],
None => &[],
fn netdev_args(&self) -> Vec<String> {
let Some(netdev) = self.netdev else {
return vec![];
};

let mut netdev_args = vec![
"-netdev".to_string(),
"user,id=u1,hostfwd=tcp::9975-:9975,hostfwd=udp::9975-:9975,net=192.168.76.0/24,dhcpstart=192.168.76.9".to_string(),
"-device".to_string(),
];

let mut device_arg = match netdev {
NetworkDevice::VirtioNetPci => "virtio-net-pci,netdev=u1,disable-legacy=on",
NetworkDevice::VirtioNetMmio => "virtio-net-device,netdev=u1",
NetworkDevice::Rtl8139 => "rtl8139,netdev=u1",
}
.to_string();

if !self.no_default_virtio_features
&& matches!(
netdev,
NetworkDevice::VirtioNetPci | NetworkDevice::VirtioNetMmio
) {
device_arg.push_str(",packed=on,mq=on");
}

netdev_args.push(device_arg);

netdev_args
}

fn virtiofsd_args(&self) -> Vec<String> {
if self.virtiofsd {
let memory = self.memory();
let default_virtio_features = if !self.no_default_virtio_features {
",packed=on"
} else {
""
};
vec![
"-chardev".to_string(),
"socket,id=char0,path=./vhostqemu".to_string(),
"-device".to_string(),
"vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=root".to_string(),
format!("vhost-user-fs-pci,queue-size=1024{default_virtio_features},chardev=char0,tag=root"),
"-object".to_string(),
format!("memory-backend-file,id=mem,size={memory}M,mem-path=/dev/shm,share=on"),
"-numa".to_string(),
Expand Down

0 comments on commit 80f688e

Please sign in to comment.