vmx: Allow missing cdrom image file in virVMXParseFileName

This will be used later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander
2020-12-21 16:51:31 +01:00
parent 152be66eaf
commit eb07c7e563
6 changed files with 29 additions and 10 deletions

View File

@@ -139,7 +139,8 @@ testCompareHelper(const void *data)
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;
@@ -160,6 +161,16 @@ testParseVMXFileName(const char *fileName,
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 */