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.
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;
{
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));