Bug 2189948

Summary: [virtio-win][balloon] balloon doesn't work after reboot os sometimes (win10-64)
Product: Red Hat Enterprise Linux 9 Reporter: xiagao
Component: virtio-winAssignee: Meirav Dean <mdean>
virtio-win sub component: virtio-win-prewhql QA Contact: xiagao
Status: CLOSED MIGRATED Docs Contact:
Severity: medium    
Priority: medium CC: coli, jinzhao, juzhang, lijin, qizhu
Version: 9.3Keywords: CustomerScenariosInitiative
Target Milestone: rc   
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: 2023-05-16 02:46:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description xiagao 2023-04-26 14:46:44 UTC
Description of problem:
Boot up win10-64 guest with 30G memory, try to evict guest memory to a minimum value and then try to enlarge it to the maximum one, and then evict it to half of the maximum one, and then reboot guest os, after the system booted up and watch the balloon value, it was not ballooned to the expected value(15G), so seems that balloon doesn't work after os reboot.

Here is the qmp log before and after the system reboot.
```
2023-04-26 02:40:56: {"execute": "query-balloon", "id": "lRp6Y5LN"}
2023-04-26 02:40:56: {"return": {"actual": 18107858944}, "id": "lRp6Y5LN"}
2023-04-26 02:41:11: {"timestamp": {"seconds": 1682491271, "microseconds": 286694}, "event": "BALLOON_CHANGE", "data": {"actual": 32212254720}}
2023-04-26 02:41:43: {"timestamp": {"seconds": 1682491303, "microseconds": 607396}, "event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
2023-04-26 02:41:43: {"timestamp": {"seconds": 1682491303, "microseconds": 615880}, "event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
2023-04-26 02:43:45: {"timestamp": {"seconds": 1682491311, "microseconds": 66905}, "event": "BALLOON_CHANGE", "data": {"actual": 32210157568}}
2023-04-26 02:43:45: {"timestamp": {"seconds": 1682491312, "microseconds": 62397}, "event": "BALLOON_CHANGE", "data": {"actual": 32208060416}}
2023-04-26 02:43:45: {"execute": "query-balloon", "id": "11PU1Cgr"}
2023-04-26 02:43:45: {"return": {"actual": 32208060416}, "id": "11PU1Cgr"}
2023-04-26 02:43:55: {"execute": "query-balloon", "id": "FUSSA9YL"}
2023-04-26 02:43:55: {"return": {"actual": 32208060416}, "id": "FUSSA9YL"}
2023-04-26 02:44:03: {"execute": "query-balloon", "id": "VwuFkLts"}
2023-04-26 02:44:03: {"return": {"actual": 32208060416}, "id": "VwuFkLts"}
2023-04-26 02:44:12: {"execute": "query-balloon", "id": "TNPdjEFX"}
2023-04-26 02:44:12: {"return": {"actual": 32208060416}, "id": "TNPdjEFX"}
2023-04-26 02:44:20: {"execute": "query-balloon", "id": "CUF3X1hU"}
2023-04-26 02:44:20: {"return": {"actual": 32208060416}, "id": "CUF3X1hU"}
2023-04-26 02:44:28: {"execute": "query-balloon", "id": "CDDg0jXH"}
2023-04-26 02:44:28: {"return": {"actual": 32208060416}, "id": "CDDg0jXH"}
2023-04-26 02:44:37: {"execute": "query-balloon", "id": "i7zjcSx5"}
2023-04-26 02:44:37: {"return": {"actual": 32208060416}, "id": "i7zjcSx5"}
2023-04-26 02:44:45: {"execute": "query-balloon", "id": "Pkd82nf3"}
2023-04-26 02:44:45: {"return": {"actual": 32208060416}, "id": "Pkd82nf3"}
2023-04-26 02:44:53: {"execute": "query-balloon", "id": "agkGOKzR"}
2023-04-26 02:44:53: {"return": {"actual": 32208060416}, "id": "agkGOKzR"}
2023-04-26 02:45:02: {"execute": "query-balloon", "id": "yEjAWK7X"}
2023-04-26 02:45:02: {"return": {"actual": 32208060416}, "id": "yEjAWK7X"}
2023-04-26 02:45:10: {"execute": "query-balloon", "id": "xihgQ1Wg"}
2023-04-26 02:45:10: {"return": {"actual": 32208060416}, "id": "xihgQ1Wg"}
2023-04-26 02:45:18: {"execute": "query-balloon", "id": "bBPNk1gV"}
2023-04-26 02:45:18: {"return": {"actual": 32208060416}, "id": "bBPNk1gV"}
```
Note:
The guest rebooted successfully and quickly.

