if (VIR_STRDUP(ret->relPath, path) < 0)
goto error;
- if (virStorageIsFile(path)) {
- if (!(ret->path = canonicalize_file_name(path))) {
- virReportSystemError(errno, _("unable to resolve '%s'"), path);
- goto error;
- }
- } else {
- if (VIR_STRDUP(ret->path, path) < 0)
- goto error;
- }
+ if (VIR_STRDUP(ret->path, path) < 0)
+ goto error;
return ret;
{
virStorageSourcePtr ret = NULL;
+ char *canonPath = NULL;
+
+ if (!(canonPath = canonicalize_file_name(path))) {
+ virReportSystemError(errno, _("unable to resolve '%s'"), path);
+ goto cleanup;
+ }
- if (!(ret = virStorageFileMetadataNew(path, format)))
+ if (!(ret = virStorageFileMetadataNew(canonPath, format)))
goto cleanup;
+
if (virStorageFileGetMetadataFromFDInternal(ret, fd, backingFormat) < 0) {
virStorageSourceFree(ret);
ret = NULL;
}
cleanup:
+ VIR_FREE(canonPath);
return ret;
}