Allow iSCSI IQN to be set with find-storage-pool-sources-as command

Allow an iSCSI initiator IQN to be set with the XML for the
find-storage-pool-sources-as virsh command

* tools/virsh.c: Add iSCSI IQN support
This commit is contained in:
Daniel P. Berrange 2010-11-12 13:27:51 +00:00
parent 1bae28e49b
commit 9a7caeffdf

View File

@ -5802,6 +5802,7 @@ static const vshCmdOptDef opts_find_storage_pool_sources_as[] = {
N_("type of storage pool sources to find")}, N_("type of storage pool sources to find")},
{"host", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional host to query")}, {"host", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional host to query")},
{"port", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional port to query")}, {"port", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional port to query")},
{"initiator", VSH_OT_DATA, VSH_OFLAG_NONE, N_("optional initiator IQN to use for query")},
{NULL, 0, 0, NULL} {NULL, 0, 0, NULL}
}; };
@ -5811,6 +5812,7 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
char *type, *host; char *type, *host;
char *srcSpec = NULL; char *srcSpec = NULL;
char *srcList; char *srcList;
char *initiator;
int found; int found;
type = vshCommandOptString(cmd, "type", &found); type = vshCommandOptString(cmd, "type", &found);
@ -5819,6 +5821,9 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
host = vshCommandOptString(cmd, "host", &found); host = vshCommandOptString(cmd, "host", &found);
if (!found) if (!found)
host = NULL; host = NULL;
initiator = vshCommandOptString(cmd, "initiator", &found);
if (!found)
initiator = NULL;
if (!vshConnectionUsability(ctl, ctl->conn)) if (!vshConnectionUsability(ctl, ctl->conn))
return FALSE; return FALSE;
@ -5841,6 +5846,11 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
if (port) if (port)
virBufferVSprintf(&buf, " port='%s'", port); virBufferVSprintf(&buf, " port='%s'", port);
virBufferAddLit(&buf, "/>\n"); virBufferAddLit(&buf, "/>\n");
if (initiator) {
virBufferAddLit(&buf, " <initiator>\n");
virBufferVSprintf(&buf, " <iqn name='%s'/>\n", initiator);
virBufferAddLit(&buf, " </initiator>\n");
}
virBufferAddLit(&buf, "</source>\n"); virBufferAddLit(&buf, "</source>\n");
if (virBufferError(&buf)) { if (virBufferError(&buf)) {
vshError(ctl, "%s", _("Out of memory")); vshError(ctl, "%s", _("Out of memory"));