Bug 1474452

Summary: Qemu cannot get memory statistics from ballooning driver (qom-get).
Product: [Community] Virtualization Tools Reporter: Shiyanov Vadim <vadimsh853>
Component: virtio-winAssignee: Amnon Ilan <ailan>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: ghammer, juzhang, ks002278, lijin, michen, phou, vadimsh853, virt-maint, vrozenfe, wyu, xiagao, yvugenfi
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-25 06:47:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Shiyanov Vadim 2017-07-24 16:05:22 UTC
Description of problem:
Hello, first of all, I am not, actually sure, that this is a bug (however it seems to be one). I am experiencing some troubles with windows 7 VM running under qemu-kvm (managed by libvirt, created and ran mostly from virt-manager). The problem is I can use balloon:

"""
virsh # qemu-monitor-command win7 --hmp "info balloon"
balloon: actual=4096

virsh # qemu-monitor-command win7 --hmp "balloon 2048"

virsh # qemu-monitor-command win7 --hmp "info balloon"
balloon: actual=2048

virsh # qemu-monitor-command win7 --hmp "balloon 4096"

virsh # qemu-monitor-command win7 --hmp "info balloon"
balloon: actual=4096
"""

but when it comes to guest memory stats, I can only see "balloon-free" (not obtained from balloon driver) stats:

"""
virsh # dommemstat win7 --period 10

virsh # dommemstat win7
actual 4194304
last_update 1500911258
rss 4130124
"""

And last_update never changes.
As far as I know, virsh (and libvirt) only get, what qemu can obtain. So I tried using qemu tools themselves:

"""
virsh # qemu-monitor-command win7 '{ "execute": "qom-get",  "arguments": { "path": "/machine/peripheral/balloon0",  "property": "guest-stats" } }'
{"return":{"stats":{"stat-swap-out":-1,"stat-available-memory":-1,"stat-free-memory":-1,"stat-minor-faults":-1,"stat-major-faults":-1,"stat-total-memory":-1,"stat-swap-in":-1},"last-update":1500911258},"id":"libvirt-463"}
"""

Driver thinks that guest does not support any stats (but the driver seems to be working properly, hence, I am not sure that this is a bug).
Is it really true, that windows driver don't support them at all?

Note: tried reinstalling system, installing system updates (on guest of course, Linux is up to date), tried both last and last stable drivers.

Version-Release number of selected component (if applicable):
guest - windows 7
host:

"""
uname -- all
Linux arch.localhost 4.9.37-1-lts #1 SMP Wed Jul 12 19:22:39 CEST 2017 x86_64 GNU/Linux
"""

Qemu:

"""
qemu-system-x86_64 --version
QEMU emulator version 2.9.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
"""

Libvirt:

"""
libvirtd --version
libvirtd (libvirt) 3.5.0
"""

How reproducible:
always

Steps to Reproduce:
1. Install qemu, libvirt, virt-manager.
2. Create VM and install windows 7.
3. Install VirtIO driver in it (either all or just balloon).
4. Reboot and type commands from description.

Actual results:
Only 3 memory stats from dommemstat.

Expected results:
All 10 stats.

Additional info:
If my report is missing something, please, don't hesitate to ask for additional info.

Comment 1 Vadim Rozenfeld 2017-07-25 01:24:34 UTC
Can you check that balloon service is up and running up on your system? 
If it is, then what is the balloon driver version?

Thanks,
Vadim.

Comment 2 xiagao 2017-07-25 06:33:52 UTC
Yes,if did not install blnsrv.exe in guest. The qmp output info will like that.
{ "execute": "qom-get","arguments": {"path":"/machine/peripheral/balloon0","property":"guest-stats" } }
{"return": {"stats": {"stat-swap-out": -1, "stat-available-memory": -1, "stat-free-memory": -1, "stat-minor-faults": -1, "stat-major-faults": -1, "stat-total-memory": -1, "stat-swap-in": -1}, "last-update": 1500963304}}

after run "blnsrv.exe -i" in windows guest. The qmp output info will be like:
{ "execute": "qom-get","arguments": {"path":"/machine/peripheral/balloon0","property":"guest-stats" } }
{"return": {"stats": {"stat-swap-out": 213032960, "stat-available-memory": 724871168, "stat-free-memory": 724869120, "stat-minor-faults": 1540819, "stat-major-faults": 21126, "stat-total-memory": 3220688896, "stat-swap-in": 611061760}, "last-update": 1500963581}}

Comment 3 Shiyanov Vadim 2017-07-25 06:35:49 UTC
Hello, Vadim,

The "Balloon" service is running:

"""
sc query "Balloon" | find "STATE"
        STATE               : 4 RUNNING
"""

Driver version is 61.74.104.14000 (this one should be from the last virtio-win iso 0.1.140.1-1, I also tried last stable 0.1.126 iso).

Yours sincerely,
Vadim

Comment 4 Shiyanov Vadim 2017-07-25 06:47:09 UTC
Hello, xiagao,

