diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9ac5975ed8..aa2965833f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1423,22 +1423,24 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferAsprintf(buf, "\n", format);
}
- virBufferAddLit(buf, "\n");
- virBufferAdjustIndent(buf, 2);
+ if (def->perms) {
+ virBufferAddLit(buf, "\n");
+ virBufferAdjustIndent(buf, 2);
- virBufferAsprintf(buf, "0%o\n",
- def->perms->mode);
- virBufferAsprintf(buf, "%u\n",
- (unsigned int) def->perms->uid);
- virBufferAsprintf(buf, "%u\n",
- (unsigned int) def->perms->gid);
+ virBufferAsprintf(buf, "0%o\n",
+ def->perms->mode);
+ virBufferAsprintf(buf, "%u\n",
+ (unsigned int) def->perms->uid);
+ virBufferAsprintf(buf, "%u\n",
+ (unsigned int) def->perms->gid);
- virBufferEscapeString(buf, "\n",
- def->perms->label);
+ virBufferEscapeString(buf, "\n",
+ def->perms->label);
- virBufferAdjustIndent(buf, -2);
- virBufferAddLit(buf, "\n");
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "\n");
+ }
if (def->timestamps) {
virBufferAddLit(buf, "\n");