Bug 1467759 - send-key can not send the string containing the same character to the guest correctly
send-key can not send the string containing the same character to the guest c...
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev (Show other bugs)
7.4
All Linux
unspecified Severity unspecified
: rc
: ---
Assigned To: Gerd Hoffmann
Chao Yang
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-04 22:51 EDT by yafu
Modified: 2017-07-10 03:52 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-07-10 03:52:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description yafu 2017-07-04 22:51:02 EDT
Description of problem:
send-key can not send the string containing the same character to the guest correctly

Version-Release number of selected component (if applicable):
libvirt-3.2.0-14.el7.x86_64
qemu-kvm-rhev-2.9.0-14.el7.x86_64

How reproducible:
100%

Steps to reproduce:
1.Start a guest with virtio keyboard:
#virsh dumpxml rhel7.3
...
 <input type='keyboard' bus='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </input>
...

2.Login in the guest and run a terminal in the guest;

3.Send string "touch abc\n" to the guest:
virsh send-key rhel7.3 --codeset linux 20 24 22 46 35 57 30 48 46 28

4.Check the terminal in the guest:
#touch ab
Check the file created:
# ll ab
-rw-r--r--. 1 root root 0 Jul  3 17:17 ab

Actual results:
Only "touch ab\n" was sent to the guest.The second 'c' in the string was not sent to thet guest, a file named 'ab' created in the guest.

Expected results:
Should send 'touch abc\n" correctly to the guest and will create a file named 'abc' in the guest.

Additional info:
1.With the usb keyboard, it will send "touch a" to the guest. And with the ps2 keyboard, the issue can not be reproduced everytime.
2.Check the log in the libvirtd.log:
2017-07-03 09:36:08.171+0000: 18513: debug : qemuMonitorSendKey:3403 : holdtime=0, nkeycodes=10
2017-07-03 09:36:08.171+0000: 18513: debug : qemuMonitorSendKey:3405 : mon:0x7f97000830d0 vm:0x7f96a42acb00 json:1 fd:27
2017-07-03 09:36:08.171+0000: 18513: debug : virJSONValueToString:1904 : result={"execute":"send-key","arguments":{"keys":[{"type":"number","data":20},{"type":"number","data":24},{"type":"number","data":22},{"type":"number","data":46},{"type":"number","data":35},{"type":"number","data":57},{"type":"number","data":30},{"type":"number","data":48},{"type":"number","data":46},{"type":"number","data":28}]},"id":"libvirt-35"}
2017-07-03 09:36:08.171+0000: 18513: debug : qemuMonitorJSONCommandWithFd:298 : Send command '{"execute":"send-key","arguments":{"keys":[{"type":"number","data":20},{"type":"number","data":24},{"type":"number","data":22},{"type":"number","data":46},{"type":"number","data":35},{"type":"number","data":57},{"type":"number","data":30},{"type":"number","data":48},{"type":"number","data":46},{"type":"number","data":28}]},"id":"libvirt-35"}' for write with FD -1
2017-07-03 09:36:08.171+0000: 18513: info : qemuMonitorSend:1034 : QEMU_MONITOR_SEND_MSG: mon=0x7f97000830d0 msg={"execute":"send-key","arguments":{"keys":[{"type":"number","data":20},{"type":"number","data":24},{"type":"number","data":22},{"type":"number","data":46},{"type":"number","data":35},{"type":"number","data":57},{"type":"number","data":30},{"type":"number","data":48},{"type":"number","data":46},{"type":"number","data":28}]},"id":"libvirt-35"}
2017-07-03 09:36:08.171+0000: 18512: info : qemuMonitorIOWrite:536 : QEMU_MONITOR_IO_WRITE: mon=0x7f97000830d0 buf={"execute":"send-key","arguments":{"keys":[{"type":"number","data":20},{"type":"number","data":24},{"type":"number","data":22},{"type":"number","data":46},{"type":"number","data":35},{"type":"number","data":57},{"type":"number","data":30},{"type":"number","data":48},{"type":"number","data":46},{"type":"number","data":28}]},"id":"libvirt-35"}
2017-07-03 09:36:08.173+0000: 18513: debug : virThreadJobClear:121 : Thread 18513 (virNetServerHandleJob) finished job remoteDispatchDomainSendKey with ret=0
Comment 1 Gerd Hoffmann 2017-07-10 03:52:41 EDT
> 3.Send string "touch abc\n" to the guest:
> virsh send-key rhel7.3 --codeset linux 20 24 22 46 35 57 30 48 46 28

send-key doesn't send strings.  It sends key combinations, i.e. all specified keys are pressed at the same time, for things like "Ctrl-C".  If you want sent strings you need a sequence of send-key calls.

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