diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 6243d1e9b2bc352287279a28d5111e5494dc8f4c..889f5305cc430eee601bc8909226d41c52bbbd7e 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -208,6 +208,14 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, } while ((amtleft -= interval) > 0); } + if (fdatasync(fd) < 0) { + ret = -errno; + virReportSystemError(errno, _("cannot sync data to file '%s'"), + vol->target.path); + goto cleanup; + } + + if (VIR_CLOSE(inputfd) < 0) { ret = -errno; virReportSystemError(errno, diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index c622d2a3b32123965de049cece9e0b1268f49ba2..ca4166da2b4d162542c1e1e7af63671ee4bf81b4 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -424,6 +424,13 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_FORCE_CLOSE(fd); goto cleanup; } + if (fsync(fd) < 0) { + virReportSystemError(errno, + _("cannot flush header of device'%s'"), + pool->def->source.devices[i].path); + VIR_FORCE_CLOSE(fd); + goto cleanup; + } if (VIR_CLOSE(fd) < 0) { virReportSystemError(errno, _("cannot close device '%s'"), diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 6715790a6f99dd6ddc43c99e753b41c188f06f48..68cac1fc474b03fcf49ee140be3eab4c4dcdec46 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1777,6 +1777,14 @@ storageWipeExtent(virStorageVolDefPtr vol, remaining -= written; } + if (fdatasync(fd) < 0) { + ret = -errno; + virReportSystemError(errno, + _("cannot sync data to volume with path '%s'"), + vol->target.path); + goto out; + } + VIR_DEBUG("Wrote %zu bytes to volume with path '%s'", *bytes_wiped, vol->target.path);