}
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
- if (ctx->parseFileName(fileName, ctx->opaque, &tmp) < 0)
+ if (ctx->parseFileName(fileName, ctx->opaque, &tmp, false) < 0)
goto cleanup;
virDomainDiskSetSource(*def, tmp);
VIR_FREE(tmp);
}
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
- if (ctx->parseFileName(fileName, ctx->opaque, &tmp) < 0)
+ if (ctx->parseFileName(fileName, ctx->opaque, &tmp, false) < 0)
goto cleanup;
virDomainDiskSetSource(*def, tmp);
VIR_FREE(tmp);
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
if (fileName &&
- ctx->parseFileName(fileName, ctx->opaque, &tmp) < 0)
+ ctx->parseFileName(fileName, ctx->opaque, &tmp, false) < 0)
goto cleanup;
virDomainDiskSetSource(*def, tmp);
VIR_FREE(tmp);
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
if (ctx->parseFileName(fileName,
ctx->opaque,
- &(*def)->source->data.file.path) < 0)
+ &(*def)->source->data.file.path,
+ false) < 0)
goto cleanup;
} else if (STRCASEEQ(fileType, "pipe")) {
/*
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
if (ctx->parseFileName(fileName,
ctx->opaque,
- &(*def)->source->data.file.path) < 0)
+ &(*def)->source->data.file.path,
+ false) < 0)
goto cleanup;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
* Context
*/
-typedef int (*virVMXParseFileName)(const char *fileName, void *opaque, char **src);
+typedef int (*virVMXParseFileName)(const char *fileName,
+ void *opaque,
+ char **src,
+ bool allow_missing);
typedef char * (*virVMXFormatFileName)(const char *src, void *opaque);
typedef int (*virVMXAutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
int *model, void *opaque);
static int
testParseVMXFileName(const char *fileName,
void *opaque G_GNUC_UNUSED,
- char **src)
+ char **src,
+ bool allow_missing)
{
g_autofree char *copyOfFileName = NULL;
char *tmp = NULL;
return -1;
}
+ if (STREQ(datastoreName, "missing") ||
+ STRPREFIX(directoryAndFileName, "missing")) {
+ if (allow_missing)
+ return 0;
+
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Referenced missing file '%s'", fileName);
+ return -1;
+ }
+
*src = g_strdup_printf("[%s] %s", datastoreName, directoryAndFileName);
} else if (STRPREFIX(fileName, "/")) {
/* Found absolute path referencing a file outside a datastore */