qemu: domain: Format storage source node names into private data

Save and restore node names if we know them or when we will be
generating them in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Peter Krempa 2018-03-01 18:39:45 +01:00
parent 3817fa10c4
commit 38fd7aec33
2 changed files with 16 additions and 0 deletions

View File

@ -1937,6 +1937,9 @@ static int
qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
virStorageSourcePtr src)
{
src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
return -1;
@ -1948,6 +1951,15 @@ static int
qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virBufferPtr buf)
{
if (src->nodestorage || src->nodeformat) {
virBufferAddLit(buf, "<nodenames>\n");
virBufferAdjustIndent(buf, 2);
virBufferEscapeString(buf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
virBufferEscapeString(buf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</nodenames>\n");
}
if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0)
return -1;

View File

@ -309,6 +309,10 @@
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/base.qcow2'>
<privateData>
<nodenames>
<nodename type='storage' name='test-storage'/>
<nodename type='format' name='test-format'/>
</nodenames>
<relPath>base.qcow2</relPath>
</privateData>
</source>