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 1211970

Summary: smart card emulation doesn't work with USB3 (nec-xhci) controller
Product: Red Hat Enterprise Linux 7 Reporter: David Jaša <djasa>
Component: qemu-kvm-rhevAssignee: Gerd Hoffmann <kraxel>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: areis, djasa, hhuang, huding, juzhang, kraxel, michen, pzhang, rbalakri, sharpwiner, spice-qe-bugs, virt-maint, xfu, xuzhang, yama, yduan
Target Milestone: rc   
Target Release: 7.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.3.0-15.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1243731 (view as bug list) Environment:
Last Closed: 2015-12-04 16:37:57 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: 1243731    
Attachments:
Description Flags
log of logging into the system using smartcard, log is full of EREMOTEIO messages none

Description David Jaša 2015-04-15 10:29:50 UTC
Description of problem:
smart card emulation doesn't work with USB3 (nec-xhci) controller

Version-Release number of selected component (if applicable):
qemu-kvm-1.5.3-86.el7_1.1.x86_64

How reproducible:
always

Steps to Reproduce:
1. set up a VM with smartcard controller and USB3 controller:
    <controller type='usb' index='0' model='nec-xhci'/>
    <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>
2. connect to the VM (virt-viewer $VM_NAME --spice-smartcard)
3.

Actual results:
smartcard emulation doesn't work. Examples of what is printed to qemu log with both QEMU_CCID_PASSTHRU_DEBUG and QEMU_CCID_DEBUG set to 4 is below

Expected results:
smartcard works just as it works with default controller (USB2 or in domain xml, ich9-ehci/ich9-uhci)

Additional info:
examples of qemu log:
-- 8< --
usb-ccid: ccid_handle_bulk_out 65 GetSlotStatus
usb-ccid: ccid_reserve_recv_buf: QUEUE: reserve 10 bytes
usb-ccid: ccid_calc_status: status = 0
usb-ccid: ccid_bulk_in_copy_to_guest: 10/10 req/act to guest (BULK_IN)
usb-ccid: ccid_bulk_in_copy_to_guest: 10/2 req/act to guest (BULK_IN)
usb-ccid: ccid_bulk_in_copy_to_guest: returning short (EREMOTEIO) 2 < 10
-- 8< --
usb-ccid: ccid_handle_bulk_out 65 GetSlotStatus
usb-ccid: ccid_reserve_recv_buf: QUEUE: reserve 10 bytes
usb-ccid: ccid_calc_status: status = 0
usb-ccid: ccid_bulk_in_copy_to_guest: 10/10 req/act to guest (BULK_IN)
usb-ccid: ccid_bulk_in_copy_to_guest: 10/10 req/act to guest (BULK_IN)
usb-ccid: ccid_handle_bulk_out 65 GetSlotStatus
usb-ccid: ccid_reserve_recv_buf: QUEUE: reserve 10 bytes
usb-ccid: ccid_calc_status: status = 0
usb-ccid: ccid_bulk_in_copy_to_guest: 10/10 req/act to guest (BULK_IN)
usb-ccid: ccid_handle_bulk_out 62 IccPowerOn
usb-ccid: ccid_handle_bulk_out: PowerOn: 0
usb-ccid: ccid_write_data_block_atr: atr contains protocol=0
usb-ccid: ccid_reserve_recv_buf: QUEUE: reserve 22 bytes
usb-ccid: ccid_calc_status: status = 0
usb-ccid: ccid_bulk_in_copy_to_guest: 259/22 req/act to guest (BULK_IN)
usb-ccid: ccid_bulk_in_copy_to_guest: returning short (EREMOTEIO) 22 < 259

usb-ccid: ccid_handle_bulk_out 6f XfrBlock
usb-ccid: ccid_on_apdu_from_guest: seq 27, len 14
usb-ccid: usb-ccid: pending answers:usb-ccid: 0:27
usb-ccid: ccid_bulk_in_copy_to_guest: returning short (EREMOTEIO) 0 < 273
usb-ccid: APDU returned to guest 2 (answer seq 27, slot 0)
usb-ccid: usb-ccid: pending answers:usb-ccid:  empty
usb-ccid: ccid_reserve_recv_buf: QUEUE: reserve 12 bytes
usb-ccid: ccid_calc_status: status = 0

Comment 1 Gerd Hoffmann 2015-04-28 08:05:50 UTC
http://patchwork.ozlabs.org/patch/465422/

