*/
if (!disk->src->backingStore) {
bool probe = ctl->allowDiskFormatProbing;
- virStorageFileGetMetadata(disk->src, -1, -1, probe);
+ virStorageFileGetMetadata(disk->src, -1, -1, probe, false);
}
/* XXX passing ignoreOpenFailure = true to get back to the behavior
virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
uid_t uid, gid_t gid,
bool allow_probe,
+ bool report_broken,
virHashTablePtr cycle)
{
int ret = -1;
else
backingStore->format = backingFormat;
- if (virStorageFileGetMetadataRecurse(backingStore,
- uid, gid, allow_probe,
- cycle) < 0) {
+ if ((ret = virStorageFileGetMetadataRecurse(backingStore,
+ uid, gid,
+ allow_probe, report_broken,
+ cycle)) < 0) {
+ if (report_broken)
+ goto cleanup;
+
/* if we fail somewhere midway, just accept and return a
* broken chain */
ret = 0;
* format, since a malicious guest can turn a raw file into any
* other non-raw format at will.
*
+ * If @report_broken is true, the whole function fails with a possibly sane
+ * error instead of just returning a broken chain.
+ *
* Caller MUST free result after use via virStorageSourceFree.
*/
int
virStorageFileGetMetadata(virStorageSourcePtr src,
uid_t uid, gid_t gid,
- bool allow_probe)
+ bool allow_probe,
+ bool report_broken)
{
- VIR_DEBUG("path=%s format=%d uid=%d gid=%d probe=%d",
- src->path, src->format, (int)uid, (int)gid, allow_probe);
+ VIR_DEBUG("path=%s format=%d uid=%d gid=%d probe=%d, report_broken=%d",
+ src->path, src->format, (int)uid, (int)gid,
+ allow_probe, report_broken);
virHashTablePtr cycle = NULL;
int ret = -1;
src->format = allow_probe ? VIR_STORAGE_FILE_AUTO : VIR_STORAGE_FILE_RAW;
ret = virStorageFileGetMetadataRecurse(src, uid, gid,
- allow_probe, cycle);
+ allow_probe, report_broken, cycle);
virHashFree(cycle);
return ret;
if (VIR_STRDUP(ret->path, path) < 0)
goto error;
- if (virStorageFileGetMetadata(ret, uid, gid, allow_probe) < 0)
+ if (virStorageFileGetMetadata(ret, uid, gid, allow_probe, false) < 0)
goto error;
return ret;