conf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML

Remember the preferred placement of <auth> and <encryption> for a disk
source across libvirtd restarts.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-05-07 15:01:54 +02:00
parent 6bde2a1e20
commit fe12fb4132
2 changed files with 24 additions and 0 deletions

View File

@ -10593,6 +10593,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
} else if (virXMLNodeNameEqual(cur, "boot")) {
/* boot is parsed as part of virDomainDeviceInfoParseXML */
} else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
virXMLNodeNameEqual(cur, "diskSecretsPlacement")) {
g_autofree char *secretAuth = virXMLPropString(cur, "auth");
g_autofree char *secretEnc = virXMLPropString(cur, "enc");
def->diskElementAuth = !!secretAuth;
def->diskElementEnc = !!secretEnc;
}
}
@ -25485,6 +25492,19 @@ virDomainDiskDefFormat(virBufferPtr buf,
if (virDomainDiskDefFormatPrivateData(buf, def, flags, xmlopt) < 0)
return -1;
/* format diskElementAuth and diskElementEnc into status XML to preserve
* formatting */
if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) {
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
if (def->diskElementAuth)
virBufferAddLit(&attrBuf, " auth='true'");
if (def->diskElementEnc)
virBufferAddLit(&attrBuf, " enc='true'");
virXMLFormatElement(buf, "diskSecretsPlacement", &attrBuf, NULL);
}
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</disk>\n");
return 0;

View File

@ -308,6 +308,9 @@
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' discard='unmap' detect_zeroes='on'/>
<auth username='testuser'>
<secret type='iscsi' usage='libvirtiscsi'/>
</auth>
<source file='/var/lib/libvirt/images/a.qcow2'/>
<backingStore type='file' index='1'>
<format type='qcow2'/>
@ -348,6 +351,7 @@
<nodename type='copyOnRead' name='cor-node'/>
</nodenames>
</privateData>
<diskSecretsPlacement auth='true'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>