Bug 1477880 - can't use default LUN of iscsi protocol used in network type virtual disk when don't specify the LUN
can't use default LUN of iscsi protocol used in network type virtual disk whe...
Status: VERIFIED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.4
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: John Ferlan
Meina Li
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-03 02:53 EDT by Meina Li
Modified: 2017-10-20 06:33 EDT (History)
5 users (show)

See Also:
Fixed In Version: libvirt-3.8.0-1.el7
Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of:
Environment:
Last Closed:
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 Meina Li 2017-08-03 02:53:34 EDT
Description of problem:
can't use default LUN of iscsi protocol used in network type virtual disk when don't specify the LUN, which don't match our documentation that indicate "The above page indicate some points:For "iscsi" (since 1.0.4), the name attribute may include a logical unit number, separated from the target's name by a slash (e.g.,iqn.2013-07.com.example:iscsi-pool/1). If not specified, the default LUN is zero" in http://libvirt.org/formatdomain.html#elementsDisks.

Version-Release number of selected component (if applicable):
libvirt-3.2.0-14.virtcov.el7_4.2.x86_64
kernel-3.10.0-693.el7.x86_64
qemu-kvm-rhev-2.9.0-16.el7_4.3.x86_64

How reproducible:
100%

Steps to Reproduce:
1. On the iscsi-initiator machine, define and start a guest.

2.Attach a iscsi network disk with xml below:
#more iscsi.xml
<disk type='network' device='disk'>
<driver name="qemu" type="raw"/>
<source protocol="iscsi" name="iqn.2013-10.com.example:iscsi/0">
<host name="10.66.4.164" port="3260"/>
</source>
<target dev="vdb" bus="virtio"/>
</disk>
# virsh attach-device r7-qcow2 iscsi.xml
Device attached successfully
# virsh detach-device r7-qcow2 iscsi.xml
Device detached successfull

3.Modify iscsi.xml and ttach a iscsi network disk with xml below:
#more iscsi.xml
<disk type='network' device='disk'>
<driver name="qemu" type="raw"/>
<source protocol="iscsi" name="iqn.2013-10.com.example:iscsi">
<host name="10.66.4.164" port="3260"/>
</source>
<target dev="vdb" bus="virtio"/>
</disk>
# virsh attach-device r7-qcow2 iscsi.xml
error: Failed to attach device from iscsi.xml
error: internal error: unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-virtio-disk1' could not be initialized

Actual results:
step3:
# virsh attach-device r7-qcow2 iscsi.xml
error: Failed to attach device from iscsi.xml
error: internal error: unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-virtio-disk1' could not be initialized

Expected results:
step3:
# virsh attach-device r7-qcow2 iscsi.xml
Device attached successfully

Additional info:
http://libvirt.org/formatdomain.html#elementsDisks: For "iscsi" (since 1.0.4), the name attribute may include a logical unit number, separated from the target's name by a slash (e.g.,iqn.2013-07.com.example:iscsi-pool/1). If not specified, the default LUN is zero
Comment 2 yisun 2017-08-03 23:25:38 EDT
not related to npiv, remove it from white board key word
Comment 3 John Ferlan 2017-09-06 12:09:39 EDT
Strange this was never checked before - sometimes the power of the documentation does make believers.  In any case, posted the following patch upstream to resolve:

https://www.redhat.com/archives/libvir-list/2017-September/msg00122.html
Comment 4 John Ferlan 2017-09-11 19:28:05 EDT
First patch had negative review, so v2 was generated:

https://www.redhat.com/archives/libvir-list/2017-September/msg00248.html

Primary difference is the XML is adjusted during post parse processing rather than during command creation. This results in a change to the output XML as well.

Since QEMU didn't really support a non-supplied value, this should be fine.
Comment 5 John Ferlan 2017-09-12 10:50:36 EDT
Patch has been pushed:

commit f64f03b5b1e6f3ecd6c6d79316c3efedc00c2167
Author: John Ferlan <jferlan@redhat.com>
Date:   Mon Sep 11 19:18:21 2017 -0400

    qemu: Provide default LUN=0 for iSCSI if not provided
    
...
    
    If the "/#" is missing from the provided iSCSI path, then we need
    to provide the default LUN of /0; otherwise, QEMU will fail to parse
    the URL causing a failure to either create the guest or hotplug
    attach the storage.
    
    During post parse, for any iSCSI disk or hostdev, scan the source
    path looking for the presence of '/', if found, then we can assume
    the LUN is provided.  If not found, alter the input XML to add the
    "/0".  This will cause the generated XML to have the generated
    value when the domain config is saved after post parse.

$ git describe f64f03b5b1e6f3ecd6c6d79316c3efedc00c2167
v3.7.0-52-gf64f03b5b
$
Comment 7 Meina Li 2017-10-20 06:33:09 EDT
Test env components:
kernel-3.10.0-734.el7.x86_64
libvirt-3.8.0-1.el7.x86_64
qemu-kvm-rhev-2.10.0-2.el7.x86_64

Steps to verify:
Scenario 1:
1. iSCSI network disk XML(network-disk.xml):
 <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol='iscsi' name='iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.target1'>
        <host name='10.73.224.151' port='3260'/>
      </source>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
  </disk>

2. Attach/detach the disk and check the status:
# virsh attach-device lmn network-disk.xml 
Device attached successfully

# virsh domblklist lmn
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/lmn.qcow2
vdb        iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.target1/0

# virsh detach-device lmn network-disk.xml 
Device detached successfully

Scenario 2:
1. iSCSI network lun XML(network-lun.xml):
 <disk type='network' device='lun'>
      <driver name='qemu' type='raw'/>
      <source protocol='iscsi' name='iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.target1'>
        <host name='10.73.224.151' port='3260'/>
      </source>
      <target dev='sdb' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

2. Attach/detach the disk and check the status:
# virsh attach-device lmn network-lun.xml 
Device attached successfully

# virsh domblklist lmn
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/lmn.qcow2
sdb        iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.target1/0

# virsh detach-device lmn network-lun.xml 
Device detached successfully


Scenario 3:
1. iSCSI hostdev with no scsi controller model:
1)Domain's scsi controller in XML:
<controller type='scsi' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</controller>
2)iSCSI hostdev XML(hostdev-lsi.xml)
<hostdev mode='subsystem' type='scsi' managed='yes'>
      <source protocol='iscsi' name='iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.target1'>
        <host name='10.73.224.151' port='3260'/>
      </source>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='4'/>
    </hostdev>

2. Attach/ the host device and use 'fdisk -l' to check the device in guest:
# virsh attach-device lmn hostdev-lsi.xml 
Device attached successfully

# virsh detach-device lmn hostdev-lsi.xml 
Device detached successfully

Scenario 4:
1. iSCSI hostdev with scsi controller model='virtio-scsi':
1)Domain's scsi controller in XML:
<controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</controller>
2)iSCSI hostdev XML(hostdev-virtio.xml)
<hostdev mode='subsystem' type='scsi' managed='yes'>
      <source protocol='iscsi' name='iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.target1'>
        <host name='10.73.224.151' port='3260'/>
      </source>
      <alias name='hostdev0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='4'/>
    </hostdev>

2. Attach the host device and use 'fdisk -l' to check the device in guest:
# virsh attach-device lmn hostdev-virtio.xml 
Device attached successfully

# virsh detach-device lmn hostdev-virtio.xml 
Device detached successfully

The results are as expected, move this bug to be verified.

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