Coder Social home page Coder Social logo

jollheef / appvm Goto Github PK

View Code? Open in Web Editor NEW
241.0 14.0 19.0 718 KB

Nix-based app VMs

License: GNU General Public License v3.0

Nix 13.29% Go 84.51% Makefile 2.20%
security security-hardening virtualization isolation isolation-framework nix libvirt nixos

appvm's Introduction

Documentation Status

Nix application VMs: security through virtualization

Simple application VMs (hypervisor-based sandbox) based on Nix package manager.

Uses one read-only /nix directory for all appvms. So creating a new appvm (but not first) is just about one minute.

appvm screenshot

Installation

See related documentation.

Usage

Search for applications

$ appvm search chromium

Run application

$ appvm start chromium
$ # ... long wait for first time, because we need to collect a lot of packages

Synchronize remote repos for applications

$ appvm sync

You can customize local settings in ~/.config/appvm/nix/local.nix.

Default hotkey to release cursor: ctrl+alt.

Shared directory

$ ls appvm/chromium
foo.tar.gz
bar.tar.gz

Close VM

$ appvm stop chromium

Automatic ballooning

Add this command:

$ appvm autoballoon

to crontab like that:

$ crontab -l
* * * * * /home/user/dev/go/bin/appvm autoballoon

appvm's People

Contributors

cab404 avatar ilian avatar jollheef avatar msm-code avatar onny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appvm's Issues

Qemu error: PCI slot 2 function 0 not available for qxl-vga

Hey,
when trying to use appvm start chromium I get following error:

2022/05/20 17:32:19 internal error: process exited while connecting to monitor: qemu-system-x86_64: -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/nix/store,readonly: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
2022-05-20T15:32:18.834702Z qemu-system-x86_64: -device {"driver":"qxl-vga","id":"video0","max_outputs":1,"ram_size":536870912,"vram_size":536870912,"vram64_size_mb":0,"vgamem_mb":256,"bus":"pci.0","addr":"0x2"}: PCI: slot 2 function 0 not available for qxl-vga, in use by e1000,id=(null)

I tried to patch xml.go but without success :(

Configuration file

There are some command line (e.g. --min-memory and --adj-memory for autoballooning, also --networking-model in #20) switches that are better to have also in the configuration file that not introduced yet.

So the idea is to have a configuration file that will set all Default("...") in parameters for kingpin.

macOS support

Libvirt available in home-brew, and qemu on macOS since v2.12 (24 April 2018) supports Hypervisor.framework.

Which means it's possible to port appvm to macOS.

README: Compare with Qubes OS?

Thank you for publishing this really cool project.
It seems to be inspired on the AppVMs in Qubes OS.
I would like to know what are the differences between this implementation of the idea and Qubes OS, and what is the maturity status of this project? (Or, similarly, why did you reimplement it?)
How would I recognize a spoofed window from a compromised appvm?

nixos 20.03: permission problems for libvirt connection

I did a fresh install of nixos today, and I'm currently a bit out of ideas. I followed the installation procedure without problems, but later:

appvm start firefox

results in:

2020/07/27 19:03:43 authentication required

The error is thrown at that line:

appvm/appvm.go

Line 507 in d9c6519

log.Fatal(err)

I've tried to tweak libvirt and polkit configuration, but to no avail (usual advice on the internet is to change unix_sock_group, but it doesn't help here. Nixos uses polkit auth by default, but polkit should allow my user too. My user is a member of libvirtd as it should). Does anyone know why (apparently) appvm can't read libvirt's socket?

I can run virsh -c qemu:///system list as my user and it works correctly.

When I use sudo:

sudo appvm start firefox

It has no permission problems and almost works correctly, except it has a different error (trace: Duplicate uid 0). I could probably work around it, but I suppose sudo is not the solution to everything and I prefer to find the underlying problem.

Can't start appvm

Ubuntu 16.04

v@v-To-be-filled-by-O-E-M:~$ appvm list
Started VM:

Available VM:
	 chromium
	 firefox
v@v-To-be-filled-by-O-E-M:~$ appvm start chromium
trace: Default graphical session, 'xmonad', not found.
Valid names for 'services.xserver.displayManager.defaultSession' are:
  none+xmonad

error: The option value `services.xserver.displayManager.defaultSession' in `/home/v/.nix-defexpr/channels/nixpkgs/nixos/modules/services/x11/display-managers/default.nix' is not of type `session name'.
(use '--show-trace' to show detailed location information)
2020/01/14 15:46:28 <nil> [] []
2020/01/14 15:46:28 ret code: 1, out: [], err: []

Wayland support

Currently appvm uses X11/Xorg. This issue is for experimentation with Wayland, with eventual goal being to have optional Wayland support without Xorg on the guest, and maybe to pass windows to the host more directly with waypipe.
Possible approaches

  • cage (or other simple wayland compositor)
    Cage is a simple compositor that starts a single application full-screen and quits as soon as that application quits.
    Problems: no support for automatic resizing or other features of SPICE. It's a deal-breaker, as the almost-native experience that we thrive for is ruined by the need to capture pointer and keyboard, and the window does not resize correctly.
    Possible solution: write a daemon that reacts to SPICE events.
    Things done

    • mingetty autologins user, cage starts from loginShellInit
      Problems: not very fast, feels bodgy
    • cage replaces getty, logs in via a PAM module (as suggested upstream)
    • Make cage understand SPICE (either by patching cage or by writing a shim`
    • Find another wayland compositor that already knows SPICE
  • GNOME3
    Gnome3 supports SPICE natively or maybe not, see the following

    Potential problems: SPICE not working, very heavy, not sure if it can run a single full-screen app without all the fuss (see https://help.gnome.org/admin/system-admin-guide/stable/lockdown-single-app-mode.html.en, not sure if this is for wayland or for X)
    Things done:

    • GDM starts a wayland gnome kiosk session
      Problems: really heavy, might be buggy
    • dbus-launch gnome-session from loginShellInit
      Problems: might not support SPICE or whatever
  • waypipe without compositor
    It might be possible to run waypipe on a guest without having a compositor at all. This would solve most of our problems with SPICE, since all of the window management now happens on the host. I have not looked into waypipe, so maybe I'm wrong, but this looks like the most elegant and "correct" solution of them all.
    Problems: might not actually run without a compositor, might be slow, requires networking between guest and host, might be insecure
    Investigation process:

    • waypipe can run without a compositor (tested with waypipe ssh headless-server konsole, where headless-server only has waypipe and konsole installed)
    • Figure out how host and guest can talk to each other
    • Figure out how to make guest's waypipe server talk with host's waypipe client (using -s argument and socat)

    Things done:

    • Run a guest with waypipe and the application installed, then run waypipe ssh user@guest application from the host (we have to figure out credentials)
    • Run waypipe client on a host, run guest with waypipe server CMD, make them communicate (I like this solution the most of them all)

Permission problems

appvm start chromium
/nix/store/gr8x944bv3cwhk4i5751yhbqix1b16lh-nixos-vm
2020/07/14 22:20:52 internal error: process exited while connecting to monitor: 2020-07-14T21:20:52.185266Z qemu-system-x86_64: -blockdev {"node-name":"libvirt-1-format","read-only":false,"cache":{"direct":false,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage","backing":null}: Could not reopen file: Permission denied

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.