Bug 1343302 - libvirt Could not find scsi controller with index 1 required for device
Summary: libvirt Could not find scsi controller with index 1 required for device
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-nova
Version: 7.0 (Kilo)
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: async
: 8.0 (Liberty)
Assignee: Kashyap Chamarthy
QA Contact: Prasanth Anbalagan
URL:
Whiteboard:
Depends On: 1380309
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-07 05:51 UTC by xusloan
Modified: 2020-04-15 14:31 UTC (History)
22 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-11 13:58:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description xusloan 2016-06-07 05:51:58 UTC
Description of problem:
I use cinder create volume , nova volume-attach server volumeid to use network disk device by ceph in openstack kilo .
I found one vm can't attach disk The fifth mount point。
nova compute report
2016-06-07 10:03:31.802 4622 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib64/python2.7/site-packages/libvirt.py", line 557, in attachDeviceFlags
2016-06-07 10:03:31.802 4622 TRACE oslo_messaging.rpc.dispatcher     if ret == -1: raise libvirtError ('virDomainAttachDeviceFlags() failed', dom=self)
2016-06-07 10:03:31.802 4622 TRACE oslo_messaging.rpc.dispatcher libvirtError: internal error: Could not find scsi controller with index 1 required for device

so,I extract nova to_xml()
<driver name="qemu" type="raw" cache="writeback"/>
  <source protocol="rbd" name="volumes/volume-6a804a02-8bf7-4ae9-9fcc-af625281c1bf">
    <host name="10.138.123.194" port="6789"/>
    <host name="10.138.123.195" port="6789"/>
    <host name="10.138.123.196" port="6789"/>
  </source>
  <auth username="cinder">
    <secret type="ceph" uuid="12a18a3c-e67b-4aa4-968b-e60e458fe041"/>
  </auth>
  <target bus="scsi" dev="sdh"/>
  <serial>6a804a02-8bf7-4ae9-9fcc-af625281c1bf</serial>
</disk>

I try 
virsh attach-device --domain instance-00001430 --file 1.xml --config --live

the same of error
Could not find scsi controller with index 1 required for device

The scene is

vm disk have 

/dev/sda1 is root
/dev/sdb  is swap

nova volume-attach server volume

I will see /dev/sdc , it is success!

nova volume-attach server volume

I will see /dev/sdd , it is success!

nova volume-attach server volume

I will see /dev/sde , it is success!

nova volume-attach server volume

I will see /dev/sdf , it is success!

nova volume-attach server volume

I will see /dev/sdg , it is success!

nova volume-attach server volume

I will't  see /dev/sdh , it is failed!

so, virus attach-device can't mount the fifth disk device!

so,I try edit xml :
<disk type='network' device='disk'>
  <driver name='qemu' type='raw' cache='writeback'/>
  <auth username='cinder'>
    <secret type='ceph' uuid='12a18a3c-e67b-4aa4-968b-e60e458fe041'/>
  </auth>
  <source protocol='rbd' name='volumes/volume-6a804a02-8bf7-4ae9-9fcc-af625281c1bf'>
    <host name='10.138.123.194' port='6789'/>
    <host name='10.138.123.195' port='6789'/>
    <host name='10.138.123.196' port='6789'/>
  </source>
  <backingStore/>
  <target dev='sdh' bus='scsi'/>
  <serial>6a804a02-8bf7-4ae9-9fcc-af625281c1bf</serial>
  <alias name='scsi0-0-0-7'/>
  <address type='drive' controller='0' bus='0' target='0' unit='7'/>
</disk>

and , exec virsh command again

virsh attach-device --domain instance-00001430 --file 1.xml --config --live


I will  see /dev/sdh , it is success!

but,xml file is auto create by nova , so I cant't mount fifth device by nova volume-attach.

virsh version
Compiled against library: libvirt 1.2.17
Using library: libvirt 1.2.17
Using API: QEMU 1.2.17
Running hypervisor: QEMU 2.4.0

Comment 2 Jaroslav Suchanek 2016-06-20 12:09:38 UTC
Thank you for reporting this bug. I am reassigning this to nova component in RHOS for further analysis.

