Bug 1292019

Summary: Changing CPU's current status failed via qmp command
Product: Red Hat Enterprise Linux 7 Reporter: Min Deng <mdeng>
Component: qemu-kvm-rhevAssignee: Markus Armbruster <armbru>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dgibson, hannsj_uhl, huding, juzhang, knoel, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-21 17:10:49 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:
Bug Depends On:    
Bug Blocks: 1308609, 1359843    

Description Min Deng 2015-12-16 08:59:11 UTC
Description of problem:
Changing CPU's current status failed via qmp command  

Version-Release number of selected component (if applicable):
kernel-3.10.0-334.el7.ppc64le
qemu-kvm-rhev-2.3.0-31.el7.ppc64le

How reproducible:
3 times

Steps to Reproduce:
1.boot up guest with the following cli
  /usr/libexec/qemu-kvm -name virt-tests-vm1 -sandbox off -machine pseries -nodefaults -vga std -chardev socket,id=hmp_id_humanmonitor1,path=/tmp/monitor-humanmonitor1-20151216-023305-yiSWzYp2,server,nowait -mon chardev=hmp_id_humanmonitor1,mode=readline -chardev socket,id=qmp_id_qmp1,path=/tmp/monitor-qmp1-20151216-023305-yiSWzYp2,server,nowait -mon chardev=qmp_id_qmp1,mode=control -chardev socket,id=hmp_id_catch_monitor,path=/tmp/monitor-catch_monitor-20151216-023305-yiSWzYp2,server,nowait -mon chardev=hmp_id_catch_monitor,mode=readline -chardev socket,id=serial_id_serial0,path=/tmp/serial-serial0-20151216-023305-yiSWzYp2,server,nowait -device spapr-vty,reg=0x30000000,chardev=serial_id_serial0 -device pci-ohci,id=usb1,bus=pci.0,addr=03 -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pci.0,addr=04,disable-legacy=off,disable-modern=on -drive id=drive_image1,if=none,cache=none,snapshot=off,aio=native,format=qcow2,file=/home/auto/autotest/client/tests/virt/shared/data/images/RHEL-Server-7.2-ppc64le-virtio-scsi.qcow2 -device scsi-hd,id=image1,drive=drive_image1 -m 4096 -smp 2,maxcpus=2,cores=1,threads=1,sockets=2 -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 -vnc :0 -rtc base=utc,clock=host -boot order=cdn,once=c,menu=off,strict=off -enable-kvm -monitor stdio

2.connect to guest via qmp

a.{"execute":"qmp_capabilities"}
{"return": {}}

b.{"execute":"query-cpus"}
 {"return": [{"current": true, "CPU": 0, "nip": -4611686018426779980, "halted": false, "thread_id": 7982}, {"current": false, "CPU": 1, "nip": -4611686018426779980, "halted": false, "thread_id": 7983}]}

c.{'execute': 'cpu', 'arguments': {'index': 1}, 'id': 'r8nM0rzA'}
{"return": {}, "id": "r8nM0rzA"}

d.{"execute":"query-cpus"}
{"return": [{"current": true, "CPU": 0, "nip": -4611686018426779980, "halted": false, "thread_id": 7982}, {"current": false, "CPU": 1, "nip": -4611686018426779980, "halted": false, "thread_id": 7983}]}

Actual results:
The current status of #1 cpu should be true but still false and #0 cpu should become to false correspondingly.

Expected results:
After step c,the #1 cpu current status could become True and #0 cpu could become to false

Additional info:
It isn't reproduced via HMP
(qemu) cpu 1
(qemu) info cpus
  CPU #0: nip=0xc0000000000946b4 thread_id=7982
* CPU #1: nip=0xc0000000000946b4 thread_id=7983
(qemu) cpu 2
invalid CPU index
(qemu) cpu 0
(qemu) info cpus
* CPU #0: nip=0xc0000000000946b4 thread_id=7982
  CPU #1: nip=0xc0000000000946b4 thread_id=7983
(qemu)

Comment 2 Markus Armbruster 2016-07-21 17:10:49 UTC
"Current CPU" is monitor-local, i.e. if you have multiple monitors,
each has its own current CPU.  Only HMP monitors have a current CPU.
QMP command "cpu" actually does nothing, and command "query-cpus"
always shows CPU #0 as current.  Actually an implementation artifact
that shouldn't be relied on; member "current" exists only for backward
compatibility, and should be ignored.  This mess is due to some
confused QMP development history, and can't be changed now.

Closing NOTABUG.  Please don't hesitate to ask if you have further
questions.

See also bug 1272417 - qmp didnot distinguish the current work cpu
when change the cpu in hmp.