Thanks, that was the problem. Please, add this to your guides about installation of VirtIO drivers (as I have never found anything like that while searching the web).
For example on redhat customer portal:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Host_Configuration_and_Guest_Installation_Guide/form-Virtualization_Host_Configuration_and_Guest_Installation_Guide-Para_virtualized_drivers-Mounting_the_image_with_virt_manager.html
I will suggest adding this info in ArchWiki if you don't mind.
Also marking issue as closed, not a bug.

Thanks,
Vadim

Comment 5 xiagao 2017-07-31 14:10:18 UTC
(In reply to Shiyanov Vadim from comment #4)
> Hello, xiagao,
> 
> Thanks, that was the problem. Please, add this to your guides about
> installation of VirtIO drivers (as I have never found anything like that
> while searching the web).
> For example on redhat customer portal:
> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/
> html/Virtualization_Host_Configuration_and_Guest_Installation_Guide/form-
> Virtualization_Host_Configuration_and_Guest_Installation_Guide-
> Para_virtualized_drivers-Mounting_the_image_with_virt_manager.html
> I will suggest adding this info in ArchWiki if you don't mind.
> Also marking issue as closed, not a bug.
> 
> Thanks,
> Vadim

Hi Vadim,

We will add it to the guide. And thanks for your testing and suggestion.

BR,
xiagao

Comment 6 ks002278@163.com 2020-03-25 02:01:49 UTC
thought I have install the virtio balloon driver ,and run the blnsrv.exe -i , but my win7 vm still can't get enough mem stat information,such as:

bash-4.1# virsh dommemstat root-vsys_win7
actual 2097152
last_update 1585044578
rss 36644

and the cmd:
bash-4.1# virsh qemu-monitor-command root-vsys_win7 '{"execute":"qom-get", "arguments":{"path":"//machine/peripheral/balloon0","property":"guest-stats"}}' --pretty
{
  "return": {
    "stats": {
      "stat-htlb-pgalloc": 18446744073709551615, //-1, 64bit
      "stat-swap-out": 18446744073709551615,    // -1, 64bit
      "stat-available-memory": 18446744073709551615,  // -1, 64bit
      "stat-htlb-pgfail": 18446744073709551615,
      "stat-free-memory": 18446744073709551615,
      "stat-minor-faults": 18446744073709551615,
      "stat-major-faults": 18446744073709551615,
      "stat-total-memory": 18446744073709551615,
      "stat-swap-in": 18446744073709551615,
      "stat-disk-caches": 18446744073709551615
    },
    "last-update": 1585044578
  },
  "id": "libvirt-952"
}
from above ,the qemu can't get guest root-vsys_win7 mem details

my virtio balloon driver is: 61.80.104.17300 and blnsrv status result :"Status: Service RUNNING"
my guest os is windows 7 64bit

can any one give me some suggestion ,what the reason lead the failure ? thanks !

Comment 7 xiagao 2021-11-26 01:33:32 UTC
(In reply to ks002278 from comment #6)
> thought I have install the virtio balloon driver ,and run the blnsrv.exe -i
> , but my win7 vm still can't get enough mem stat information,such as:
> 
> bash-4.1# virsh dommemstat root-vsys_win7
> actual 2097152
> last_update 1585044578
> rss 36644
> 
> and the cmd:
> bash-4.1# virsh qemu-monitor-command root-vsys_win7 '{"execute":"qom-get",
> "arguments":{"path":"//machine/peripheral/balloon0","property":"guest-
> stats"}}' --pretty
> {
>   "return": {
>     "stats": {
>       "stat-htlb-pgalloc": 18446744073709551615, //-1, 64bit
>       "stat-swap-out": 18446744073709551615,    // -1, 64bit
>       "stat-available-memory": 18446744073709551615,  // -1, 64bit
>       "stat-htlb-pgfail": 18446744073709551615,
>       "stat-free-memory": 18446744073709551615,
>       "stat-minor-faults": 18446744073709551615,
>       "stat-major-faults": 18446744073709551615,
>       "stat-total-memory": 18446744073709551615,
>       "stat-swap-in": 18446744073709551615,
>       "stat-disk-caches": 18446744073709551615
>     },
>     "last-update": 1585044578
>   },
>   "id": "libvirt-952"
> }
> from above ,the qemu can't get guest root-vsys_win7 mem details
> 
> my virtio balloon driver is: 61.80.104.17300 and blnsrv status result
> :"Status: Service RUNNING"
> my guest os is windows 7 64bit
> 
> can any one give me some suggestion ,what the reason lead the failure ?
> thanks !

Do you set "period" before getting memstat?
# virsh dommemstat win2016 --period 2
# virsh dommemstat win2016
actual 4194304
swap_in 1136256
swap_out 0
major_fault 61995
minor_fault 2628933
unused 3155332
available 4193760
usable 3176434
last_update 1637889879
disk_caches 42204
hugetlb_pgalloc 0
hugetlb_pgfail 0
rss 4305268

Thanks,
Xiaoling