]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: create: Create files with correct mode
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 Jul 2014 14:09:39 +0000 (16:09 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 29 Jul 2014 08:45:32 +0000 (10:45 +0200)
Use correct mode when pre-creating files (for snapshots). The refactor
changing to storage driver usage caused a regression as some systems
created the file with 000 permissions forbidding qemu to write the file.

Pass mode to the creating functions to avoid the problem.

Regression since 185e07a5f82bc0692324f3ee13b4816d71b653c1.

src/storage/storage_backend_fs.c
src/storage/storage_backend_gluster.c

index 378c553f0c50088974d8e5acdebc03ba80b8e7e3..b8f907aee11fa8bfa0b79723d438b4cc2951cb59 100644 (file)
@@ -1390,8 +1390,12 @@ static int
 virStorageFileBackendFileCreate(virStorageSourcePtr src)
 {
     int fd = -1;
+    mode_t mode = S_IRUSR;
 
-    if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, 0,
+    if (!src->readonly)
+        mode |= S_IWUSR;
+
+    if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, mode,
                             src->drv->uid, src->drv->gid, 0)) < 0) {
         errno = -fd;
         return -1;
index 38d02acfa28811282a68aefac8c6c594ae21652c..8a7d7e5314bab6ea828df81bc541e04dba85e891 100644 (file)
@@ -638,8 +638,13 @@ virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
 {
     virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
     glfs_fd_t *fd = NULL;
+    mode_t mode = S_IRUSR;
 
-    if (!(fd = glfs_open(priv->vol, src->path, O_CREAT | O_TRUNC | O_WRONLY)))
+    if (!src->readonly)
+        mode |= S_IWUSR;
+
+    if (!(fd = glfs_creat(priv->vol, src->path,
+                          O_CREAT | O_TRUNC | O_WRONLY, mode)))
         return -1;
 
     ignore_value(glfs_close(fd));