mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
secret: add iscsi to possible usage types
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
8110a8249d
commit
adba070122
@ -66,6 +66,18 @@
|
|||||||
device</a>. <span class="since">Since 0.9.7</span>.
|
device</a>. <span class="since">Since 0.9.7</span>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h3>Usage type "iscsi"</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This secret is associated with an iSCSI target for CHAP authentication.
|
||||||
|
The <code><usage type='iscsi'></code> element must contain
|
||||||
|
a single <code>target</code> element that specifies a usage name
|
||||||
|
for the secret. The iSCSI secret can then be used by UUID or by
|
||||||
|
this usage name via the <code><auth></code> element of
|
||||||
|
a <a href="domain.html#elementsDisks">disk
|
||||||
|
device</a>. <span class="since">Since 1.0.4</span>.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h2><a name="example">Example</a></h2>
|
<h2><a name="example">Example</a></h2>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<choice>
|
<choice>
|
||||||
<ref name='usagevolume'/>
|
<ref name='usagevolume'/>
|
||||||
<ref name='usageceph'/>
|
<ref name='usageceph'/>
|
||||||
|
<ref name='usageiscsi'/>
|
||||||
<!-- More choices later -->
|
<!-- More choices later -->
|
||||||
</choice>
|
</choice>
|
||||||
</element>
|
</element>
|
||||||
@ -67,4 +68,13 @@
|
|||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
<define name='usageiscsi'>
|
||||||
|
<attribute name='type'>
|
||||||
|
<value>iscsi</value>
|
||||||
|
</attribute>
|
||||||
|
<element name='target'>
|
||||||
|
<ref name='genericName'/>
|
||||||
|
</element>
|
||||||
|
</define>
|
||||||
|
|
||||||
</grammar>
|
</grammar>
|
||||||
|
@ -3649,6 +3649,7 @@ typedef enum {
|
|||||||
VIR_SECRET_USAGE_TYPE_NONE = 0,
|
VIR_SECRET_USAGE_TYPE_NONE = 0,
|
||||||
VIR_SECRET_USAGE_TYPE_VOLUME = 1,
|
VIR_SECRET_USAGE_TYPE_VOLUME = 1,
|
||||||
VIR_SECRET_USAGE_TYPE_CEPH = 2,
|
VIR_SECRET_USAGE_TYPE_CEPH = 2,
|
||||||
|
VIR_SECRET_USAGE_TYPE_ISCSI = 3,
|
||||||
|
|
||||||
#ifdef VIR_ENUM_SENTINELS
|
#ifdef VIR_ENUM_SENTINELS
|
||||||
VIR_SECRET_USAGE_TYPE_LAST
|
VIR_SECRET_USAGE_TYPE_LAST
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#define VIR_FROM_THIS VIR_FROM_SECRET
|
#define VIR_FROM_THIS VIR_FROM_SECRET
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_LAST,
|
VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_LAST,
|
||||||
"none", "volume", "ceph")
|
"none", "volume", "ceph", "iscsi")
|
||||||
|
|
||||||
void
|
void
|
||||||
virSecretDefFree(virSecretDefPtr def)
|
virSecretDefFree(virSecretDefPtr def)
|
||||||
@ -57,6 +57,10 @@ virSecretDefFree(virSecretDefPtr def)
|
|||||||
VIR_FREE(def->usage.ceph);
|
VIR_FREE(def->usage.ceph);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_ISCSI:
|
||||||
|
VIR_FREE(def->usage.target);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
|
VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
|
||||||
break;
|
break;
|
||||||
@ -108,6 +112,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_ISCSI:
|
||||||
|
def->usage.target = virXPathString("string(./usage/target)", ctxt);
|
||||||
|
if (!def->usage.target) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("iSCSI usage specified, but target is missing"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected secret usage type %d"),
|
_("unexpected secret usage type %d"),
|
||||||
@ -262,6 +275,13 @@ virSecretDefFormatUsage(virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_ISCSI:
|
||||||
|
if (def->usage.target != NULL) {
|
||||||
|
virBufferEscapeString(buf, " <target>%s</target>\n",
|
||||||
|
def->usage.target);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected secret usage type %d"),
|
_("unexpected secret usage type %d"),
|
||||||
|
@ -39,6 +39,7 @@ struct _virSecretDef {
|
|||||||
union {
|
union {
|
||||||
char *volume; /* May be NULL */
|
char *volume; /* May be NULL */
|
||||||
char *ceph;
|
char *ceph;
|
||||||
|
char *target;
|
||||||
} usage;
|
} usage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -149,6 +149,11 @@ secretFindByUsage(virSecretDriverStatePtr driver, int usageType, const char *usa
|
|||||||
if (STREQ(s->def->usage.ceph, usageID))
|
if (STREQ(s->def->usage.ceph, usageID))
|
||||||
return s;
|
return s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_ISCSI:
|
||||||
|
if (STREQ(s->def->usage.target, usageID))
|
||||||
|
return s;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -614,6 +619,9 @@ secretUsageIDForDef(virSecretDefPtr def)
|
|||||||
case VIR_SECRET_USAGE_TYPE_CEPH:
|
case VIR_SECRET_USAGE_TYPE_CEPH:
|
||||||
return def->usage.ceph;
|
return def->usage.ceph;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_ISCSI:
|
||||||
|
return def->usage.target;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user