Remember the preferred placement of <auth> and <encryption> for a disk
source across libvirtd restarts.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 20 ++++++++++++++++++++
tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++
2 files changed, 24 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 84eadb5659..c201fc901d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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;
diff --git a/tests/qemustatusxml2xmldata/modern-in.xml
b/tests/qemustatusxml2xmldata/modern-in.xml
index cb56cdcef9..64d42200e4 100644
--- a/tests/qemustatusxml2xmldata/modern-in.xml
+++ b/tests/qemustatusxml2xmldata/modern-in.xml
@@ -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'/>
--
2.26.2