From: Peter Krempa Date: Thu, 7 May 2020 13:01:54 +0000 (+0200) Subject: conf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML X-Git-Tag: v6.4.0-rc1~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe12fb4132c48da4223b9cf74465b6358586ebcc;p=thirdparty%2Flibvirt.git conf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML Remember the preferred placement of and for a disk source across libvirtd restarts. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- 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, "\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 @@ /usr/bin/qemu-system-x86_64 + + + @@ -348,6 +351,7 @@ +