Bug 921426

Summary: The other opiton of the 'virsh find-storage-pool-sources-as' command didn't work while appointed the storage type logical
Product: Red Hat Enterprise Linux 7 Reporter: zhenfeng wang <zhwang>
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: cwei, dyuan, mzhan, rbalakri, yanyang, yisun, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.14-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:42:11 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 zhenfeng wang 2013-03-14 07:51:47 UTC
Description of problem:
The other opiton of the 'virsh find-storage-pool-sources-as' command didn't work while appointed the storage type logical
Version-Release number of selected component (if applicable):
qemu-kvm-1.3.0-6.el7.x86_64
kernel-3.7.0-0.36.el7.x86_64
libvirt-1.0.3-1.el7.x86_64

How reproducible:
100%
Steps
1. Create a physical volume in local.
# pvcreate /dev/sda8
2. Create a volume group
# vgcreate myvg /dev/sda8
3. Create a pv and vg in remote refer to the step 2&3
4. virsh find-storage-pool-sources-as logical $local-ip
# virsh find-storage-pool-sources-as logical $local-ip
<sources>
  <source>
    <device path='/dev/sda5'/>
    <name>myvg</name>
    <format type='lvm2'/>
  </source>
  <source>
    <device path='/dev/sdc2'/>
    <name>VolGroup</name>
    <format type='lvm2'/>
  </source>
  <source>
    <device path='/dev/sdd'/>
    <name>811e737c-533e-4c18-b672-daece07a8a41</name>
    <format type='lvm2'/>
  </source>
</sources>
6 can't find the remote host storage while appoint the option --host with the remote ip address,however,it still list the local storage
# virsh find-storage-pool-sources-as logical --host $remote-ip
<sources>
  <source>
    <device path='/dev/sda5'/>
    <name>myvg</name>
    <format type='lvm2'/>
  </source>
  <source>
    <device path='/dev/sdc2'/>
    <name>VolGroup</name>
    <format type='lvm2'/>
  </source>
  <source>
    <device path='/dev/sdd'/>
    <name>811e737c-533e-4c18-b672-daece07a8a41</name>
    <format type='lvm2'/>
  </source>
</sources>
7. can still list the local storage ,evenif appointed a illegal option value
# virsh find-storage-pool-sources-as logical --host abcd --port abcd
<sources>
  <source>
    <device path='/dev/sda5'/>
    <name>myvg</name>
    <format type='lvm2'/>
  </source>
  <source>
    <device path='/dev/sdc2'/>
    <name>VolGroup</name>
    <format type='lvm2'/>
  </source>
  <source>
    <device path='/dev/sdd'/>
    <name>811e737c-533e-4c18-b672-daece07a8a41</name>
    <format type='lvm2'/>
  </source>
</sources>

8.the nfs storage can find the remote nfs storage correctly with the --host option

 #virsh find-storage-pool-sources-as netfs --host $remote-ip

Actual results:
can't find the remote logical storage with --host option  and didn't report error evenif the option value was illegal

Expected results:
I am not sure whether the find-storage-pool-as command support find the remote logical storage ,if it supported,it should list the remote storage correctly,if not ,it should report some proper error while the command's option with illegal value

Comment 2 zhenfeng wang 2013-03-14 07:58:40 UTC
From the manpage of the virsh find-storage-pool-as command, we knew that ,this command support the following option
# virsh find-storage-pool-sources-as --help
 OPTIONS
    [--type] <string>  type of storage pool sources to find
    [--host] <string>  optional host to query
    [--port] <string>  optional port to query
    [--initiator] <string>  optional initiator IQN to use for query
I have a doubt that which type of the storage support the --host --port option now,and what's the function of the --port option ? thanks

Comment 5 John Ferlan 2015-02-25 22:37:01 UTC
I disagree with the Expected results, although admittedly it's not very clear from the virsh man page, which is something I will use this bz to rectify.

If you look at the API eventually called :

http://libvirt.org/html/libvirt-libvirt-storage.html#virConnectFindStoragePoolSources

You will see that the API returns all possible pools for a given type dependant upon the 'srcSpec' XML.  As it turns out it's up to the individual storage backend modules to provide the search service.  Currently only 4 provide that - netfs, gluster, logical, and iscsi.