Version-Release number of selected component (if applicable):
virtio-win-prewhql-0.1-236
kernel-5.14.0-302.el9.x86_64
qemu-kvm-8.0.0-1.el9.x86_64
seabios-bin-1.16.1-1.el9.noarch

How reproducible:
I tried on two hosts: 
dell-per750-14: 4/10 (all logs: http://virtqetools.lab.eng.pek2.redhat.com/kvm_autotest_job_log/?jobid=7787589)
dell-per750-13: 1/10

Steps to Reproduce:
1. boot up win10-64 guest with balloon device(q35 + seabios)
-m 30720 \
-device virtio-balloon-pci,id=balloon0,bus=pcie-root-port-4,addr=0x0 \

2. in guest, install balloon driver

3. Run evict test to get the minimum memory of guests.
2023-04-26 02:39:13: {"execute": "balloon", "arguments": {"value": 1048576}, "id": "DHbP7HBM"}
2023-04-26 02:39:13: {"return": {}, "id": "DHbP7HBM"}
....
2023-04-26 02:40:00: {"timestamp": {"seconds": 1682491172, "microseconds": 55184}, "event": "BALLOON_CHANGE", "data": {"actual": 2919235584}}
2023-04-26 02:40:00: {"execute": "query-balloon", "id": "FBLeXsgq"}
2023-04-26 02:40:00: {"return": {"actual": 2919235584}, "id": "FBLeXsgq"}

4. balloon memory back to the maximum one
2023-04-26 02:40:00: {"execute": "balloon", "arguments": {"value": 32212254720}, "id": "kfT5rtMt"} 
2023-04-26 02:40:38: {"execute": "query-balloon", "id": "RTgEDUyN"}
2023-04-26 02:40:38: {"return": {"actual": 32212254720}, "id": "RTgEDUyN"}

5. balloon memory to about half the size of the maximum one.
2023-04-26 02:40:45: {"execute": "balloon", "arguments": {"value": 18107858944}, "id": "lm8svpko"}
...
2023-04-26 02:40:56: {"execute": "query-balloon", "id": "SGIc3MC5"}
2023-04-26 02:40:56: {"return": {"actual": 18107858944}, "id": "SGIc3MC5"}

6. reboot the guest.
023-04-26 02:41:11: {"timestamp": {"seconds": 1682491271, "microseconds": 286694}, "event": "BALLOON_CHANGE", "data": {"actual": 32212254720}}
2023-04-26 02:41:43: {"timestamp": {"seconds": 1682491303, "microseconds": 607396}, "event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
2023-04-26 02:41:43: {"timestamp": {"seconds": 1682491303, "microseconds": 615880}, "event": "RESET", "data": {"guest": true, "reason": "guest-reset"}}
2023-04-26 02:43:45: {"timestamp": {"seconds": 1682491311, "microseconds": 66905}, "event": "BALLOON_CHANGE", "data": {"actual": 32210157568}}
2023-04-26 02:43:45: {"timestamp": {"seconds": 1682491312, "microseconds": 62397}, "event": "BALLOON_CHANGE", "data": {"actual": 32208060416}}
2023-04-26 02:43:45: {"execute": "query-balloon", "id": "11PU1Cgr"}
2023-04-26 02:43:45: {"return": {"actual": 32208060416}, "id": "11PU1Cgr"}
2023-04-26 02:43:55: {"execute": "query-balloon", "id": "FUSSA9YL"}
2023-04-26 02:43:55: {"return": {"actual": 32208060416}, "id": "FUSSA9YL"}
2023-04-26 02:44:03: {"execute": "query-balloon", "id": "VwuFkLts"}
2023-04-26 02:44:03: {"return": {"actual": 32208060416}, "id": "VwuFkLts"}
2023-04-26 02:44:12: {"execute": "query-balloon", "id": "TNPdjEFX"}
2023-04-26 02:44:12: {"return": {"actual": 32208060416}, "id": "TNPdjEFX"}

Actual results:
The memory value came back to the maximum one.

Expected results:
After rebooting os, the memory keeps the value like before.

Additional info: