]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: storage: Don't emit empty <permissions> block
authorCole Robinson <crobinso@redhat.com>
Thu, 21 May 2015 19:15:24 +0000 (15:15 -0400)
committerCole Robinson <crobinso@redhat.com>
Tue, 26 May 2015 00:52:57 +0000 (20:52 -0400)
src/conf/storage_conf.c
tests/storagepoolxml2xmlout/pool-netfs-gluster.xml
tests/storagevolxml2xmlout/vol-gluster-dir.xml
tests/storagevolxml2xmlout/vol-sheepdog.xml

index a02e50409aacfbbe759704471a9790e68e1d6c98..7857a5ee63d160b0adc741572db17ba5c80f0706 100644 (file)
@@ -1179,22 +1179,28 @@ virStoragePoolDefFormatBuf(virBufferPtr buf,
 
         virBufferEscapeString(buf, "<path>%s</path>\n", def->target.path);
 
-        virBufferAddLit(buf, "<permissions>\n");
-        virBufferAdjustIndent(buf, 2);
-        if (def->target.perms.mode != (mode_t) -1)
-            virBufferAsprintf(buf, "<mode>0%o</mode>\n",
-                              def->target.perms.mode);
-        if (def->target.perms.uid != (uid_t) -1)
-            virBufferAsprintf(buf, "<owner>%d</owner>\n",
-                              (int) def->target.perms.uid);
-        if (def->target.perms.gid != (gid_t) -1)
-            virBufferAsprintf(buf, "<group>%d</group>\n",
-                              (int) def->target.perms.gid);
-        virBufferEscapeString(buf, "<label>%s</label>\n",
-                              def->target.perms.label);
+        if (def->target.perms.mode != (mode_t) -1 ||
+            def->target.perms.uid != (uid_t) -1 ||
+            def->target.perms.gid != (gid_t) -1 ||
+            def->target.perms.label) {
+            virBufferAddLit(buf, "<permissions>\n");
+            virBufferAdjustIndent(buf, 2);
+            if (def->target.perms.mode != (mode_t) -1)
+                virBufferAsprintf(buf, "<mode>0%o</mode>\n",
+                                  def->target.perms.mode);
+            if (def->target.perms.uid != (uid_t) -1)
+                virBufferAsprintf(buf, "<owner>%d</owner>\n",
+                                  (int) def->target.perms.uid);
+            if (def->target.perms.gid != (gid_t) -1)
+                virBufferAsprintf(buf, "<group>%d</group>\n",
+                                  (int) def->target.perms.gid);
+            virBufferEscapeString(buf, "<label>%s</label>\n",
+                                  def->target.perms.label);
+
+            virBufferAdjustIndent(buf, -2);
+            virBufferAddLit(buf, "</permissions>\n");
+        }
 
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf, "</permissions>\n");
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</target>\n");
     }
@@ -1513,7 +1519,11 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
         virBufferAsprintf(buf, "<format type='%s'/>\n", format);
     }
 
-    if (def->perms) {
+    if (def->perms &&
+        (def->perms->mode != (mode_t) -1 ||
+         def->perms->uid != (uid_t) -1 ||
+         def->perms->gid != (gid_t) -1 ||
+         def->perms->label)) {
         virBufferAddLit(buf, "<permissions>\n");
         virBufferAdjustIndent(buf, 2);
 
index 9e36cb6ce925d746e0123eaec3e6a720733f7fe8..dd7ffb59d07e67a6fa867254341c16d6e410ac8d 100644 (file)
@@ -11,7 +11,5 @@
   </source>
   <target>
     <path>/mnt/gluster</path>
-    <permissions>
-    </permissions>
   </target>
 </pool>
index 37400b980a32a25bcad720966c2a9aeeebc45ebd..d4222489ec80c6065eefa33578f2d7218c2f316b 100644 (file)
@@ -8,7 +8,5 @@
   <target>
     <path>gluster://example.com/vol/dir</path>
     <format type='dir'/>
-    <permissions>
-    </permissions>
   </target>
 </volume>
index fe1879fd2f208ecdefb31dfd4b9f6fc41f9a397f..e1d6a9e27d1e02221c6ff30cf670a0947de62706 100644 (file)
@@ -7,7 +7,5 @@
   <target>
     <path>sheepdog:test2</path>
     <format type='unknown'/>
-    <permissions>
-    </permissions>
   </target>
 </volume>