qemu: domain: Store and restore TLS object alias of a disk

Libvirt uses the stored alias to detach the TLS x509 object on disk
unplug. As the alias was not stored, the object would not be detached
if unplugging disks after libvirtd restart.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-05-30 12:03:41 +02:00
parent 5e8218fad7
commit 1f1aa21cb9
2 changed files with 5 additions and 0 deletions

View File

@ -2023,6 +2023,7 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
src->tlsAlias = virXPathString("string(./objects/TLSx509/@alias)", ctxt);
if (src->pr)
src->pr->mgralias = virXPathString("string(./reservations/@mgralias)", ctxt);
@ -2102,6 +2103,9 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
qemuStorageSourcePrivateDataFormatSecinfo(&tmp, srcPriv->encinfo, "encryption");
}
if (src->tlsAlias)
virBufferAsprintf(&tmp, "<TLSx509 alias='%s'/>\n", src->tlsAlias);
if (virXMLFormatElement(buf, "objects", NULL, &tmp) < 0)
goto cleanup;

View File

@ -322,6 +322,7 @@
<objects>
<secret type='auth' alias='test-auth-alias'/>
<secret type='encryption' alias='test-encryption-alias'/>
<TLSx509 alias='transport-alias'/>
</objects>
</privateData>
</source>