Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1145028

Summary: send-key does not crash windows guest even when it should
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: qemu-kvm-rhevAssignee: jason wang <jasowang>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: armbru, dyuan, hhuang, huding, jasowang, juzhang, lcapitulino, lhuang, mazhang, mkletzan, mrezanin, mzhan, virt-bugs, virt-maint, xfu, yafu, yvugenfi
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1161184 (view as bug list) Environment:
Last Closed: 2016-08-09 02:28:04 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: 1161184    
Attachments:
Description Flags
RHEL7 debug log
none
RHEL6 sendkey debug log none

Description Luyao Huang 2014-09-22 08:53:00 UTC
Description of problem:
Cannot use sendkey crash a windows guest. 

Version-Release number of selected component (if applicable):
libvirt-1.2.8-3.el7.x86_64
qemu-kvm-rhev-2.1.0-4.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
  1). Start a Windows guest
# virsh start win7
Domain win7 started

  2). Add the following new registory key at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters  on Windows guest.

  3). Restart the Windows guest.

  4). After guest start fully , test linux codeset

    #virsh send-key win2008 --codeset linux 0x61 0x46 0x46

Actual results:
guest won't crash by the command ,but if i hold right_ctrl and scroll_lock on my keyboard,guest can crash normal.

Expected results:
Send key work well

Additional info:

I have tried to reproduce this issue in RHEL6 use the same guest and found guest can crash successful in RHEL6.And found some information from debug log:

RHEL7:

2014-09-22 07:19:34.697+0000: 9157: debug : qemuMonitorJSONCommandWithFd:286 : Send command '{"execute":"send-key","arguments":{"keys":[{"type":"number","data":157},{"type":"number","data":70},{"type":"number","data":70}]},"id":"libvirt-10"}' for write with FD -1

RHEL6:

2014-09-22 08:00:22.354+0000: 29482: debug : qemuMonitorJSONCommandWithFd:269 : Send command '{"execute":"human-monitor-command","arguments":{"command-line":"sendkey 0x9D-0x46-0x46"},"id":"libvirt-7"}' for write with FD -1

Comment 1 Luyao Huang 2014-09-22 08:54:01 UTC
Created attachment 939925 [details]
RHEL7 debug log

Comment 2 Luyao Huang 2014-09-22 08:55:25 UTC
Created attachment 939926 [details]
RHEL6 sendkey debug log

Comment 6 Luiz Capitulino 2014-09-22 17:02:30 UTC
What does "crash" mean in this context? Did virsh stop working? Did Windows get a blue screen? Did QEMU crash?

You said you tried with RHEL6, what are the QEMU and libvirt versions?

Have you tried to reproduce running QEMU directly (ie. w/o libvirt)?

PS: Yes, I've noticed libvirt has a fd=-1 for the monitor, which could be the cause. But you this report doesn't contain enough information to determine what the problem is.

