From 4b2b53f674f6b831c842a89b4e96aa80b2cb1d92 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 11 May 2015 13:51:04 -0400 Subject: [PATCH] conf: Remove source host name check for iSCSI https://bugzilla.redhat.com/show_bug.cgi?id=1171984 https://bugzilla.redhat.com/show_bug.cgi?id=1188463 Remove the check for the source host name for iSCSI source XML processing declaring duplicate sources when the source device path and if present the initiator of a proposed storage pool matches an existing storage pool. The backend iSCSI storage driver uses 'iscsiadm --mode session' to query available iscsid target sessions. The output displayed is the IP address and the IQN (target path) of known targets. The displayed IP address is a resolved address based on the session --login. Additionally, iscsid keeps track of the various ways to define the host name (IPv4 Address, IPv6 Address, /etc/hosts, etc.) for that IQN (see output of an 'iscsiadm --mode node'). If an incoming IQN matches and the host name provided by libvirt is resolved to the existing IQN, then iscsid will "reuse" the session. Although libvirt could do the same name resolution, if there is a difference, iscsid could still declare two seemingly different sources to be the same and not create a new session which means libvirt now has two storage pools looking at the same source. Thus to avoid any strange host name resolution issues, just rely on iscsid for that and do not allow multiple pools on the same host to use the same device path (IQN). --- docs/formatstorage.html.in | 18 ++++++++++++++---- docs/storage.html.in | 8 +++++++- src/conf/storage_conf.c | 4 +--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 479e73c41..474abd625 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -78,7 +78,7 @@ ... <source> <host name="iscsi.example.com"/> - <device path="demo-target"/> + <device path="iqn.2013-06.com.example:iscsi-pool"/> <auth type='chap' username='myname'> <secret usage='mycluster_myname'/> </auth> @@ -118,8 +118,10 @@ (pool types fs, logical, disk, iscsi, zfs). May be repeated multiple times depending on backend driver. Contains - a single attribute path which is the fully qualified - path to the block device node. Since 0.4.1 + a single attribute path which is either the fully + qualified path to the block device node or for iscsi + the iSCSI Qualified Name (IQN). + Since 0.4.1
dir
Provides the source for pools backed by directories (pool type dir), or optionally to select a subdirectory @@ -292,7 +294,15 @@ or device element. Contains an attribute name which is the hostname or IP address of the server. May optionally contain a port attribute for the protocol specific - port number. Since 0.4.1
+ port number. Duplicate storage pool definition checks may perform + a cursory check that the same host name by string comparison in the + new pool does not match an existing pool's source host name when + combined with the directory or device + element. Name resolution of the provided hostname or IP address + is left to the storage driver backend interactions with the remote + server. See the storage driver page for + any restrictions for specific storage backends. + Since 0.4.1
auth
If present, the auth element provides the authentication credentials needed to access the source by the diff --git a/docs/storage.html.in b/docs/storage.html.in index b9b503de8..92e9ae7b5 100644 --- a/docs/storage.html.in +++ b/docs/storage.html.in @@ -439,6 +439,12 @@ to use /dev/disk/by-path or /dev/disk/by-id for the target path. These provide persistent stable naming for LUNs

+

+ The libvirt iSCSI storage backend does not resolve the provided + host name or IP address when finding the available target IQN's + on the host; therefore, defining two pools to use the same IQN + on the same host will fail the duplicate source pool checks. +

Example pool input

@@ -446,7 +452,7 @@
         <name>virtimages</name>
         <source>
           <host name="iscsi.example.com"/>
-          <device path="demo-target"/>
+          <device path="iqn.2013-06.com.example:iscsi-pool"/>
         </source>
         <target>
           <path>/dev/disk/by-path</path>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 61365b9ca..65b270410 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -2427,9 +2427,7 @@ virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool,
     virStoragePoolSourcePtr poolsrc = &matchpool->def->source;
     virStoragePoolSourcePtr defsrc = &def->source;
 
-    if (!virStoragePoolSourceMatchSingleHost(poolsrc, defsrc))
-        return false;
-
+    /* NB: Do not check the source host name */
     if (STRNEQ_NULLABLE(poolsrc->initiator.iqn, defsrc->initiator.iqn))
         return false;
 
-- 
2.39.5