Bug 1224088

Summary: Using "pool-create-as" to create a scsi pool with wwnn&wwpn has redundant xml check.
Product: Red Hat Enterprise Linux 7 Reporter: yisun
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, rbalakri, shyu, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.17-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:36:24 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 yisun 2015-05-22 07:54:45 UTC
description:
Using "pool-create-as" to create a scsi pool with wwnn&wwpn has redundant xml check.  

versions:
kernel-3.10.0-253.el7.x86_64
libvirt-1.2.15-2.el7.x86_64
qemu-kvm-rhev-2.3.0-1.el7.x86_64

repro steps:
1. try to create a fibre channel scsi pool with wwnn&wwpn as follow:
# virsh pool-create-as npiv-pool scsi --adapter-wwnn 2101001b32a90002 --adapter-wwpn 2101001b32a90002   --adapter-parent scsi_host5 --target /dev/disk/by-path/
error: Failed to create pool npiv-pool
error: XML error: missing storage pool source adapter

2. use same cmd line in step 1 and add "--source-host haha" (or "--source-dev haha" / "--source-path haha")
# virsh pool-create-as npiv-pool scsi --adapter-wwnn 2101001b32a90002 --adapter-wwpn 2101001b32a90002   --adapter-parent scsi_host5 --target /dev/disk/by-path/ --source-host haha
Pool npiv-pool created

3. Check the pool's xml file, the "--source-host haha" doesn't effect the final xml file.
# virsh pool-dumpxml npiv-pool
<pool type='scsi'>
  <name>npiv-pool</name>
  <uuid>50875fdb-97c4-4015-b667-7247cce5bc5b</uuid>
  <capacity unit='bytes'>0</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>0</available>
  <source>
    <adapter type='fc_host' parent='scsi_host5' managed='yes' wwnn='2101001b32a90002' wwpn='2101001b32a90002'/>
  </source>
  <target>
    <path>/dev/disk/by-path</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

actual result:
When ignore the unnecessary source elements, virsh will prevent the creation of a scsi pool from wwnn&wwpn (as step 1).  And if we add the unnecessary element, it will be ignored finally in the xml (as step 3). It's confusing.

expected result:
Step 1 should be a valid command without error.

Additional info:
You can use add "--print-xml" in the command to make a quick reproduction.
standard npiv pool xml as follow:
http://wiki.libvirt.org/page/NPIV_in_libvirt#Creation_of_vHBA_by_the_storage_pool

Comment 2 John Ferlan 2015-05-29 00:53:31 UTC
Seems I forgot to add to the list of "if"'s which cause the code to print the <source...> and source child xml when I added commits '89325806' and 'bd00e00ea'.

As for --source host, --source-dev, --source-path and not appearing after - that's because they are ignored for <pool type='scsi'>

--source-host is valid for "netfs, iscsi, rbd, sheepdog, gluster" pool types
--source-dev is valid for "fs, logical, disk, iscsi, zfs" pool types
--source-path is valid for "dir" pools

Patches post upstream :

http://www.redhat.com/archives/libvir-list/2015-May/msg01103.html

Comment 3 John Ferlan 2015-06-01 09:53:58 UTC
Patch pushed upstream:

commit cffc099356f0ce1bb94d9d009aa49a99b9001d3c
Author: John Ferlan <jferlan>
Date:   Thu May 28 14:29:19 2015 -0400

    virsh: Fix printing of XML for pool-create-as
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1224088
    
    commit id 'bd00e00e' neglected to add the new adapter source options
    into the if condition that allowed printing the <source> XML fields.
    The <adapter type='fc_host'.../> doesn't require other options in order
    to be complete.


git describe cffc099356f0ce1bb94d9d009aa49a99b9001d3c
v1.2.16-2-gcffc099

Comment 5 Yang Yang 2015-07-16 07:28:05 UTC
Verified with libvirt-1.2.17-2.el7.x86_64
Steps
1. create scsi pool with option adapter-wwnn and adapter-wwpn
# virsh pool-create-as npiv-pool scsi --adapter-wwnn 2101001b32a90002 --adapter-wwpn 2101001b32a90002   --adapter-parent scsi_host2 --target /dev/disk/by-path/
Pool npiv-pool created

2. create scsi pool with option adapter-name
# virsh pool-create-as npiv-pool scsi --adapter-name scsi_host7 --target /dev/disk/by-path/ 
Pool npiv-pool created

Comment 7 errata-xmlrpc 2015-11-19 06:36:24 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