ret = -EINVAL;
goto exit;
}
- bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, NULL);
+ ret = bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF,
+ NULL);
+ if (ret < 0) {
+ goto exit;
+ }
}
}
qemu_vfree(desc_entries);
desc_entries = NULL;
}
- bdrv_flush(bs);
+ ret = bdrv_flush(bs);
+ if (ret < 0) {
+ goto exit;
+ }
/* once the log is fully flushed, indicate that we have an empty log
* now. This also sets the log guid to 0, to indicate an empty log */
vhdx_log_reset(bs, s);
}
sector_offset = offset % VHDX_LOG_SECTOR_SIZE;
- file_offset = (offset / VHDX_LOG_SECTOR_SIZE) * VHDX_LOG_SECTOR_SIZE;
+ file_offset = QEMU_ALIGN_DOWN(offset, VHDX_LOG_SECTOR_SIZE);
aligned_length = length;
/* Make sure data written (new and/or changed blocks) is stable
* on disk, before creating log entry */
- bdrv_flush(bs);
+ ret = bdrv_flush(bs);
+ if (ret < 0) {
+ goto exit;
+ }
+
ret = vhdx_log_write(bs, s, data, length, offset);
if (ret < 0) {
goto exit;
logs.log = s->log;
/* Make sure log is stable on disk */
- bdrv_flush(bs);
+ ret = bdrv_flush(bs);
+ if (ret < 0) {
+ goto exit;
+ }
+
ret = vhdx_log_flush(bs, s, &logs);
if (ret < 0) {
goto exit;