-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
muvm: init from krun as 0.2.0 #347792
Open
RossComputerGuy
wants to merge
3
commits into
NixOS:master
Choose a base branch
from
ExpidusOS:feat/rename-krun-as-muvm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+133
−70
Open
muvm: init from krun as 0.2.0 #347792
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchFromGitHub, | ||
fetchpatch, | ||
rustPlatform, | ||
libkrun, | ||
makeWrapper, | ||
passt, | ||
dhcpcd, | ||
sommelier, | ||
systemd, | ||
udev, | ||
pkg-config, | ||
fex, | ||
coreutils, | ||
procps, | ||
substituteAll, | ||
withSommelier ? false, | ||
}: | ||
|
||
rustPlatform.buildRustPackage rec { | ||
pname = "muvm"; | ||
version = "0.2.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "AsahiLinux"; | ||
repo = pname; | ||
rev = "muvm-${version}"; | ||
hash = "sha256-eB60LjI1Qr85MPtQh0Fb5ihzBahz95tXaozNe8q6o3o="; | ||
}; | ||
|
||
useFetchCargoVendor = true; | ||
cargoHash = "sha256-B3klydX4xlop0pZUzMoxMjeRV7ZqWfKY+LhL+wFS4kM="; | ||
|
||
postPatch = '' | ||
substituteAll crates/muvm/src/guest/bin/muvm-guest.rs \ | ||
--replace-fail "/usr/lib/systemd/systemd-udevd" "${systemd}/lib/systemd/systemd-udevd" | ||
''; | ||
|
||
patches = [ | ||
(substituteAll { | ||
src = ./paths.patch.in; | ||
env = { | ||
inherit procps coreutils fex; | ||
}; | ||
}) | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
rustPlatform.bindgenHook | ||
makeWrapper | ||
pkg-config | ||
]; | ||
|
||
buildInputs = [ | ||
(libkrun.override { | ||
withBlk = true; | ||
withGpu = true; | ||
withNet = true; | ||
}) | ||
udev | ||
]; | ||
|
||
# Allow for sommelier to be disabled as it can cause problems. | ||
wrapArgs = [ | ||
"--prefix PATH : ${ | ||
lib.makeBinPath ( | ||
lib.optional withSommelier [ sommelier ] | ||
++ [ | ||
dhcpcd | ||
passt | ||
(placeholder "out") | ||
] | ||
) | ||
}" | ||
]; | ||
|
||
postFixup = '' | ||
wrapProgram $out/bin/muvm $wrapArgs | ||
''; | ||
|
||
meta = { | ||
description = "Run programs from your system in a microVM"; | ||
homepage = "https://github.com/AsahiLinux/muvm"; | ||
license = lib.licenses.mit; | ||
maintainers = with lib.maintainers; [ RossComputerGuy ]; | ||
platforms = libkrun.meta.platforms; | ||
mainProgram = "muvm"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
diff --git a/crates/muvm/src/guest/mount.rs b/crates/muvm/src/guest/mount.rs | ||
index 3126ca0..35472d6 100644 | ||
--- a/crates/muvm/src/guest/mount.rs | ||
+++ b/crates/muvm/src/guest/mount.rs | ||
@@ -84,7 +84,7 @@ fn mount_fex_rootfs() -> Result<()> { | ||
// Now we need to tell FEX about this. One of the FEX share directories has an unmounted rootfs | ||
// and a Config.json telling FEX to use FUSE. Neither should be visible to the guest. Instead, | ||
// we want to replace the folders and tell FEX to use our mounted rootfs | ||
- for base in ["/usr/share/fex-emu", "/usr/local/share/fex-emu"] { | ||
+ for base in ["@fex@/share/fex-emu"] { | ||
if Path::new(base).exists() { | ||
let json = format!("{{\"Config\":{{\"RootFS\":\"{dir_rootfs}\"}}}}\n"); | ||
let path = base.to_string() + "/Config.json"; | ||
diff --git a/crates/muvm/src/monitor.rs b/crates/muvm/src/monitor.rs | ||
index 7628d83..bc43a5c 100644 | ||
--- a/crates/muvm/src/monitor.rs | ||
+++ b/crates/muvm/src/monitor.rs | ||
@@ -50,7 +50,7 @@ fn set_guest_pressure(server_port: u32, cookie: Uuid, pressure: GuestPressure) - | ||
let wsf: u32 = pressure.into(); | ||
debug!("setting watermark_scale_factor to {wsf}"); | ||
|
||
- let command = PathBuf::from("/sbin/sysctl"); | ||
+ let command = PathBuf::from("@procps@/bin/sysctl"); | ||
let command_args = vec![format!("vm.watermark_scale_factor={}", wsf)]; | ||
let env = HashMap::new(); | ||
request_launch(server_port, cookie, command, command_args, env, 0, false) | ||
diff --git a/crates/muvm/src/server/bin/muvm-server.rs b/crates/muvm/src/server/bin/muvm-server.rs | ||
index b538091..dae8895 100644 | ||
--- a/crates/muvm/src/server/bin/muvm-server.rs | ||
+++ b/crates/muvm/src/server/bin/muvm-server.rs | ||
@@ -36,7 +36,7 @@ async fn tokio_main(cookie: String) -> Result<()> { | ||
}; | ||
( | ||
server_port, | ||
- PathBuf::from("/bin/sleep"), | ||
+ PathBuf::from("@coreutils@/bin/sleep"), | ||
vec!["inf".to_string()], | ||
) | ||
} else { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change really necessary?
pname
is alreadymuvm
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purely cosmetic now, but can be problematic in combination with finalAttrs in the future: #310373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok but we're using
buildRustPackage
which doesn't supportfinalAttrs
, is there plans to makebuildRustPackage
supportfinalAttrs
or has that already happened?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It SHOULD happen I guess? Not aware of the progress though.