Merge branch 'master' of github.com:jollheef/appvm

This commit is contained in:
Vladimir Serov 2019-12-30 00:23:37 +03:00
commit 555768d03b
No known key found for this signature in database
GPG key ID: 6BA7C26C3FDF7BB3
6 changed files with 57 additions and 17 deletions

16
.github/workflows/macos.yml vendored Normal file
View file

@ -0,0 +1,16 @@
name: macOS
on: [push]
jobs:
build:
name: Build
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- name: Fetch dependencies
run: go get -d ./...
- name: Build
run: go build

16
.github/workflows/ubuntu.yml vendored Normal file
View file

@ -0,0 +1,16 @@
name: Ubuntu
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Fetch dependencies
run: go get -d ./...
- name: Build
run: go build

View file

@ -47,7 +47,7 @@ You need to **relogin** if you install virt-manager (libvirt) first time.
$ appvm start chromium --verbose $ appvm start chromium --verbose
$ # ... long wait for first time, because we need to collect a lot of packages $ # ... long wait for first time, because we need to collect a lot of packages
You can customize local settings in `$GOPATH/code.dumpstack.io/tools/appvm/nix/local.nix`. You can customize local settings in **~/.config/appvm/nix/local.nix**.
Default hotkey to release cursor: ctrl+alt. Default hotkey to release cursor: ctrl+alt.

View file

@ -106,13 +106,9 @@ func list(l *libvirt.Libvirt) {
} }
for _, f := range files { for _, f := range files {
if f.Name() != "base.nix" &&
f.Name() != "local.nix" &&
f.Name() != "local.nix.template" {
fmt.Println("\t", f.Name()[0:len(f.Name())-4]) fmt.Println("\t", f.Name()[0:len(f.Name())-4])
} }
} }
}
func copyFile(from, to string) (err error) { func copyFile(from, to string) (err error) {
source, err := os.Open(from) source, err := os.Open(from)
@ -264,7 +260,6 @@ func stupidProgressBar() {
} }
func start(l *libvirt.Libvirt, name string, verbose bool) { func start(l *libvirt.Libvirt, name string, verbose bool) {
// Currently binary-only installation is not supported, because we need *.nix configurations
appvmPath := configDir appvmPath := configDir
// Copy templates // Copy templates
@ -317,7 +312,7 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) {
table := tablewriter.NewWriter(os.Stdout) table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Application VM", "Used memory", "Current memory", "Max memory", "New memory"}) table.SetHeader([]string{"Application VM", "Used memory", "Current memory", "Max memory", "New memory"})
for _, d := range domains { for _, d := range domains {
if d.Name[0:5] == "appvm" { if strings.HasPrefix(d.Name, "appvm_") {
name := d.Name[6:] name := d.Name[6:]
memoryUsedRaw, err := ioutil.ReadFile(os.Getenv("HOME") + "/appvm/" + name + "/.memory_used") memoryUsedRaw, err := ioutil.ReadFile(os.Getenv("HOME") + "/appvm/" + name + "/.memory_used")

View file

@ -40,14 +40,6 @@ startup = do
spawn "${pkgs.spice-vdagent}/bin/spice-vdagent" spawn "${pkgs.spice-vdagent}/bin/spice-vdagent"
''; '';
environment.systemPackages = [ pkgs.bc ];
services.cron = {
enable = true;
systemCronJobs = [
"* * * * * root free -m | grep Mem | awk '{print $2 \"-\" $4}' | bc > /home/user/.memory_used"
];
};
systemd.services.home-user-build-xmonad = { systemd.services.home-user-build-xmonad = {
description = "Link xmonad configuration"; description = "Link xmonad configuration";
serviceConfig = { serviceConfig = {
@ -89,5 +81,27 @@ startup = do
}; };
wantedBy = ["timers.target"]; wantedBy = ["timers.target"];
}; };
systemd.services."autoballoon" = {
serviceConfig = {
StartLimitBurst = 100;
};
script = ''
${pkgs.procps}/bin/free -m | grep Mem | \
${pkgs.gawk}/bin/awk '{print $2 "-" $4}' | \
${pkgs.bc}/bin/bc > /home/user/.memory_used
'';
};
systemd.timers."autoballoon" = {
description = "Auto update resolution crutch";
timerConfig = {
OnBootSec = "1s";
OnUnitInactiveSec = "1s";
Unit = "autoballoon.service";
AccuracySec = "1us";
};
wantedBy = ["timers.target"];
};
} }
`) `)

1
xml.go
View file

@ -6,7 +6,6 @@ import "fmt"
// Believe me, you shouldn't. // Believe me, you shouldn't.
func generateXML(name, vmNixPath, reginfo, img, sharedDir string) string { func generateXML(name, vmNixPath, reginfo, img, sharedDir string) string {
// TODO: Define XML in go
return fmt.Sprintf(xmlTmpl, "appvm_"+name, vmNixPath, vmNixPath, vmNixPath, return fmt.Sprintf(xmlTmpl, "appvm_"+name, vmNixPath, vmNixPath, vmNixPath,
reginfo, img, sharedDir, sharedDir, sharedDir) reginfo, img, sharedDir, sharedDir, sharedDir)
} }