Of those, the "host" is required for only netfs, gluster, and iscsi.  The "port" and "initiator" are only used for iscsi pool searches.

I disagree the command should fail if something that's not necessary is provided; however, if something is required, but not provided, then yes an error is generated. For example:

# virsh find-storage-pool-sources-as iscsi
error: Failed to find any iscsi pool sources
error: invalid argument: hostname and device path must be specified for iscsi sources

#

Although the error message is a bit incorrect as only host is required:

# virsh find-storage-pool-sources-as iscsi 192.168.122.1
<sources>
  <source>
    <host name='192.168.122.1' port='3260'/>
    <device path='iqn.2013-12.com.example:iscsi-chap-lclpool'/>
  </source>
  <source>
    <host name='192.168.122.1' port='3260'/>
    <device path='iqn.2013-12.com.example:iscsi-chap-netpool'/>
  </source>
  <source>
    <host name='192.168.122.1' port='3260'/>
    <device path='iqn.2013-12.com.example:iscsi-chap-nopool'/>
  </source>
</sources>


For a netfs and gluster pool only the host is required

For a logical pool the host, port, and initiator are ignored.

Comment 6 John Ferlan 2015-02-26 21:45:18 UTC
Patches posted upstream:

http://www.redhat.com/archives/libvir-list/2015-February/msg01189.html

Comment 7 John Ferlan 2015-03-03 04:06:42 UTC
Patches pushed upstream

commit id:

567bd0fa57025efe8eda8f39e48d957842e39d43

$ git describe 567bd0fa57025efe8eda8f39e48d957842e39d43
v1.2.13-31-g567bd0f
$

Comment 10 yisun 2015-06-03 05:42:08 UTC
Verified

On Versions:
libvirt-1.2.15-2.el7.x86_64


verify steps:
1. check the error message when no host info provided for iscsi pool discovery
# virsh find-storage-pool-sources-as iscsi
error: Failed to find any iscsi pool sources
error: invalid argument: hostname must be specified for iscsi sources

<==========It's modifed.


2. check the man page content about "find-storage-pool-sources"
#man virsh
...
find-storage-pool-sources type [srcSpec]
           Returns XML describing all possible available storage pool sources that could be used to create or define a storage pool of a given
           type. If srcSpec is provided, it is a file that contains XML to further restrict the query for pools.

           Not all storage pools support discovery in this manner. Furthermore, for those that do support discovery, only specific XML elements
           are required in order to return valid data, while other elements and even attributes of some elements are ignored since they are not
           necessary to find the pool based on the search criteria. The following lists the supported type options and the expected minimal XML
           elements used to perform the search.

           For a "netfs" or "gluster" pool, the minimal expected XML required is the <host> element with a "name" attribute describing the IP
           address or hostname to be used to find the pool. The "port" attribute will be ignored as will any other provided XML elements in
           srcSpec.

           For a "logical" pool, the contents of the srcSpec file are ignored, although if provided the file must at least exist.

           For an "iscsi" pool, the minimal expect XML required is the <host> element with a "name" attribute describing the IP address or
           hostname to be used to find the pool (the iSCSI server address). Optionally, the "port" attribute may be provided, although it will
           default to 3260. Optionally, an <initiator> XML element with a "name" attribute may be provided to further restrict the iSCSI target
           search to a specific initiator for multi-iqn iSCSI storage pools.

       find-storage-pool-sources-as type [host] [port] [initiator]
           Rather than providing srcSpec XML file for find-storage-pool-sources use this command option in order to have virsh generate the query
           XML file using the optional arguments. The command will return the same output XML as find-storage-pool-sources.

           Use host to describe a specific host to use for networked storage, such as netfs, gluster, and iscsi type pools.

           Use port to further restrict which networked port to utilize for the connection if required by the specific storage backend, such as
           iscsi.

           Use initiator to further restrict the iscsi type pool searches to specific target initiators.
...
<===== It's clear enough to explain the host/port/initiator usage.

Comment 12 errata-xmlrpc 2015-11-19 05:42:11 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-2202.html