Bug 612816 - QMP: query commands may return negative values
Summary: QMP: query commands may return negative values
Status: CLOSED DUPLICATE of bug 706887
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.0
Hardware: All
OS: Linux
Target Milestone: beta
: ---
Assignee: Luiz Capitulino
QA Contact: Virtualization Bugs
: 1024215 1039804 1151305 (view as bug list)
Depends On:
Blocks: 559201 580953 1153905
TreeView+ depends on / blocked
Reported: 2010-07-09 06:34 UTC by YangFeng
Modified: 2015-04-20 00:26 UTC (History)
11 users (show)

Clone Of:
Last Closed: 2011-05-27 15:20:30 UTC

Attachments (Terms of Use)

Description YangFeng 2010-07-09 06:34:33 UTC
Description of problem:
Sometimes query-cpus return negative value for pc item.
output for {'execute': 'query-cpus', 'arguments': {}, 'id': '0x4wK9Eg'} is:
{u'current': True, u'pc': -2013119777, u'halted': False, u'CPU': 0, u'thread_id': 10153}, {u'current': False, u'pc': 4645386, u'halted': False, u'CPU': 1, u'thread_id': 10154}

output for info cpus:
* CPU #0: pc=0xffffffff8006b36f (halted) thread_id=10153
  CPU #1: pc=0x000000000046e20a thread_id=10154

Version-Release number of selected component (if applicable):
uname -a in host:
Linux dhcp-65-129.nay.redhat.com.englab.nay.redhat.com 2.6.32-44.el6.x86_64 #1 SMP Wed Jul 7 15:47:50 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

rpm -qa|grep qemu in host:

How reproducible:

Steps to Reproduce:
1. Start a VM with monitor and qmp enable on console 1.
'qemu-kvm -name 'vm1' -monitor /dev/tty -qmp tcp:0:7001,server,nowait -drive file='/usr/RHEL-Server-5.5-64-virtio.qcow2',if=none,id=drive-virtio-disk1,media=disk,cache=none,boot=on,format=qcow2 -device virtio-blk-pci,drive=drive-virtio-disk1,id=virtio-disk1 -net nic,vlan=0,netdev=Ykio,model=e1000,macaddr='02:8F:50:B4:fe:18' -netdev tap,id=Ykio,ifname=e1000_0_8000,script=/usr/qemu-ifup-switch,downscript=no -m 2048 -smp 2 -vnc :0 -spice port=8000,disable-ticketing -rtc base=utc,clock=host -M rhel6.0.0 -usbdevice tablet -cpu qemu64,+sse2 -no-kvm-pit-reinjection'
2. Telnet to 7001 by 'telnet 7001' on console 2.
3. Run '{"execute": "qmp_capabilities"}' on console 2.
4. Run '{'execute': 'query-cpus', 'arguments': {}, 'id': '0x4wK9Eg'}' on console 2.
5. Run 'info cpus' on console 1.
Actual results:
'query-cpus' return negative value for pc item.

Expected results:
'query-cpus' should not return negative value for pc item.

Additional info:
Output in step 4:
{"return": [{"current": true, "CPU": 0, "pc": -2146991538, "halted": false, "thread_id": 13108}, {"current": false, "CPU": 1, "pc": -2147044497, "halted": true, "thread_id": 13109}], "id": "0x4wK9Eg"}

Output in step 5:
* CPU #0: pc=0xffffffff80079413 thread_id=13108 
  CPU #1: pc=0xffffffff8006b36f (halted) thread_id=13109

Comment 4 RHEL Product and Program Management 2010-07-15 14:01:18 UTC
This issue has been proposed when we are only considering blocker
issues in the current Red Hat Enterprise Linux release. It has
been denied for the current Red Hat Enterprise Linux release.

** If you would still like this issue considered for the current
release, ask your support representative to file as a blocker on
your behalf. Otherwise ask that it be considered for the next
Red Hat Enterprise Linux release. **

Comment 5 Luiz Capitulino 2010-07-15 14:47:40 UTC
I appreciate the reporter's attention to detail, but this is not an issue. At least not from qemu's side.

What happens here is that, internally qemu stores values such as the "pc" key as uint64_t (unsigned 64 bits) but our json parser only handles int64_t (signed 64 bits). So, there's a casting going on from uint64_t to int64_t and we put a negative value on the wire.

This is not an issue as long as libvirt does the cast back correctly.

Also note that this is not only about the "pc" key, but most 'big' integers we send to clients, that's, this also applies for query-balloon, query-blockstats and others.

Now, we should address this someway for upstream, we have two options:

1. Just document the behavior

2. Fix our parser to handle uint64_t correctly

According to Anthony the problem is the JSON standard, not the parser itself. But I wonder what other JSON implementations do..

Moving to rhel6.1, anyway.

Comment 8 Luiz Capitulino 2011-05-27 15:20:30 UTC
I'm marking this a duplicate of a newer bug (706887) because it contains more up to date information.

*** This bug has been marked as a duplicate of bug 706887 ***

Comment 9 Laszlo Ersek 2013-12-17 17:14:05 UTC
*** Bug 1024215 has been marked as a duplicate of this bug. ***

Comment 10 Laszlo Ersek 2013-12-17 17:30:49 UTC
*** Bug 1039804 has been marked as a duplicate of this bug. ***

Comment 11 Luiz Capitulino 2014-10-21 16:08:29 UTC
*** Bug 1151305 has been marked as a duplicate of this bug. ***

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