mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vmx: shortcut earlier few 'ignore' cases in virVMXParseDisk()
Move earlier the checks for skipping a hard disk when parsing a CD-DROM, and for skipping a CD-ROM when parsing a hard disk. This should have no behaviour changes, and avoids to add repeated checks in following commits. Signed-off-by: Pino Toscano <ptoscano@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Tested-by: Richard W.M. Jones <rjones@redhat.com>
This commit is contained in:
parent
64ed4d00c4
commit
9a469c0d35
@ -2218,7 +2218,21 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
|
|
||||||
/* Setup virDomainDiskDef */
|
/* Setup virDomainDiskDef */
|
||||||
if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
||||||
if (virStringHasCaseSuffix(fileName, ".vmdk")) {
|
if (virStringHasCaseSuffix(fileName, ".iso") ||
|
||||||
|
STREQ(fileName, "emptyBackingString") ||
|
||||||
|
(deviceType &&
|
||||||
|
(STRCASEEQ(deviceType, "atapi-cdrom") ||
|
||||||
|
STRCASEEQ(deviceType, "cdrom-raw") ||
|
||||||
|
(STRCASEEQ(deviceType, "scsi-passthru") &&
|
||||||
|
STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) {
|
||||||
|
/*
|
||||||
|
* This function was called in order to parse a harddisk device,
|
||||||
|
* but .iso files, 'atapi-cdrom', 'cdrom-raw', and 'scsi-passthru'
|
||||||
|
* CDROM devices are for CDROM devices only. Just ignore it, another
|
||||||
|
* call to this function to parse a CDROM device may handle it.
|
||||||
|
*/
|
||||||
|
goto ignore;
|
||||||
|
} else if (virStringHasCaseSuffix(fileName, ".vmdk")) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (deviceType != NULL) {
|
if (deviceType != NULL) {
|
||||||
@ -2254,20 +2268,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
if (mode)
|
if (mode)
|
||||||
(*def)->transient = STRCASEEQ(mode,
|
(*def)->transient = STRCASEEQ(mode,
|
||||||
"independent-nonpersistent");
|
"independent-nonpersistent");
|
||||||
} else if (virStringHasCaseSuffix(fileName, ".iso") ||
|
|
||||||
STREQ(fileName, "emptyBackingString") ||
|
|
||||||
(deviceType &&
|
|
||||||
(STRCASEEQ(deviceType, "atapi-cdrom") ||
|
|
||||||
STRCASEEQ(deviceType, "cdrom-raw") ||
|
|
||||||
(STRCASEEQ(deviceType, "scsi-passthru") &&
|
|
||||||
STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) {
|
|
||||||
/*
|
|
||||||
* This function was called in order to parse a harddisk device,
|
|
||||||
* but .iso files, 'atapi-cdrom', 'cdrom-raw', and 'scsi-passthru'
|
|
||||||
* CDROM devices are for CDROM devices only. Just ignore it, another
|
|
||||||
* call to this function to parse a CDROM device may handle it.
|
|
||||||
*/
|
|
||||||
goto ignore;
|
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invalid or not yet handled value '%s' "
|
_("Invalid or not yet handled value '%s' "
|
||||||
@ -2277,7 +2277,15 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
} else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
||||||
if (virStringHasCaseSuffix(fileName, ".iso")) {
|
if (virStringHasCaseSuffix(fileName, ".vmdk")) {
|
||||||
|
/*
|
||||||
|
* This function was called in order to parse a CDROM device, but
|
||||||
|
* .vmdk files are for harddisk devices only. Just ignore it,
|
||||||
|
* another call to this function to parse a harddisk device may
|
||||||
|
* handle it.
|
||||||
|
*/
|
||||||
|
goto ignore;
|
||||||
|
} else if (virStringHasCaseSuffix(fileName, ".iso")) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
||||||
@ -2295,14 +2303,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
} else if (virStringHasCaseSuffix(fileName, ".vmdk")) {
|
|
||||||
/*
|
|
||||||
* This function was called in order to parse a CDROM device, but
|
|
||||||
* .vmdk files are for harddisk devices only. Just ignore it,
|
|
||||||
* another call to this function to parse a harddisk device may
|
|
||||||
* handle it.
|
|
||||||
*/
|
|
||||||
goto ignore;
|
|
||||||
} else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
|
} else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
|
||||||
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user