Comment 7 Martin Kletzander 2014-09-23 08:53:45 UTC
(In reply to Luiz Capitulino from comment #6)
Just from a libvirt's POV, that fd=-1 doesn't mean anything to qemu.

Comment 8 Luyao Huang 2014-09-23 14:25:17 UTC
(In reply to Luiz Capitulino from comment #6)
> What does "crash" mean in this context? Did virsh stop working? Did Windows
> get a blue screen? Did QEMU crash?
> 
> You said you tried with RHEL6, what are the QEMU and libvirt versions?
> 
> Have you tried to reproduce running QEMU directly (ie. w/o libvirt)?
> 
> PS: Yes, I've noticed libvirt has a fd=-1 for the monitor, which could be
> the cause. But you this report doesn't contain enough information to
> determine what the problem is.

1.The "crash" mean Windows get a blue screen  

2.the RHEL6 version which i tried:
qemu-kvm-rhev-0.12.1.2-2.446
libvirt-0.10.2-46.el6

Also i have tried to use virsh qemu-monitor-command r6 --hmp "sendkey 0x9D-0x46-0x46" to crash the guest(windows get a blue screen) in RHEL7 ,but it didn't work.

3.Sorry,I haven't tried that and i will try to use QEMU monitor command tmr.


Thanks,
Luyao Huang

Comment 9 Luiz Capitulino 2014-09-23 14:43:11 UTC
OK, so I guess there are two possible reasons: it's either a bug in Windows itself or an emulation problem in QEMU/KVM.

Yan, can you debug this bug please? If it turns out to be something outside the scope of your work, you can re-assign it back to me. But I need help to at least debug this down.

Comment 10 Martin Kletzander 2014-09-24 11:14:42 UTC
I think there was a huge misunderstanding here.  What Luyao is trying to say is that when you have the right setting in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters, Windows *are supposed* to crash when you press Ctrl+(2*ScrollLock).  That is a "feature" there.  And what he tried is that he did that on RHEL6 and BSOD appeared as was expected, but on RHEL7 it *didn't* crash and that is the problem.

Libvirt switched from HMP to QMP between RHEL6 and RHEL7 because of newer qemu.  I hope those commands behave the same way.  The only thing that may cause the problem is that, for example, the hmp command does something like:

hold down Control
press ScrollLock
press ScrollLock

whether the qmp one does:

press Control
press ScrollLock
press ScrollLock

Comment 12 Martin Kletzander 2014-09-25 05:27:08 UTC
Should this bug stay assigned to Yan or be assigned back to you after the explanation in comment #10 ?

Comment 13 Luiz Capitulino 2014-09-25 12:55:37 UTC
Thanks for your explanation. I really got it completely wrong.

When you mention this difference between HMP and QMP, where HMP "holds down Control" while QMP just presses it, does it happen in libvirt or QEMU? How do you know QEMU does it?

I'm going to re-assign this BZ to Amos, as he re-wrote the send-key command for newer QMP.

Comment 14 Martin Kletzander 2014-09-25 16:32:48 UTC
(In reply to Luiz Capitulino from comment #13)
I don't know whether that's the problem, that's just my guess.  But if that's the case it's in QEMU.

Comment 15 Amos Kong 2014-09-26 08:22:25 UTC
Actually there are two problem here.

1) I sensitively identified the first issue when I saw comment #1, the qcodes of last keys are same. I touched this issue in the past.

2) In verifying my thought, I found a regression [1], so I filed a new bug.

I will post patch to fix those two issues.

[1] Bug 1146801 - sendkey: releasing order of combined keys was wrongly converse

Comment 19 Amos Kong 2014-10-29 07:17:52 UTC
As discussed in http://marc.info/?l=qemu-devel&m=141456679226178&w=2, my patch isn't accepted by upstream, they prefer to use Marcelo's new QMP command to emit the event, then we can hold on Ctrl key.

Marcelo's patch v4: https://patchwork.ozlabs.org/patch/395116/

Comment 20 Amos Kong 2014-10-29 07:55:45 UTC
Marcelo's patch was applied by upstream, then we can crash Windows by:

1. hold on right ctrl
{ "execute": "input-send-event", "arguments": { "console": 0, "events": [ { "type": "key", "data" : { "down": true, "key": {"type": "qcode", "data": "ctrl_r" } } }] } }

2. press the SCROLL LOCK key twice
{ "execute": "send-key", "arguments": { "keys": [{"type": "qcode", "data": "scroll_lock"} ] } }

{ "execute": "send-key", "arguments": { "keys": [{"type": "qcode", "data": "scroll_lock"} ] } }

3. release right ctrl

{ "execute": "input-send-event", "arguments": { "console": 0, "events": [ { "type": "key", "data" : { "down": false, "key": {"type": "qcode", "data": "ctrl_r" } } } ] } }

Comment 22 Miroslav Rezanina 2014-11-04 09:35:37 UTC
Fix included in qemu-kvm-rhev-2.1.2-6.el7

Comment 27 Markus Armbruster 2014-11-27 07:31:45 UTC
During upstream review of a documentation patch triggered by downstream review, doubts on the API came up.  Upstream marked the command experimental by prefixing it with x- for the 2.2 release, to give us time to get it right.  We want to wait for the dust to settle upstream, so punt to 7.2.

Comment 32 Amos Kong 2015-05-22 00:16:56 UTC
Status of this bug:

need to backport patch :

[RHEL-7.1 qemu-kvm-rhev PATCH 2/2] add input-send-event command

Comment 36 jason wang 2016-07-01 05:43:51 UTC
Can QE reproduce this on recent qemu-kvm-rhev?

Comment 37 Luyao Huang 2016-07-12 06:27:59 UTC
(In reply to jason wang from comment #36)
> Can QE reproduce this on recent qemu-kvm-rhev?

No, i cannot reproduce this problem with steps in comment 0

Comment 38 jason wang 2016-08-09 02:28:04 UTC
(In reply to Luyao Huang from comment #37)
> (In reply to jason wang from comment #36)
> > Can QE reproduce this on recent qemu-kvm-rhev?
> 
> No, i cannot reproduce this problem with steps in comment 0

Closed according to this.