Re: [libvirt-users] Connect libvirt to iSCSI target

John Ferlan
2013-12-21T15:44:13Z

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...

Have you looked at http://libvirt.org/formatstorage.html ?  There's an
example there of output that works for me. Use virsh pool-dumpxml <pool>
to view the XML...

Also, do you need to authenticate to the iSCSI target?  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.  Looking at the output in the system messages
log may help (for my f19 /var/log/messages).

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...

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

where the <username>/<password> allow the authentication to the
ipAddr
iSCSI tgt server.

If you need to authenticate, then set up a secret to the iSCSI server,
see http://libvirt.org/formatsecret.html for an example.


HTH,

John

> Why can't libvirt find the session, and which session? Running
>
>   iscsiadm --mode discovery --type sendtargets --portal vmhost:3260,1
>
> succeeds and lists the targets. How to connect libvirt to the iSCSI
> target?
>
> System info:
>
> Debian sid, Linux 3.11-2-amd64
> libvirtd (libvirt) 1.1.4
> virsh version: 1.1.4

What's your QEMU version?

>
> iSCSI target: FreeNAS-9.1.1
>
>
> Best regards
> Marco
>
> ¹
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/chap-Virtualization_Administration_Guide-Storage_Pools-Storage_Pools.html#sect-Virtualization-Storage_Pools-Creating-iSCSI
>
> _______________________________________________
> libvirt-users mailing list
> libvirt-users@redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users
>