libvirt/SOURCES/libvirt-vmx-shortcut-earlier-few-ignore-cases-in-virVMXParseDisk.patch
2021-09-10 11:58:15 +00:00

110 lines
5.0 KiB
Diff

From e8bd352038f46facdb4891d4df109a3c6351479c Mon Sep 17 00:00:00 2001
Message-Id: <e8bd352038f46facdb4891d4df109a3c6351479c@dist-git>
From: Pino Toscano <ptoscano@redhat.com>
Date: Fri, 20 Mar 2020 13:25:38 +0100
Subject: [PATCH] vmx: shortcut earlier few 'ignore' cases in virVMXParseDisk()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
https://bugzilla.redhat.com/show_bug.cgi?id=1808610
(cherry picked from commit 9a469c0d358bf3fd4b4e55b20360620d6fda44b5)
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Message-Id: <20200320122539.141785-2-ptoscano@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/vmx/vmx.c | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 4362da6cee..fc4fa1c22b 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2217,7 +2217,21 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
/* Setup virDomainDiskDef */
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;
if (deviceType != NULL) {
@@ -2253,20 +2267,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
if (mode)
(*def)->transient = STRCASEEQ(mode,
"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 {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' "
@@ -2276,7 +2276,15 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
goto cleanup;
}
} 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;
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
@@ -2294,14 +2302,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
goto cleanup;
}
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")) {
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
--
2.25.1