From c0801541b3b405f3431e49a9de06c11cfa1ce06d Mon Sep 17 00:00:00 2001 From: msm-code Date: Mon, 30 Mar 2020 21:53:02 +0000 Subject: [PATCH] Fix random panics during autoballonning. (#17) There is a race condition, when good behaving VMs will temporarily truncate .memory_used to 0 bytes (update is not atomic). Also, as a matter of principle, VMs should not crash the host, ever. Co-authored-by: msm --- appvm.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appvm.go b/appvm.go index 19c3abd..574de04 100644 --- a/appvm.go +++ b/appvm.go @@ -310,6 +310,10 @@ func autoBalloon(l *libvirt.Libvirt, memoryMin, adjustPercent uint64) { log.Println(err) continue } + if len(memoryUsedRaw) == 0 { + log.Println("Empty .memory_used file for domain", name) + continue + } memoryUsedMiB, err := strconv.Atoi(string(memoryUsedRaw[0 : len(memoryUsedRaw)-1])) if err != nil { log.Println(err)