Bug 1020102

Summary: qmp don't give any message when specify balloon size more than memory via qmp
Product: Red Hat Enterprise Linux 7 Reporter: Jun Li <juli>
Component: qemu-kvmAssignee: Luiz Capitulino <lcapitulino>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: acathrow, hhuang, juzhang, michen, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-17 18:43:42 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 Jun Li 2013-10-17 02:27:59 UTC
Description of problem:
When specify balloon size more than memory, qmp do not return any reasonable hint or the actual size of balloon.
But on Rhel6, qmp will return the actual size. Please ref https://bugzilla.redhat.com/show_bug.cgi?id=927336#c15 .
I also test specify balloon size smaller than memory, qmp will return the actual size. Please see "Additional info:".

Version-Release number of selected component (if applicable):
3.10.0-34.el7.x86_64
qemu-kvm-rhev-1.5.3-9.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Boot a guest.
# /usr/libexec/qemu-kvm -enable-kvm -m 5G -smp 2,sockets=2,cores=2,threads=1 -drive file=/mnt/rhel7base.qcow2_v3,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,werror=stop,rerror=stop,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,id=hostnet0,vhost=on,script=/etc/ovs-ifup -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:1a:4a:42:0b:38,bus=pci.0 -spice port=8000,disable-ticketing -k en-us -vga qxl -global qxl-vga.vram_size=67108864 -monitor stdio -device virtio-balloon-pci,id=ballooning -qmp tcp:0:4445,server,nowait

2.specify balloon size more than memory via qmp(boot with  5G goes down to 7G).
{"execute":"balloon","arguments":{"value":7516192768},"id":"libvirt-9"}

3.Check the return of qmp.

Actual results:
{"execute":"balloon","arguments":{"value":7516192768},"id":"libvirt-9"}
{"return": {}, "id": "libvirt-9"}

Expected results:
When specify balloon size more than memory, qmp will return a reasonable hint or the actual size of balloon.

Additional info:
I also test the followings scenarios.
Senario 1:boot with  5G goes down to 1G:
...
{"execute":"balloon","arguments":{"value":1073741824},"id":"libvirt-9"}
{"return": {}, "id": "libvirt-9"}
{"timestamp": {"seconds": 1381975120, "microseconds": 312924}, "event": "BALLOON_CHANGE", "data": {"actual": 5367660544}}
{"timestamp": {"seconds": 1381975121, "microseconds": 313064}, "event": "BALLOON_CHANGE", "data": {"actual": 1200619520}}
{"timestamp": {"seconds": 1381975121, "microseconds": 342414}, "event": "BALLOON_CHANGE", "data": {"actual": 1073741824}}

Senario 2:boot with  5G goes down to 0G
...
{"execute":"balloon","arguments":{"value":0},"id":"libvirt-9"}
{"id": "libvirt-9", "error": {"class": "GenericError", "desc": "Parameter 'target' expects a size"}}

Comment 2 Luiz Capitulino 2013-10-17 18:43:42 UTC
(In reply to Jun Li from comment #0)
> Description of problem:
> When specify balloon size more than memory, qmp do not return any reasonable
> hint or the actual size of balloon.

By "more than memory" do you mean specifying a balloon value which is greater than the memory assigned to the guest in the command-line? If this is what you meant, then we have two cases. Supposed you passed "-m 5G" to QEMU:

1. If the guest's balloon is empty (eg. QEMU just booted) and you ask the guest to grow to 7G, nothing will happen. This is so because QEMU will automatically limit the operation to 5G which is what the guest currently has. I agree an error message there would be better, but that's how the balloon command has always worked and changing that would break QMP clients

2. If the guest balloon is already inflated (say, the guest currently has 2G) and you ask the guest to grow to 7G, then the guest will grow only to 5G. Again, I agree a error message would be better but we'd need to add a new command for this, which is overkill

> But on Rhel6, qmp will return the actual size. Please ref
> https://bugzilla.redhat.com/show_bug.cgi?id=927336#c15 .

Are you referring to scenario 2? I believe there's a typo there, I think the reporter really wanted to say "7G goes down to 5G" (and not "5G goes down to 7G" as this doesn't even make sense) as we can see on the test results.

> I also test specify balloon size smaller than memory, qmp will return the
> actual size. Please see "Additional info:".

Yes, that's correct.

> Steps to Reproduce:
> 1.Boot a guest.
> # /usr/libexec/qemu-kvm -enable-kvm -m 5G -smp 2,sockets=2,cores=2,threads=1
> -drive
> file=/mnt/rhel7base.qcow2_v3,if=none,id=drive-virtio-disk0,format=qcow2,
> cache=none,werror=stop,rerror=stop,aio=native -device
> virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,
> id=virtio-disk0,bootindex=1 -netdev
> tap,id=hostnet0,vhost=on,script=/etc/ovs-ifup -device
> virtio-net-pci,netdev=hostnet0,id=net0,mac=00:1a:4a:42:0b:38,bus=pci.0
> -spice port=8000,disable-ticketing -k en-us -vga qxl -global
> qxl-vga.vram_size=67108864 -monitor stdio -device
> virtio-balloon-pci,id=ballooning -qmp tcp:0:4445,server,nowait
> 
> 2.specify balloon size more than memory via qmp(boot with  5G goes down to
> 7G).
> {"execute":"balloon","arguments":{"value":7516192768},"id":"libvirt-9"}

Works as expected.

> 
> 3.Check the return of qmp.
> 
> Actual results:
> {"execute":"balloon","arguments":{"value":7516192768},"id":"libvirt-9"}
> {"return": {}, "id": "libvirt-9"}
> 
> Expected results:
> When specify balloon size more than memory, qmp will return a reasonable
> hint or the actual size of balloon.
> 
> Additional info:
> I also test the followings scenarios.
> Senario 1:boot with  5G goes down to 1G:
> ...
> {"execute":"balloon","arguments":{"value":1073741824},"id":"libvirt-9"}
> {"return": {}, "id": "libvirt-9"}
> {"timestamp": {"seconds": 1381975120, "microseconds": 312924}, "event":
> "BALLOON_CHANGE", "data": {"actual": 5367660544}}
> {"timestamp": {"seconds": 1381975121, "microseconds": 313064}, "event":
> "BALLOON_CHANGE", "data": {"actual": 1200619520}}
> {"timestamp": {"seconds": 1381975121, "microseconds": 342414}, "event":
> "BALLOON_CHANGE", "data": {"actual": 1073741824}}

Works as expected.

> Senario 2:boot with  5G goes down to 0G
> ...
> {"execute":"balloon","arguments":{"value":0},"id":"libvirt-9"}
> {"id": "libvirt-9", "error": {"class": "GenericError", "desc": "Parameter
> 'target' expects a size"}}

QEMU ignores value=0, but QMP and HMP return the error above, because it expects a size, which is defined as > 0. I think we should allow the guest to go to 0 (we allow 1MB, why a special test for 0?) but this is a very minor problem which doesn't seem to have any practical implications, so let's leave it alone.