mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-05 04:41:20 +00:00
secret: Add support for usage type vTPM, extend schema and test case
Add support for usage type vTPM to secret. Extend the schema for the Secret to support the vTPM usage type and add a test case for parsing the Secret with usage type vTPM. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
c1d347027f
commit
50a7b0cb4e
@ -37,6 +37,7 @@
|
|||||||
<ref name='usageceph'/>
|
<ref name='usageceph'/>
|
||||||
<ref name='usageiscsi'/>
|
<ref name='usageiscsi'/>
|
||||||
<ref name='usagetls'/>
|
<ref name='usagetls'/>
|
||||||
|
<ref name='usagevtpm'/>
|
||||||
<!-- More choices later -->
|
<!-- More choices later -->
|
||||||
</choice>
|
</choice>
|
||||||
</element>
|
</element>
|
||||||
@ -81,4 +82,13 @@
|
|||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
<define name='usagevtpm'>
|
||||||
|
<attribute name='type'>
|
||||||
|
<value>vtpm</value>
|
||||||
|
</attribute>
|
||||||
|
<element name='name'>
|
||||||
|
<ref name='genericName'/>
|
||||||
|
</element>
|
||||||
|
</define>
|
||||||
|
|
||||||
</grammar>
|
</grammar>
|
||||||
|
@ -43,6 +43,7 @@ typedef enum {
|
|||||||
VIR_SECRET_USAGE_TYPE_CEPH = 2,
|
VIR_SECRET_USAGE_TYPE_CEPH = 2,
|
||||||
VIR_SECRET_USAGE_TYPE_ISCSI = 3,
|
VIR_SECRET_USAGE_TYPE_ISCSI = 3,
|
||||||
VIR_SECRET_USAGE_TYPE_TLS = 4,
|
VIR_SECRET_USAGE_TYPE_TLS = 4,
|
||||||
|
VIR_SECRET_USAGE_TYPE_VTPM = 5,
|
||||||
|
|
||||||
# ifdef VIR_ENUM_SENTINELS
|
# ifdef VIR_ENUM_SENTINELS
|
||||||
VIR_SECRET_USAGE_TYPE_LAST
|
VIR_SECRET_USAGE_TYPE_LAST
|
||||||
|
@ -110,6 +110,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_VTPM:
|
||||||
|
def->usage_id = virXPathString("string(./usage/name)", ctxt);
|
||||||
|
if (!def->usage_id) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("vTPM usage specified, but name 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"),
|
||||||
@ -257,6 +266,10 @@ virSecretDefFormatUsage(virBufferPtr buf,
|
|||||||
virBufferEscapeString(buf, "<name>%s</name>\n", def->usage_id);
|
virBufferEscapeString(buf, "<name>%s</name>\n", def->usage_id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_VTPM:
|
||||||
|
virBufferEscapeString(buf, "<name>%s</name>\n", def->usage_id);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected secret usage type %d"),
|
_("unexpected secret usage type %d"),
|
||||||
|
@ -34,7 +34,7 @@ VIR_LOG_INIT("util.secret");
|
|||||||
|
|
||||||
VIR_ENUM_IMPL(virSecretUsage,
|
VIR_ENUM_IMPL(virSecretUsage,
|
||||||
VIR_SECRET_USAGE_TYPE_LAST,
|
VIR_SECRET_USAGE_TYPE_LAST,
|
||||||
"none", "volume", "ceph", "iscsi", "tls",
|
"none", "volume", "ceph", "iscsi", "tls", "vtpm",
|
||||||
);
|
);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
7
tests/secretxml2xmlin/usage-vtpm.xml
Normal file
7
tests/secretxml2xmlin/usage-vtpm.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<secret ephemeral='no' private='yes'>
|
||||||
|
<uuid>aa6c7af2-45a7-477c-85a2-fe86d9f2514e</uuid>
|
||||||
|
<description>vTPM secret</description>
|
||||||
|
<usage type='vtpm'>
|
||||||
|
<name>vTPMvTPMvTPM</name>
|
||||||
|
</usage>
|
||||||
|
</secret>
|
@ -80,6 +80,7 @@ mymain(void)
|
|||||||
DO_TEST("usage-ceph");
|
DO_TEST("usage-ceph");
|
||||||
DO_TEST("usage-iscsi");
|
DO_TEST("usage-iscsi");
|
||||||
DO_TEST("usage-tls");
|
DO_TEST("usage-tls");
|
||||||
|
DO_TEST("usage-vtpm");
|
||||||
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user