diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index a02e50409a..7857a5ee63 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1179,22 +1179,28 @@ virStoragePoolDefFormatBuf(virBufferPtr buf, virBufferEscapeString(buf, "%s\n", def->target.path); - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - if (def->target.perms.mode != (mode_t) -1) - virBufferAsprintf(buf, "0%o\n", - def->target.perms.mode); - if (def->target.perms.uid != (uid_t) -1) - virBufferAsprintf(buf, "%d\n", - (int) def->target.perms.uid); - if (def->target.perms.gid != (gid_t) -1) - virBufferAsprintf(buf, "%d\n", - (int) def->target.perms.gid); - virBufferEscapeString(buf, "\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, "\n"); + virBufferAdjustIndent(buf, 2); + if (def->target.perms.mode != (mode_t) -1) + virBufferAsprintf(buf, "0%o\n", + def->target.perms.mode); + if (def->target.perms.uid != (uid_t) -1) + virBufferAsprintf(buf, "%d\n", + (int) def->target.perms.uid); + if (def->target.perms.gid != (gid_t) -1) + virBufferAsprintf(buf, "%d\n", + (int) def->target.perms.gid); + virBufferEscapeString(buf, "\n", + def->target.perms.label); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } @@ -1513,7 +1519,11 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options, virBufferAsprintf(buf, "\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, "\n"); virBufferAdjustIndent(buf, 2); diff --git a/tests/storagepoolxml2xmlout/pool-netfs-gluster.xml b/tests/storagepoolxml2xmlout/pool-netfs-gluster.xml index 9e36cb6ce9..dd7ffb59d0 100644 --- a/tests/storagepoolxml2xmlout/pool-netfs-gluster.xml +++ b/tests/storagepoolxml2xmlout/pool-netfs-gluster.xml @@ -11,7 +11,5 @@ /mnt/gluster - - diff --git a/tests/storagevolxml2xmlout/vol-gluster-dir.xml b/tests/storagevolxml2xmlout/vol-gluster-dir.xml index 37400b980a..d4222489ec 100644 --- a/tests/storagevolxml2xmlout/vol-gluster-dir.xml +++ b/tests/storagevolxml2xmlout/vol-gluster-dir.xml @@ -8,7 +8,5 @@ gluster://example.com/vol/dir - - diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml b/tests/storagevolxml2xmlout/vol-sheepdog.xml index fe1879fd2f..e1d6a9e27d 100644 --- a/tests/storagevolxml2xmlout/vol-sheepdog.xml +++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml @@ -7,7 +7,5 @@ sheepdog:test2 - -