mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
vmx: The virVMXParseDisk deviceType can be NULL, add some missing checks
This commit is contained in:
parent
8720551256
commit
7c959e0dc0
@ -2178,8 +2178,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
(*def)->transient = STRCASEEQ(mode,
|
(*def)->transient = STRCASEEQ(mode,
|
||||||
"independent-nonpersistent");
|
"independent-nonpersistent");
|
||||||
} else if (virFileHasSuffix(fileName, ".iso") ||
|
} else if (virFileHasSuffix(fileName, ".iso") ||
|
||||||
STRCASEEQ(deviceType, "atapi-cdrom") ||
|
(deviceType &&
|
||||||
STRCASEEQ(deviceType, "cdrom-raw")) {
|
(STRCASEEQ(deviceType, "atapi-cdrom") ||
|
||||||
|
STRCASEEQ(deviceType, "cdrom-raw")))) {
|
||||||
/*
|
/*
|
||||||
* This function was called in order to parse a harddisk device,
|
* This function was called in order to parse a harddisk device,
|
||||||
* but .iso files, 'atapi-cdrom', and 'cdrom-raw' devices are for
|
* but .iso files, 'atapi-cdrom', and 'cdrom-raw' devices are for
|
||||||
@ -2199,14 +2200,12 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
if (virFileHasSuffix(fileName, ".iso")) {
|
if (virFileHasSuffix(fileName, ".iso")) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (deviceType != NULL) {
|
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
||||||
if (STRCASENEQ(deviceType, "cdrom-image")) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Expecting VMX entry '%s' to be 'cdrom-image' "
|
_("Expecting VMX entry '%s' to be 'cdrom-image' "
|
||||||
"but found '%s'"), deviceType_name, deviceType);
|
"but found '%s'"), deviceType_name, deviceType);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
||||||
if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
||||||
@ -2224,7 +2223,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
* handle it.
|
* handle it.
|
||||||
*/
|
*/
|
||||||
goto ignore;
|
goto ignore;
|
||||||
} else if (STRCASEEQ(deviceType, "atapi-cdrom")) {
|
} else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
||||||
|
|
||||||
if (STRCASEEQ(fileName, "auto detect")) {
|
if (STRCASEEQ(fileName, "auto detect")) {
|
||||||
@ -2233,7 +2232,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else if (STRCASEEQ(deviceType, "cdrom-raw")) {
|
} else if (deviceType && STRCASEEQ(deviceType, "cdrom-raw")) {
|
||||||
/* Raw access CD-ROMs actually are device='lun' */
|
/* Raw access CD-ROMs actually are device='lun' */
|
||||||
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
||||||
|
Loading…
Reference in New Issue
Block a user