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

Integration with krunkit #24

Merged
merged 5 commits into from
Feb 9, 2025
Merged

Integration with krunkit #24

merged 5 commits into from
Feb 9, 2025

Conversation

nirs
Copy link
Owner

@nirs nirs commented Feb 3, 2025

Add krunkit example tested with upstream krunkit.

  • Add --driver krunkit
  • Add --krunkit-port, required for running multiple krunkit vms.
  • Add --vmnet-offload {auto,on,off}, required for testing krunkit upstream.

Example run:

% ./example server --driver krunkit
Starting vmnet-helper for 'server' with interface id 'bdc7b3e0-8594-4814-aa25-05187ad2a36e'
Creating cloud-init iso '/Users/nir/.vmnet-helper/vms/server/cidata.iso'
Starting 'krunkit' virtual machine 'server' with mac address '92:c9:52:b7:6c:08'
Virtual machine IP address: 192.168.105.2

Upstream libkrun enables offloading features, showing very inconsistent performance. When disabling offloading, it shows similar performance as vfkit.

network mode vm host to vm cpu vm to vm cpu
vmnet-helper shared vfkit 10.5 Gbits/s 71% 13.5 Gbits/s 88%
vmnet-helper bridged vfkit 13.0 Gbits/s 88% 12.9 Gbits/s 86%
vmnet-helper shared krunkit[1] 1.4 Gbits/s 33% 29.9 Gbits/s 63%
vmnet-helper bridged krunkit[1] 1.4 Gbits/s 34% 31.0 Gbits/s 63%
vmnet-helper shared krunkit[2] 9.8 Gbits/s 70% 9.4 Gbits/s 84%
vmnet-helper bridged krunkit[2] 9.9 Gbits/s 94% 8.9 Gbits/s 88%

[1] krunkit built with libkrun upstream
[2] krunkit built with libkrun patched to disable offloading

Based on #22
Fixes #18

@nirs nirs force-pushed the krunkit branch 5 times, most recently from 45cad1b to dcfd375 Compare February 8, 2025 07:27
@nirs nirs marked this pull request as ready for review February 8, 2025 07:36
@nirs nirs marked this pull request as draft February 8, 2025 07:38
@nirs nirs force-pushed the krunkit branch 3 times, most recently from 6ae77b7 to 2c88d5b Compare February 9, 2025 01:19
@nirs nirs marked this pull request as ready for review February 9, 2025 01:19
@nirs nirs force-pushed the krunkit branch 8 times, most recently from 7ad9692 to 588946b Compare February 9, 2025 02:50
nirs added 3 commits February 9, 2025 05:10
Trying to stabilize the qemu integration job, failing randomly.
The vment framework supports partly documented options to enable TCP
segmentation offload (TSO) and checksum offload. Enabling the offload
options typically decreases performance but we must enable them to
integrate with krunkit, which does not have a way to disable the
offloading.

/*
 * @constant vmnet_enable_tso_key
 * Enable TCP segmentation offload. Note, when this is enabled, the
 * interface may generate large (64K) TCP frames. It must also
 * be prepared to accept large TCP frames as well.
 */

/*
 * @constant vmnet_enable_checksum_offload_key
 * Enable checksum offload for this interface. The checksums that are
 * offloaded are: IPv4 header checksum, UDP checksum (IPv4 and IPv6),
 * and TCP checksum (IPv4 and IPv6).
 *
 * In order to perform the offload function, all packets flowing in and
 * out of the vmnet_interface instance are verified to pass basic
 * IPv4, IPv6, UDP, and TCP sanity checks. A packet that fails any
 * of these checks is simply dropped.
 *
 * On output, checksums are automatically computed as necessary
 * on each packet sent using vmnet_write().
 *
 * On input, checksums are verified as necessary. If any checksum verification
 * fails, the packet is dropped and not delivered to vmnet_read().
 *
 * Note that the checksum offload function for UDP and TCP checksums is unable
 * to deal with fragmented IPv4/IPv6 packets. The VM client networking stack
 * must handle UDP and TCP checksums on fragmented packets itself.
 */
When enabling TSO maximum packet size is 65550 bytes and sendmsg_x()
fails sporadically with "message too long". Increase the buffer size to
avoid this issue.

Increase receive buffer to make clients that do not handle ENOBUFS less
likely to fail. One example is libkrun.

Issues:
- When enabling TSO and checksum offload, memory usage is doubled.
nirs added 2 commits February 9, 2025 05:51
Since krunkit does not support fd connection, add new "auto" mode
selecting the best connection for the driver. This makes it easy to try
krunkit, and make it possible to try socket connection for vfkit.

Since krunkit always serve the restful-uri, add --krunkit-port option.
This is required to start multiple krunkit vms. Without the option the
second vm will fail to start.

Using local build of krunkit since current brew version is not
compatible with current libkrun version.

Example run:

    % ./example server --driver krunkit --krunkit-port 8081
    Starting vmnet-helper for 'server' with interface id 'bdc7b3e0-8594-4814-aa25-05187ad2a36e'
    Creating cloud-init iso '/Users/nir/.vmnet-helper/vms/server/cidata.iso'
    Starting 'krunkit' virtual machine 'server' with mac address '92:c9:52:b7:6c:08'
    Virtual machine IP address: 192.168.105.2
Using upstream krunkit and libkrun, since current krunkit brew version
is not compatible with current brew libkrun version.

Tested with:
- krunkit built with libkrun upstream
- krunkit built with libkrun patched to disable offloading
@nirs nirs force-pushed the krunkit branch 3 times, most recently from 796736b to fae51b0 Compare February 9, 2025 04:36
@nirs nirs merged commit 2bf28ae into main Feb 9, 2025
14 of 15 checks passed
@nirs nirs deleted the krunkit branch February 9, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integration with krunkit
1 participant