[libvirt] [PATCH v2 01/29] conf: Format seclabels for <backingStore>

Peter Krempa pkrempa at redhat.com
Fri Mar 22 18:00:37 UTC 2019


We parse the seclabels and use them internally so omitting them when
formatting would be misleading. Additionally our schema actually allows
them.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c                                    | 3 +--
 tests/qemuxml2argvdata/disk-backing-chains.xml            | 6 +++++-
 tests/qemuxml2xmloutdata/disk-backing-chains-active.xml   | 6 +++++-
 tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml | 6 +++++-
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9d8eabb42a..87db233d9f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23876,8 +23876,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, 2);

     virBufferAsprintf(buf, "<format type='%s'/>\n", format);
-    /* We currently don't output seclabels for backing chain element */
-    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, false,
+    if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, flags, true,
                                           false, xmlopt) < 0 ||
         virDomainDiskBackingStoreFormat(buf, backingStore->backingStore,
                                         xmlopt, flags) < 0)
diff --git a/tests/qemuxml2argvdata/disk-backing-chains.xml b/tests/qemuxml2argvdata/disk-backing-chains.xml
index 703c60c439..2eaafb34e7 100644
--- a/tests/qemuxml2argvdata/disk-backing-chains.xml
+++ b/tests/qemuxml2argvdata/disk-backing-chains.xml
@@ -38,7 +38,11 @@
           <source file='/tmp/image2.qcow'/>
           <backingStore type='file' index='3'>
             <format type='qcow2'/>
-            <source file='/tmp/image3.qcow'/>
+            <source file='/tmp/image3.qcow'>
+              <seclabel model='selinux' relabel='yes'>
+                <label>system_u:system_r:public_content_t:s0</label>
+              </seclabel>
+            </source>
             <backingStore type='file' index='4'>
               <format type='qcow2'/>
               <source file='/tmp/image4.qcow'/>
diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-active.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-active.xml
index d1fd2442c3..e24956f106 100644
--- a/tests/qemuxml2xmloutdata/disk-backing-chains-active.xml
+++ b/tests/qemuxml2xmloutdata/disk-backing-chains-active.xml
@@ -39,7 +39,11 @@
           <source file='/tmp/image2.qcow'/>
           <backingStore type='file' index='3'>
             <format type='qcow2'/>
-            <source file='/tmp/image3.qcow'/>
+            <source file='/tmp/image3.qcow'>
+              <seclabel model='selinux' relabel='yes'>
+                <label>system_u:system_r:public_content_t:s0</label>
+              </seclabel>
+            </source>
             <backingStore type='file' index='4'>
               <format type='qcow2'/>
               <source file='/tmp/image4.qcow'/>
diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml
index c1af58ff6f..e39e218873 100644
--- a/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml
+++ b/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml
@@ -39,7 +39,11 @@
           <source file='/tmp/image2.qcow'/>
           <backingStore type='file'>
             <format type='qcow2'/>
-            <source file='/tmp/image3.qcow'/>
+            <source file='/tmp/image3.qcow'>
+              <seclabel model='selinux' relabel='yes'>
+                <label>system_u:system_r:public_content_t:s0</label>
+              </seclabel>
+            </source>
             <backingStore type='file'>
               <format type='qcow2'/>
               <source file='/tmp/image4.qcow'/>
-- 
2.20.1




More information about the libvir-list mailing list