Commit 731de380 authored by Max Reitz's avatar Max Reitz Committed by Kevin Wolf

block/raw-posix: Only sync after successful preallocation

The loop which filled the file with zeroes may have been left early due
to an error. In that case, the fsync() should be skipped.
Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 39411cf3
......@@ -1453,7 +1453,9 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
}
left -= result;
}
fsync(fd);
if (result >= 0) {
fsync(fd);
}
g_free(buf);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment