Bug 1558317

Summary: VM can not start when configuring alias for ccid controller
Product: Red Hat Enterprise Linux 7 Reporter: jiyan <jiyan>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Jing Qi <jinqi>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: dyuan, jdenemar, jiyan, lmen, mprivozn, xuzhang, yalzhang
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-4.3.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:53:14 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:

Description jiyan 2018-03-20 02:42:46 UTC
Description of problem:
VM can not start  when configuring alias for ccid controller

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.10.0-21.el7_5.1.x86_64
kernel-3.10.0-861.el7.x86_64
libvirt-3.9.0-14.el7_5.1.x86_64

How reproducible:
100%

Steps to Reproduce:
S1: VM can start with no alias configured for ccid controller
# virsh domstate test1
shut off

# virsh dumpxml test1 |grep "<smart" -A2
    <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>

# virsh dumpxml test1 |grep "<controller type='ccid'" -A2
    <controller type='ccid' index='0'>
      <address type='usb' bus='0' port='3'/>
    </controller>

# virsh start test1
Domain test1 started

# ps -ef |grep test1 |grep ccid
-device usb-ccid,id=ccid0,bus=ua-usb6.0,port=3
-chardev spicevmc,id=charsmartcard0,name=smartcard 
-device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0

S2: VM can not start when configuring alias for ccid controller
# virsh domstate test1
shut off

# virsh dumpxml test1 |grep "<smart" -A2
    <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>
[root@amd-5200-4-1 test]# virsh dumpxml test1 |grep "<controller type='ccid'" -A3
    <controller type='ccid' index='0'>
      <alias name='ua-ccid'/>
      <address type='usb' bus='0' port='3'/>
    </controller>

# virsh start test1
error: Failed to start domain test1
error: internal error: qemu unexpectedly closed the monitor: 2018-03-20T02:32:47.269146Z qemu-kvm: -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0: Bus 'ccid0.0' not found

Actual results:
As S2 shows

Expected results:
As S1 shows

Additional info:

Comment 2 Michal Privoznik 2018-03-23 13:29:03 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2018-March/msg01472.html

Comment 3 Michal Privoznik 2018-03-23 14:59:14 UTC
I've just pushed the patch upstream:

commit 42900ec62214c67ab414c55f6f7ac4da0a21d81b
Author:     Michal Privoznik <mprivozn>
AuthorDate: Fri Mar 23 14:24:14 2018 +0100
Commit:     Michal Privoznik <mprivozn>
CommitDate: Fri Mar 23 15:57:06 2018 +0100

    qemu: Build smartcard command line more wisely
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1558317
    
    Similarly to b133fac356324c3 we need to look up alias of CCID
    controller when constructing smartcard command line instead of
    relying on broken assumption it will always be 'ccid0'. After
    user aliases it can be anything.
    
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: Andrea Bolognani <abologna>

v4.1.0-288-g42900ec622

Comment 5 Jing Qi 2018-07-17 02:09:48 UTC
Verified with libvirt-4.5.0-3.el7.x86_64 and passed.

<controller type='ccid' index='0'>
      <alias name='ua-c80aba6e-b6d8-448b-ab6e-8c7b5c29f353'/>
      <address type='usb' bus='0' port='1'/>
    </controller>
 <smartcard mode='passthrough' type='spicevmc'>
      <address type='ccid' controller='0' slot='0'/>
    </smartcard>

# virsh start avocado-vt-vm-numa0
Domain avocado-vt-vm-numa0 started

Comment 7 errata-xmlrpc 2018-10-30 09:53:14 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://access.redhat.com/errata/RHSA-2018:3113