Skip to content

Comments

Protect muvm-server, spawn one as root and monitor available host memory#89

Merged
slp merged 3 commits intoAsahiLinux:mainfrom
slp:muvm-root-server
Oct 31, 2024
Merged

Protect muvm-server, spawn one as root and monitor available host memory#89
slp merged 3 commits intoAsahiLinux:mainfrom
slp:muvm-root-server

Conversation

@slp
Copy link
Collaborator

@slp slp commented Oct 15, 2024

The goal of this PR is to enable muvm to request the guest to adjust its file system cache goals accordingly to the amount of available memory on the host.

The first two commits just set the infrastructure, first by adding some minimal protection to muvm-server, and then spawning a second instance of it as root (we need this to operate in "/proc/sys/vm", but surely will come handy for many other things).

The latter implements the monitor and the ability to request the guest to adjust watermark_scale_factor as needed, or even to drop its pagecache if the situation is critical.

@slp slp force-pushed the muvm-root-server branch from 5af5752 to ea1ff2f Compare October 16, 2024 05:53
@slp slp force-pushed the muvm-root-server branch from ea1ff2f to 158d03a Compare October 16, 2024 13:58
@slp slp marked this pull request as ready for review October 16, 2024 14:00
@slp slp force-pushed the muvm-root-server branch 3 times, most recently from 158d03a to 3567018 Compare October 18, 2024 09:50
Copy link
Member

@alyssarosenzweig alyssarosenzweig left a comment

Choose a reason for hiding this comment

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

lgtm, but probably should get review/testing from someone more rust-brained

@teohhanhui
Copy link
Collaborator

Will take another look... 🙇

slp added 3 commits October 31, 2024 16:46
While our threat model targets single user systems, let's at least
protect muvm-server with an authentication cookie, so only the user
creating the microVM (and root) can access it.

The cookie is stored in the lockfile, instead of the server port (this
was useless in practice and generated confusion as could override the
command line). The lockfile is located in XDG_RUNTIME_DIR, which in
properly configured systems is only accessible to its owner.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Being able to run commands as root comes handy to debug the guest and
will also be used to tune the virtual memory parameters on demand.

Signed-off-by: Sergio Lopez <slp@redhat.com>
This monitor checks the ratio of memory available on the host and, if
needed, contacts the VM (through muvm-server) to adjust
/proc/sys/vm/watermark_scale_factor and, if the situation is critical,
to request it to drop its caches.

Signed-off-by: Sergio Lopez <slp@redhat.com>
@slp slp force-pushed the muvm-root-server branch from 3567018 to 7ec84b0 Compare October 31, 2024 15:55
@slp slp merged commit b706c35 into AsahiLinux:main Oct 31, 2024
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.

3 participants