]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Store 'diskElementAuth' and 'diskElementEnc' properties in status XML
authorPeter Krempa <pkrempa@redhat.com>
Thu, 7 May 2020 13:01:54 +0000 (15:01 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 May 2020 04:55:00 +0000 (06:55 +0200)
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>
src/conf/domain_conf.c
tests/qemustatusxml2xmldata/modern-in.xml

index 84eadb56593f6b3d2c902106d97352be71958f6e..c201fc901d9f99790428dca31aff626a43e472f0 100644 (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;
index cb56cdcef945efc17ce258b91bec8e600e1d5ba8..64d42200e42b6dab93af054dacd7ee42a4d46848 100644 (file)
       <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'/>
             <nodename type='copyOnRead' name='cor-node'/>
           </nodenames>
         </privateData>
+        <diskSecretsPlacement auth='true'/>
       </disk>
       <disk type='file' device='cdrom'>
         <driver name='qemu' type='raw'/>