Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2232484

Summary: VM stats mem buffered and cached not reported
Product: Red Hat Enterprise Virtualization Manager Reporter: Marcus West <mwest>
Component: ovirt-engineAssignee: Nobody <nobody>
Status: CLOSED NOTABUG QA Contact: meital avital <mavital>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5.3CC: michal.skrivanek, tgolembi
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-10-25 11:10:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: UX RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marcus West 2023-08-17 05:48:09 UTC
# Description of problem:

When checking VM statistics via API, mem buffered and mem cached always report '0'.  Also, a value is reported via the GUI, however it's different that what is reported on the VM itself ('free -m').  Is this value reliable?

# Version-Release number of selected component (if applicable):

ovirt-engine-4.5.3.7-1.el8ev.noarch
qemu-guest-agent-6.2.0-11.module+el8.6.0+14707+5aa4b42d.x86_64 (running on RHEL8.6 VM)


# How reproducible:

Always


# Steps to Reproduce:
1. Check VM stats via GUI
2. Check VM stats via API
3. Check VM stats via OS ('free -m')

# Actual results:

- API always returns '0'
- GUI returns a number different to OS ('free -m')

# Expected results:

- values should be the same

# Additional info:

'vdsm-client VM getStats' does not report anything about cached or buffered memory:

$ vdsm-client VM getStats vmID="8f5dd144-a234-472a-9d8b-c7c7722f4509"
... 
        "memUsage": "32",
        "memoryStats": {
            "majflt": 0,
            "mem_free": "1067700",
            "mem_total": "1270468",
            "mem_unused": "687132",
            "minflt": 0,
            "pageflt": 0,
            "swap_in": 0,
            "swap_out": 0
        },
...

Comment 2 Michal Skrivanek 2023-08-21 12:11:57 UTC
Tomas, do you recall if qemu-ga is actually reporting these?

Comment 3 Tomáš Golembiovský 2023-08-23 08:21:59 UTC
(In reply to Michal Skrivanek from comment #2)
> Tomas, do you recall if qemu-ga is actually reporting these?

To be precise, the values are not reported by qemu-ga but by the balloon driver.

(In reply to Marcus West from comment #0)
> When checking VM statistics via API, mem buffered and mem cached always
> report '0'.

That is because those fields correspond to the values reported by oVirt Guest Agent. Since you're not running oVirt Guest Agent in your VM (and that is completely fine!), you will always see 0 in those fields.

> Also, a value is reported via the GUI, however it's different
> that what is reported on the VM itself ('free -m').  Is this value reliable?

What you see in GUI and what you can see from vdsm-client are combined values. First, mem_unused (from the vdsm-client command) corresponds to what the "free" command reports as free memory (in vdsm we call it unused). GUI shows mem_free which is sum of the unused memory (mem_unused) and buffers/caches together. The second number in GUI corresponds to only buffers/caches and is computed from formula "mem_free - mem_unused".

Hope this helps.

Comment 4 Marcus West 2023-08-24 01:17:33 UTC
Hello, thanks for the feedback.

However on my test VM, I have Memory Ballooning enabled, and I can see it in the VM:
~~~
00:07.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon
00:08.0 Unclassified device [00ff]: Red Hat, Inc. Virtio RNG

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        3740  0.0  0.5 135480  7324 ?        Ssl  Aug18   1:33 /usr/bin/qemu-ga --method=virtio-serial --path=/dev/virtio-ports/org.qemu.guest_agent.0 --blacklist=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush,guest-exec,guest-exec-status -F/etc/qemu-ga/fsfreeze-hook
~~~

But memory.buffered and memory.cached still show as '0' via the API.  Is there something else I need to see these statistics via the API?

Comment 5 Tomáš Golembiovský 2023-08-24 09:36:08 UTC
You will not be able to see the stats in API unless you install oVirt Guest Agent. But oVirt Guest Agent has been deprecated and is not available on EL8.

To get the sum of buffers and caches you can subtract memory.unused from memory.free. This is exactly what UI does. But separate values for buffers or caches are not available.

Let me try to explain little bit more...

To get any kind of memory statistics from the guest you need either oVirt Guest Agent (which is deprecated for a long time) or a balloon driver. oVirt Guest Agent used to provide statistics with more granularity and reported buffers and caches as two separate values. With the balloon driver we don't have this granularity and VDSM can see only the sum of buffers and caches together. To avoid making the APIs (internal and external) confusing VDSM does not provide the sum as a separate statistic. If the client (UI or other) needs to have the sum of buffers and caches it can compute it by simple mathematical operation from "free" and "unused".

Comment 9 Michal Skrivanek 2023-10-25 11:10:30 UTC
close as per comment #5, any potential enhancement need to be filed against qemu-ga, but considering the RHV lifecycle it's not likely to get into RHV even if implemented in qemu-ga