Comment 2 Ademar Reis 2015-07-15 14:19:48 UTC
(In reply to Gerd Hoffmann from comment #1)
> http://patchwork.ozlabs.org/patch/465422/

I don't see this patch upstream yet... What's the plan? Should I devel_ack+ this BZ?

Comment 3 Gerd Hoffmann 2015-07-16 06:26:37 UTC
upstream commit 4e8cfbe1143d8384387595b500212d7a7f11aeae

Comment 4 Gerd Hoffmann 2015-07-16 07:00:13 UTC
backport posted.

Comment 6 Gerd Hoffmann 2015-07-16 14:38:31 UTC
please test this scratch build:
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=9529070

Comment 7 Gerd Hoffmann 2015-07-17 12:17:33 UTC
new patch posted.

Comment 8 David Jaša 2015-07-21 14:52:09 UTC
(In reply to Gerd Hoffmann from comment #6)
> please test this scratch build:
> http://brewweb.devel.redhat.com/brew/taskinfo?taskID=9529070

The scratch build fixes the problem at my system. The "ccid_bulk_in_copy_to_guest: returning short (EREMOTEIO)" messages keep being printed by qemu however (I'm not sure if they're significant though).

Comment 9 David Jaša 2015-07-21 14:54:17 UTC
Created attachment 1054428 [details]
log of logging into the system using smartcard, log is full of EREMOTEIO messages

Comment 10 Miroslav Rezanina 2015-08-05 08:19:21 UTC
Fix included in qemu-kvm-rhev-2.3.0-15.el7

Comment 12 Yanhui Ma 2015-08-13 08:46:43 UTC
reproduce the issue:
host info:
3.10.0-303.el7.x86_64
qemu-kvm-rhev-2.3.0-12.el7.x86_64

steps:
1.boot up a rhel7.2 guest with smartcard controller and USB3 controller:
-device nec-usb-xhci -chardev spicevmc,name=smartcard,id=ccid -device usb-ccid -device ccid-card-passthru,chardev=ccid
2.in both host and guest
#yum groupinstall "smart card support"
 #yum remove '*openct*'
 #service pcscd start
3.plug in the reader before you run remote-viewer on host.
  remote-viewer --spice-smartcard spice://$IP:7000
4. open Smart Card Manager application in  guest

actual results:
Smart Card Manager application can not find the samrt card in guest.

verify the issue:
host info:
3.10.0-303.el7.x86_64
qemu-kvm-rhev-2.3.0-15.el7.x86_64

steps:
the same as above

actual results:
Smart Card Manager application can find the samrt card in guest.

Comment 13 Pei Zhang 2015-08-17 07:39:50 UTC
Verify this issue from libvirt :

verify version:
libvirt-1.2.17-5.el7.x86_64
qemu-kvm-rhev-2.3.0-17.el7.x86_64

verify steps:

1.prepare env
both host and guest : 
# yum groupinstall "smart card support"
# service pcscd start 
Redirecting to /bin/systemctl start  pcscd.service

Plug physical smart card to host .
check in host :
Application ---> SystemTools ---> Smart Card Manager

2.define and start guest with following XML configuration.  

#virsh dumpxml r708 
usb3.0 controller:

<controller type='usb' index='0' model='nec-xhci'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>

ccid controller :
<controller type='ccid' index='0'>
      <alias name='ccid0'/>
    </controller>

smart card passthrough :
 <smartcard mode='passthrough' type='spicevmc'>
      <alias name='smartcard0'/>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>

spice graphic:
  <graphics type='spice' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

2.1 check qemu cli, make sure guest's qemu cli like following  :
-device nec-usb-xhci,id=usb,bus=pci.0,addr=0x6 
-device usb-ccid,id=ccid0 
-chardev spicevmc,id=charsmartcard0,name=smartcard
-device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0

3.start guest to check
#virsh start r708
#virsh domdisplay r708

3.2 using remote-viewer to check, must with "--spice-smartcard"
# remote-viewer --spice-smartcard spice://$host-IP:5901

check in guest :
Application ---> SystemTools ---> Smart Card Manager
smartcard enrolled.

Comment 14 juzhang 2015-08-17 09:01:55 UTC
According to comment12 and commnet13, set this issue as verified.

Comment 16 errata-xmlrpc 2015-12-04 16:37:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2546.html