[libvirt] [libivrt] storage: Two iSCSI node records may cause refreshing iscsi pool failed

Shichangkuo shi.changkuo at h3c.com
Fri Dec 2 03:58:28 UTC 2016

Hi, John
    When starting an iscsi storage pool, libvirt will execute “iscsiadm --mode node --portal --targetname iqn.2003-10.com.xxxx --op new”, which is called by virISCSINodeNew.
    This will add an iSCSI node record. The record file is /etc/iscsi/nodes/iqn.2003-10.com.xxxx/,3260.

    When we already executed "iscsiadm --mode discovery --type sendtargets --portal --op new", another iSCSI node record will be produced in /etc/iscsi/nodes/iqn.2003-10.com.xxxx/,3260,1/default.
    Then two iscsi sessions, as [2] and [3], will be logged in when we start the pool.

    Device of session [2] is /dev/sde, and device of session [3] is /dev/sdf.
    But there is only one path in /dev/disk/by-path, let's assume it is /dev/sdf.

    Refreshing storage pool will choose first session, like [2], and libvirt will find sde NOT sdf in /dev/disk/by-path. We will not find sde, then no volumes is found in the pool.
    I think the root reason is we have two iSCSI node records.
    Can we use "iscsiadm --mode discovery --type sendtargets --portal --op new" in virISCSINodeNew?

diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index 504ffbd..a8a8644 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -469,9 +469,9 @@ virISCSINodeNew(const char *portal,
     int ret = -1;

     cmd = virCommandNewArgList(ISCSIADM,
-                               "--mode", "node",
+                               "--mode", "discovery",
+                               "--type", "sendtargets",
                                "--portal", portal,
-                               "--targetname", target,
                                "--op", "new",

This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!

More information about the libvir-list mailing list