mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
152be66eaf
commit
eb07c7e563
|
@ -128,7 +128,8 @@ esxFreePrivate(esxPrivate **priv)
|
||||||
static int
|
static int
|
||||||
esxParseVMXFileName(const char *fileName,
|
esxParseVMXFileName(const char *fileName,
|
||||||
void *opaque,
|
void *opaque,
|
||||||
char **out)
|
char **out,
|
||||||
|
bool allow_missing G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
esxVMX_Data *data = opaque;
|
esxVMX_Data *data = opaque;
|
||||||
esxVI_String *propertyNameList = NULL;
|
esxVI_String *propertyNameList = NULL;
|
||||||
|
|
|
@ -510,7 +510,8 @@ vmwareExtractPid(const char * vmxPath)
|
||||||
int
|
int
|
||||||
vmwareParseVMXFileName(const char *datastorePath,
|
vmwareParseVMXFileName(const char *datastorePath,
|
||||||
void *opaque G_GNUC_UNUSED,
|
void *opaque G_GNUC_UNUSED,
|
||||||
char **out)
|
char **out,
|
||||||
|
bool allow_missing G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
*out = g_strdup(datastorePath);
|
*out = g_strdup(datastorePath);
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ int vmwareExtractPid(const char * vmxPath);
|
||||||
int
|
int
|
||||||
vmwareParseVMXFileName(const char *datastorePath,
|
vmwareParseVMXFileName(const char *datastorePath,
|
||||||
void *opaque,
|
void *opaque,
|
||||||
char **out);
|
char **out,
|
||||||
|
bool allow_missing);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
vmwareFormatVMXFileName(const char *datastorePath,
|
vmwareFormatVMXFileName(const char *datastorePath,
|
||||||
|
|
|
@ -2411,7 +2411,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
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;
|
goto cleanup;
|
||||||
virDomainDiskSetSource(*def, tmp);
|
virDomainDiskSetSource(*def, tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
|
@ -2448,7 +2448,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
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;
|
goto cleanup;
|
||||||
virDomainDiskSetSource(*def, tmp);
|
virDomainDiskSetSource(*def, tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
|
@ -2515,7 +2515,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
||||||
|
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
||||||
if (fileName &&
|
if (fileName &&
|
||||||
ctx->parseFileName(fileName, ctx->opaque, &tmp) < 0)
|
ctx->parseFileName(fileName, ctx->opaque, &tmp, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
virDomainDiskSetSource(*def, tmp);
|
virDomainDiskSetSource(*def, tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
|
@ -2977,7 +2977,8 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
||||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
||||||
if (ctx->parseFileName(fileName,
|
if (ctx->parseFileName(fileName,
|
||||||
ctx->opaque,
|
ctx->opaque,
|
||||||
&(*def)->source->data.file.path) < 0)
|
&(*def)->source->data.file.path,
|
||||||
|
false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (STRCASEEQ(fileType, "pipe")) {
|
} else if (STRCASEEQ(fileType, "pipe")) {
|
||||||
/*
|
/*
|
||||||
|
@ -3142,7 +3143,8 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
||||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
||||||
if (ctx->parseFileName(fileName,
|
if (ctx->parseFileName(fileName,
|
||||||
ctx->opaque,
|
ctx->opaque,
|
||||||
&(*def)->source->data.file.path) < 0)
|
&(*def)->source->data.file.path,
|
||||||
|
false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
|
|
@ -36,7 +36,10 @@ virDomainXMLOptionPtr virVMXDomainXMLConfInit(virCapsPtr caps);
|
||||||
* Context
|
* 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 char * (*virVMXFormatFileName)(const char *src, void *opaque);
|
||||||
typedef int (*virVMXAutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
|
typedef int (*virVMXAutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
|
||||||
int *model, void *opaque);
|
int *model, void *opaque);
|
||||||
|
|
|
@ -139,7 +139,8 @@ testCompareHelper(const void *data)
|
||||||
static int
|
static int
|
||||||
testParseVMXFileName(const char *fileName,
|
testParseVMXFileName(const char *fileName,
|
||||||
void *opaque G_GNUC_UNUSED,
|
void *opaque G_GNUC_UNUSED,
|
||||||
char **src)
|
char **src,
|
||||||
|
bool allow_missing)
|
||||||
{
|
{
|
||||||
g_autofree char *copyOfFileName = NULL;
|
g_autofree char *copyOfFileName = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
|
@ -160,6 +161,16 @@ testParseVMXFileName(const char *fileName,
|
||||||
return -1;
|
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);
|
*src = g_strdup_printf("[%s] %s", datastoreName, directoryAndFileName);
|
||||||
} else if (STRPREFIX(fileName, "/")) {
|
} else if (STRPREFIX(fileName, "/")) {
|
||||||
/* Found absolute path referencing a file outside a datastore */
|
/* Found absolute path referencing a file outside a datastore */
|
||||||
|
|
Loading…
Reference in New Issue