提交 fc60a0c7 编写于 作者: S Stefan Berger 提交者: Daniel P. Berrangé

conf: Extend TPM XML parser with encryption support

Extend the TPM device XML parser and XML generator with emulator
state encryption support.
Signed-off-by: NStefan Berger <stefanb@linux.ibm.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 84ab0206
...@@ -4317,6 +4317,7 @@ ...@@ -4317,6 +4317,7 @@
<attribute name="type"> <attribute name="type">
<value>emulator</value> <value>emulator</value>
</attribute> </attribute>
<ref name="tpm-backend-emulator-encryption"/>
</group> </group>
</choice> </choice>
<choice> <choice>
...@@ -4346,6 +4347,16 @@ ...@@ -4346,6 +4347,16 @@
</optional> </optional>
</define> </define>
<define name="tpm-backend-emulator-encryption">
<optional>
<element name="encryption">
<attribute name="secret">
<ref name="UUID"/>
</attribute>
</element>
</optional>
</define>
<define name="vsock"> <define name="vsock">
<element name="vsock"> <element name="vsock">
<optional> <optional>
......
...@@ -13049,6 +13049,14 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -13049,6 +13049,14 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt,
* <tpm model='tpm-tis'> * <tpm model='tpm-tis'>
* <backend type='emulator' version='2'/> * <backend type='emulator' version='2'/>
* </tpm> * </tpm>
*
* Emulator state encryption is supported with the following:
*
* <tpm model='tpm-tis'>
* <backend type='emulator' version='2'>
* <encryption uuid='32ee7e76-2178-47a1-ab7b-269e6e348015'/>
* </backend>
* </tpm>
*/ */
static virDomainTPMDefPtr static virDomainTPMDefPtr
virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
...@@ -13063,6 +13071,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -13063,6 +13071,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_AUTOFREE(char *) model = NULL; VIR_AUTOFREE(char *) model = NULL;
VIR_AUTOFREE(char *) backend = NULL; VIR_AUTOFREE(char *) backend = NULL;
VIR_AUTOFREE(char *) version = NULL; VIR_AUTOFREE(char *) version = NULL;
VIR_AUTOFREE(char *) secretuuid = NULL;
VIR_AUTOFREE(xmlNodePtr *) backends = NULL; VIR_AUTOFREE(xmlNodePtr *) backends = NULL;
if (VIR_ALLOC(def) < 0) if (VIR_ALLOC(def) < 0)
...@@ -13127,6 +13136,15 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -13127,6 +13136,15 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV; def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
break; break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR: case VIR_DOMAIN_TPM_TYPE_EMULATOR:
secretuuid = virXPathString("string(./backend/encryption/@secret)", ctxt);
if (secretuuid) {
if (virUUIDParse(secretuuid, def->data.emulator.secretuuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse secret uuid '%s'"), secretuuid);
goto error;
}
def->data.emulator.hassecretuuid = true;
}
break; break;
case VIR_DOMAIN_TPM_TYPE_LAST: case VIR_DOMAIN_TPM_TYPE_LAST:
goto error; goto error;
...@@ -25953,8 +25971,19 @@ virDomainTPMDefFormat(virBufferPtr buf, ...@@ -25953,8 +25971,19 @@ virDomainTPMDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "</backend>\n"); virBufferAddLit(buf, "</backend>\n");
break; break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR: case VIR_DOMAIN_TPM_TYPE_EMULATOR:
virBufferAsprintf(buf, " version='%s'/>\n", virBufferAsprintf(buf, " version='%s'",
virDomainTPMVersionTypeToString(def->version)); virDomainTPMVersionTypeToString(def->version));
if (def->data.emulator.hassecretuuid) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
virBufferAsprintf(buf, "<encryption secret='%s'/>\n",
virUUIDFormat(def->data.emulator.secretuuid, uuidstr));
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</backend>\n");
} else {
virBufferAddLit(buf, "/>\n");
}
break; break;
case VIR_DOMAIN_TPM_TYPE_LAST: case VIR_DOMAIN_TPM_TYPE_LAST:
break; break;
......
...@@ -1269,6 +1269,8 @@ struct _virDomainTPMDef { ...@@ -1269,6 +1269,8 @@ struct _virDomainTPMDef {
virDomainChrSourceDef source; virDomainChrSourceDef source;
char *storagepath; char *storagepath;
char *logfile; char *logfile;
unsigned char secretuuid[VIR_UUID_BUFLEN];
bool hassecretuuid;
} emulator; } emulator;
} data; } data;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册