[libvirt-users] Connect libvirt to iSCSI target

John Ferlan jferlan at redhat.com
Mon Dec 23 13:14:09 UTC 2013



On 12/22/2013 10:09 AM, Marco wrote:
> On 2013–12–21 John Ferlan wrote:
> 
>> On 12/17/2013 07:13 PM, Marco wrote:
>>> Hi!
>>>
>>> I'm new to libvirt and face problems connecting to an iSCSI target.
>>> What I intend to do is to connect libvirt (I tried virt-manager and
>>> virsh) to an iSCSI target and then boot from the LUNs which contain
>>> the VMs.
>>>
>>> I followed the documentation¹ but got stuck at section 12.1.5.4.3.
>>>
>>> 1)
>>>   virsh pool-define-as \
>>>     --name foo                             \
>>>     --type iscsi                           \
>>>     --source-host vmhost                   \
>>>     --source-dev iqn.2013-11.vmhost:vmpool \
>>>     --target /dev/disk/by-path
>>>
>>> 2)
>>>   virsh pool-start foo
>>>   error: Failed to start pool foo
>>>   error: internal error: cannot find session
>>>
>>>   virsh -c qemu:///system pool-start foo
>>>   error: Failed to start pool foo
>>>   error: internal error: cannot find session
>>>
>>
>> I'm assuming 'vmhost' is actually some valid IP Address/Name that you're
>> just using here to hide from the world your actual iSCSI tgt server.
>> Don't forget that the 'source-host' may be listed as
>> 'host1.example.com'; however, the iqn has 'com.example.host1'. IOW -
>> reversed...
> 
> It's a test setup and I don't use a FQDN.
> 
>> Have you looked at http://libvirt.org/formatstorage.html ?
> 
> I did, indeed.
> 
>> There's an example there of output that works for me.
> 
> For me it does not.
> 
>> Use virsh pool-dumpxml <pool>
>> to view the XML...
> 
> Here's my XML which is directly taken from the manual. I only
> changed the host name to “freenas” and the device path.
> 
> <pool type='iscsi'>
>   <name>virtimages</name>
>   <uuid>347feb68-7e11-4f2b-ba82-ada027296fb0</uuid>
>   <capacity unit='bytes'>0</capacity>
>   <allocation unit='bytes'>0</allocation>
>   <available unit='bytes'>0</available>
>   <source>
>     <host name='freenas'/>
>     <device path='iqn.2013-11.freenas:vmpool'/>
>   </source>
>   <target>
>     <path>/dev/disk/by-path</path>
>     <permissions>
>       <mode>0755</mode>
>       <owner>-1</owner>
>       <group>-1</group>
>     </permissions>
>   </target>
> </pool>
> 
>> Also, do you need to authenticate to the iSCSI target?
> 
> Not yet. To rule out authentication issues for testing I turned off
> authentication.
> 
>> The iscsiadm will use '/etc/iscsi/iscsid.conf'. See the
>> node.session.auth.{authmethod | username | password} fields, so
>> while iscsiadm may work, when libvirt goes to connect it fails.
> 
> Thanks for pointing that out, but I don't think it's the case here.
> 
>> Looking at the output in the system messages
>> log may help (for my f19 /var/log/messages).
> 
> The log of a failed virsh pool-start virtimages can be found here
> http://dpaste.com/1518444/
> 
> Most notable is I assume:
> 
>   libvirtd[8028]: internal error: Child process (/usr/bin/iscsiadm --mode session) unexpected exit status 21
> 

Yeah - there just wasn't enough information there for me to go on.
During my work on this I did run into one other issue that's discussed
in a bz (https://bugzilla.redhat.com/show_bug.cgi?id=957295) where
libiscsi had a bug where it wasn't handling the name string built up by
libvirt properly.  I don't remember all the details of what was
happening, but you'd see messages from libvirtqemu indicating something
like:

" could not open disk image
iscsi://freenas:3260/iqn.2013-11.freenas%3Avmpool:"

This was for the case for when the iSCSI target was directly added to
the guest though, but that's just a subset of the pool changes.


Still the whole issue occurred in late October which I is within the
same time frame of 1.1.4 which you are using.  So what is your libiscsi
version.

Not sure how much time I'll have over the next week to look at anything
as I'm busy with non work related things...

John


>>From “man iscsiadm”:
> 
>   21 ISCSI_ERR_NO_OBJS_FOUND - no records/targets/sessions/portals
>      found to execute operation on.
> 
> If I run “iscsiadm --mode session” in the console, I indeed get and
> error:
> 
>   iscsiadm: No active sessions.
> 
> Do I need to create a session or setup libvert to do that before
> iSCSI is supposed to work?
> 
> The log shows that libvirt is able to connect to the target:
> 
>   iscsid: Connection85:0 to [target: iqn.2013-11.freenas:vmpool, portal: 10.0.10.23,3260] through [iface: libvirt-iface-04d9ea67] is operational now
> 
>> You may also find if you have selinux enabled as Enforcing there could
>> be more configuration that you need (if the iSCSI tgtd is local).
>> Setting up a label on the file - something I'm not an expert at...
> 
> selinux is not used.
> 
>> Another tool to try is 'iscsi-ls' from package 'libiscsi-utils'
>>
>> iscsi-ls -s -i iqn.2013-11.vmhost:vmpool \
>>          iscsi://<username>%<password>@<ipAddr>:3260
> 
> This succeeds:
> 
>   iscsi-ls -s -i iqn.2013-11.freenas:vmpool iscsi://freenas
> 
>   Target:iqn.2013-11.freenas:vmpool Portal:10.0.10.23:3260,1
>   Lun:0    Type:DIRECT_ACCESS (Size:9G)
>   […]
> 
>> If you need to authenticate, then set up a secret to the iSCSI server,
>> see http://libvirt.org/formatsecret.html for an example.
> 
> If the simple setup is working I'll add authentication but for the
> moment I try to keep is as simple as possible.
> 
> To rule out issues with the iSCSI target I manually tested using
> “iscsiadm” and VirtualBox which both succeeded without any session
> errors.
> 
> Thanks for your quick response.
> 
> Best regards
> Marco
> 
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users
> 




More information about the libvirt-users mailing list