Fix misleading memory usage for VMs without guest-side stats
Windows VMs only report balloon current/max/rss, not available/unused. Previously this fell through to RSS which showed ~100% usage. Now VMs without balloon.available show allocated RAM without a usage bar. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7
app.py
7
app.py
@@ -216,13 +216,12 @@ def get_vm_live_stats():
|
|||||||
balloon_unused = s.get("balloon_unused", 0)
|
balloon_unused = s.get("balloon_unused", 0)
|
||||||
balloon_rss = s.get("balloon_rss", 0)
|
balloon_rss = s.get("balloon_rss", 0)
|
||||||
|
|
||||||
if balloon_avail > 0:
|
if balloon_avail > 0 and balloon_unused >= 0:
|
||||||
mem_total = balloon_avail // 1024 # KiB to MB
|
mem_total = balloon_avail // 1024 # KiB to MB
|
||||||
mem_used = (balloon_avail - balloon_unused) // 1024
|
mem_used = (balloon_avail - balloon_unused) // 1024
|
||||||
elif balloon_rss > 0:
|
|
||||||
mem_total = 0
|
|
||||||
mem_used = balloon_rss // 1024
|
|
||||||
else:
|
else:
|
||||||
|
# No guest-side stats (e.g. Windows without full guest agent).
|
||||||
|
# Mark as unavailable — frontend will show allocated RAM only.
|
||||||
mem_total = 0
|
mem_total = 0
|
||||||
mem_used = 0
|
mem_used = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user