RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 822092 - RFE: QMP notification of balloon memory changes
Summary: RFE: QMP notification of balloon memory changes
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Daniel Berrangé
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 822094
TreeView+ depends on / blocked
 
Reported: 2012-05-16 10:18 UTC by Daniel Berrangé
Modified: 2014-06-18 03:16 UTC (History)
11 users (show)

Fixed In Version: qemu-kvm-1.4.0-1.el7
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-13 12:19:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Daniel Berrangé 2012-05-16 10:18:18 UTC
Description of problem:
Currently whenever libvirt runs its virDomainGetXMLDesc or virDomainGetInfo APIs, it must issue a 'query-balloon' monitor call, to determine what level the guest has currently ballooned to. This is problematic because it slows down this APIs, which would otherwise be very fast and makes libvirt & the mgmt app susceptible to a "hung" QEMU monitor.  This has caused real world pain for RHEV-M, virt-manager and GNOME Boxes and thus it is well overdue time for us to fix this problem.

QEMU knows exactly when the guest changes its actual balloon level and can trivially emit a monitor event to notify mgmt application when this happens. This would avoid the need to poll 'query-balloon' at all, and thus avoids any potential for slow operation / hangs of the afore mentioned libvirt APIs.

Comment 1 Daniel Berrangé 2012-05-16 10:51:50 UTC
Here is an suitable impl

http://lists.nongnu.org/archive/html/qemu-devel/2012-05/msg02215.html

Comment 2 Daniel Berrangé 2012-05-16 13:16:01 UTC
It would also need the 'query-events' command to let libvirt detect whether the balloon event is present

https://lists.gnu.org/archive/html/qemu-devel/2012-05/msg02255.html

Comment 3 Luiz Capitulino 2012-05-18 13:35:32 UTC
Daniel, are you going to keep pursuing this upstream? If you will, then I think this bz has to be re-assigned to you, because a backport won't be needed (ie. this will be automatically in RHEL7.0 if merged before QEMU 1.2).

Comment 4 Daniel Berrangé 2012-05-18 13:44:41 UTC
Yes, I aim to continue posting updates upstream.  Depending on the final result, I may ultimately request a backport for RHEL-6, but I'll create a separate BZ for that when required.

Comment 5 Luiz Capitulino 2012-05-18 13:54:33 UTC
Ok, re-assigning to you then. If this misses the 1.2 deadline for whatever reason, then you can re-assign it back to me for the RHEL7.0 backport work.

Comment 6 Daniel Berrangé 2012-05-21 19:33:13 UTC
V2 of the patches, with rate limiting added

http://lists.nongnu.org/archive/html/qemu-devel/2012-05/msg02833.html

Comment 7 Daniel Berrangé 2012-06-15 16:44:02 UTC
All 3 patches now accepted upstream in Luiz' QMP tree

commit 4860853d60ecea44b65e9cdefce980de3a641dce
Author: Daniel P. Berrange <berrange>
Date:   Mon May 21 17:59:51 2012 +0100

    Add 'query-events' command to QMP to query async events


commit 1bcf107bbae883540f45e11e9fdc912a496c3094
Author: Daniel P. Berrange <berrange>
Date:   Wed May 16 11:01:58 2012 +0100

    Add event notification for guest balloon changes


commit d218a99b8d590224229969594e3411e940a77a7b
Author: Daniel P. Berrange <berrange>
Date:   Mon May 21 17:27:20 2012 +0100

    Add rate limiting of RTC_CHANGE, BALLOON_CHANGE & WATCHDOG events

Comment 8 Miroslav Rezanina 2013-04-23 12:48:40 UTC
Fixed in qemu-kvm-1.4.0-1.el7

Comment 10 langfang 2014-01-26 06:29:08 UTC
Test this bug on latest version:
Host:
# uname -r
3.10.0-79.el7.x86_64
# rpm -q qemu-kvm
qemu-kvm-1.5.3-41.el7.x86_64

steps:
1.boot guest with 
 ...-device virtio-balloon-pci,bus=pci.0,id=balloon0