Comment 4 Kashyap Chamarthy 2016-06-24 10:49:15 UTC
It looks like your issue could fixed by this patch[1]:

    commit 105794cd434d815e483f87732f2084f55ae62c42
    Author: Boris Fiuczynski <fiuczy.ibm.com>
    Date:   Mon Nov 30 12:06:01 2015 +0100

        qemu: Automatic SCSI controller creation in SCSI disk hotplug 
        broken
        
        When a SCSI disk is hotplugged to a domain that does not have
        the required SCSI controller already defined and loaded the
        following internal error occurs
        
        error: Failed to attach device from scsi_disk.xml error:
        internal error: Could not find scsi controller with index 0
        required for device 
        
        Commit 0260506c added in method qemuBuildDriveDevStr a lookup of
        the controller alias. The internal error occurs because in
        method qemuDomainAttachSCSIDisk the automatic creation of the
        potentially missing SCSI controller occurs after calling
        qemuBuildDriveDevStr.
 
        This patch reverses the calling sequence.
 
 
This is included in libvirt-1.3.5-1.el7.  Can you please try with this
libvirt version, and report your result (and also a clearer reproducer
if you're still hitting the issue)?


[1] http://libvirt.org/git/?p=libvirt.git;a=commit;h=105794c -- qemu:
    Automatic SCSI controller creation in SCSI disk hotplug broken

Comment 5 xusloan 2016-06-24 10:58:31 UTC
thank you ! I will try this version。

Comment 6 Kashyap Chamarthy 2016-07-08 10:19:26 UTC
Okay, the below two commits from the upstream libvirt-1.3.3 maintenance branch should fix this issue -- I have tested[1] it upstream.

  - http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=627b6b0 -- 
    qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI
    controllers v1.3.3-maint

  - http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=696ab0a -- 
    qemu: hot-plug: Fix broken SCSI disk hot-plug

-----------------------------------------------------------------------
commit 627b6b0f6814ac686683e620c10228f89a918e15
Author: Marc Hartmayer <mhartmay.ibm.com>
Date:   Mon Jun 27 16:43:47 2016 +0200

    qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI controllers
    
    Ensure that the given controller and all controllers with a smaller
    index exist; there must not be any missing index in between.
    
    Reviewed-by: Boris Fiuczynski <fiuczy.ibm.com>
    Reviewed-by: Bjoern Walk <bwalk.ibm.com>
    Signed-off-by: Marc Hartmayer <mhartmay.ibm.com>
    (cherry picked from commit 12ec22b68befce0ae8020635e7fd71d783b1d716)
    
     Conflicts:
        src/qemu/qemu_hotplug.c: - context of the first hunk changed

commit 696ab0a1256a2c6a726005e30ea9f1ee4536334e
Author: Marc Hartmayer <mhartmay.ibm.com>
Date:   Mon Jun 27 16:43:46 2016 +0200

    qemu: hot-plug: Fix broken SCSI disk hot-plug
    
    The commit "qemu: hot-plug: Assume support for -device in
    qemuDomainAttachSCSIDisk" dropped the code for the automatic SCSI
    controller creation used in SCSI disk hot-plugging. If we are
    hot-plugging a SCSI disk to a domain and there is no proper SCSI
    controller defined, it results in an "error: internal error: Could not
    find scsi controller with index X required for device" error.
    
    For that reason reverting a hunk of the commit
    d4d32005d6e8b2cc0a2f26b483ca1de10171db6d.
    
    This patch also adds an extra comment to the code to clarify the
    loop.
    
    Reviewed-by: Boris Fiuczynski <fiuczy.ibm.com>
    Reviewed-by: Bjoern Walk <bwalk.ibm.com>
    Signed-off-by: Marc Hartmayer <mhartmay.ibm.com>
    (cherry picked from commit 58d07db9b0c294e92e294cadd737eee8597bf747)

-----------------------------------------------------------------------

[1] http://www.redhat.com/archives/libvir-list/2016-June/msg02250.html

Comment 7 Kashyap Chamarthy 2016-07-08 10:47:35 UTC
(In reply to Kashyap Chamarthy from comment #6)
> Okay, the below two commits from the upstream libvirt-1.3.3 maintenance
> branch should fix this issue -- I have tested[1] it upstream.
> 
>   - http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=627b6b0 -- 
>     qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI
>     controllers v1.3.3-maint
> 
>   - http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=696ab0a -- 
>     qemu: hot-plug: Fix broken SCSI disk hot-plug


I can confirm that this RHEL libvirt version has the above two fixes: libvirt-2.0.0-1.el7 -- when testing, please test with this version (or above).

Comment 8 dev-unix-virtualization 2016-08-20 15:25:06 UTC
I am hitting this issue on centos 7 with libvirt-1.2.17-13.el7_2.5

how to upgrade libvirt-1.2.17-13.el7_2.5 to libvirt-1.3.5-1.el7 on centos 7?

Is there any documents for that?

Comment 24 awaugama 2017-08-30 17:53:41 UTC
WONTFIX/NOTABUG therefore QE Won't automate


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