2.QMP
# telnet 10.66.83.192 4444
{"execute":"query-balloon"}
{"return": {"actual": 2147483648}}
{"execute":"balloon","arguments":{"value":900000}}
{"return": {}}
{"timestamp": {"seconds": 1390717029, "microseconds": 460666}, "event": "BALLOON_CHANGE", "data": {"actual": 2146435072}}
{"timestamp": {"seconds": 1390717030, "microseconds": 460216}, "event": "BALLOON_CHANGE", "data": {"actual": 455081984}}
{"timestamp": {"seconds": 1390717030, "microseconds": 752577}, "event": "BALLOON_CHANGE", "data": {"actual": 300941312}}

3.{"execute":"query-events"}

Results:
After step 2, when change balloon size ,added the balloon events
After step 3,will see the balloon event:
...{"name": "BALLOON_CHANGE"},...{"name": "RTC_CHANGE"}..{"name": "WATCHDOG"}...

Test on old version:
Host:
# uname -r
3.7.0-0.36.el7.x86_64
# rpm -q qemu-kvm
qemu-kvm-1.3.0-3.el7.x86_64

i can get the same results.

Addtional test:

Also test change balloon size too small and big on latest version, not hit any problem.

Hi, Daniel

   According to above test , could we can verify pass this bug ?

tanks

Comment 11 Daniel Berrangé 2014-01-27 10:03:22 UTC
When the balloon target is set, the guest will slowly adjust to meat the target. This will result in a series of BALLOON_CHANGE events. You should wait for the last event to arrive, and then compare the value with the guest RAM shown in /proc/meminfo inside the guest. They should be pretty much the same, if not identical.

Comment 12 langfang 2014-01-29 11:56:32 UTC
(In reply to Daniel Berrange from comment #11)
> When the balloon target is set, the guest will slowly adjust to meat the
> target. This will result in a series of BALLOON_CHANGE events. You should
> wait for the last event to arrive, and then compare the value with the guest
> RAM shown in /proc/meminfo inside the guest. They should be pretty much the
> same, if not identical.


yes ,test on latest version

steps:
1.Boot guest with 
/usr/libexec/qemu-kvm -m 4G ....-device virtio-balloon-pci,bus=pci.0,id=balloon0

2.Change balloon size 
# telnet 10.66.83.192 4445
Trying 10.66.83.192...
Connected to 10.66.83.192.
Escape character is '^]'.
{"QMP": {"version": {"qemu": {"micro": 3, "minor": 5, "major": 1}, "package": " (qemu-kvm-1.5.3-41.el7)"}, "capabilities": []}}
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"query-balloon"}                      
{"return": {"actual": 4294967296}}
{"execute":"balloon","arguments":{"value":1073741824}}
{"return": {}}
{"timestamp": {"seconds": 1390995440, "microseconds": 402484}, "event": "BALLOON_CHANGE", "data": {"actual": 4293918720}}
{"timestamp": {"seconds": 1390995441, "microseconds": 402074}, "event": "BALLOON_CHANGE", "data": {"actual": 2600468480}}
{"timestamp": {"seconds": 1390995442, "microseconds": 279347}, "event": "BALLOON_CHANGE", "data": {"actual": 1073741824}}
{"execute":"query-balloon"}
{"return": {"actual": 1073741824}}

3.In guest
# cat /proc/meminfo
MemTotal:         770748 kB
MemFree:          503988 kB
Buffers:            1468 kB
...

4.extend the balloon size
{"execute":"balloon","arguments":{"value":  2147483648}}
{"timestamp": {"seconds": 1390995917, "microseconds": 311927}, "event": "BALLOON_CHANGE", "data": {"actual": 806354944}}
{"timestamp": {"seconds": 1390995917, "microseconds": 837996}, "event": "BALLOON_CHANGE", "data": {"actual": 2147483648}}

4.In guest
# cat /proc/meminfo
MemTotal:        1819324 kB
MemFree:         1552348 kB
Buffers:            1468 kB
Cached:            98656 kB
SwapCached:            0 kB
Active:            97880 kB
....


According to above test ,when balloon size change,will show the balloon events ,and the mem size in guest (cat /proc/meminfo) will change too.


Hi,Daniel
    Could we can verify this bug now?

Comment 13 Daniel Berrangé 2014-01-29 12:04:07 UTC
Looks reasonable to me.

Comment 15 Ludek Smid 2014-06-13 12:19:28 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.


Note You need to log in before you can comment on or make changes to this bug.