render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d76c62
From e8bd352038f46facdb4891d4df109a3c6351479c Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <e8bd352038f46facdb4891d4df109a3c6351479c@dist-git>
d76c62
From: Pino Toscano <ptoscano@redhat.com>
d76c62
Date: Fri, 20 Mar 2020 13:25:38 +0100
d76c62
Subject: [PATCH] vmx: shortcut earlier few 'ignore' cases in virVMXParseDisk()
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Move earlier the checks for skipping a hard disk when parsing a CD-DROM,
d76c62
and for skipping a CD-ROM when parsing a hard disk. This should have no
d76c62
behaviour changes, and avoids to add repeated checks in following
d76c62
commits.
d76c62
d76c62
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
Tested-by: Richard W.M. Jones <rjones@redhat.com>
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1808610
d76c62
(cherry picked from commit 9a469c0d358bf3fd4b4e55b20360620d6fda44b5)
d76c62
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
d76c62
Message-Id: <20200320122539.141785-2-ptoscano@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/vmx/vmx.c | 48 ++++++++++++++++++++++++------------------------
d76c62
 1 file changed, 24 insertions(+), 24 deletions(-)
d76c62
d76c62
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
d76c62
index 4362da6cee..fc4fa1c22b 100644
d76c62
--- a/src/vmx/vmx.c
d76c62
+++ b/src/vmx/vmx.c
d76c62
@@ -2217,7 +2217,21 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
d76c62
 
d76c62
     /* Setup virDomainDiskDef */
d76c62
     if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
d76c62
-        if (virStringHasCaseSuffix(fileName, ".vmdk")) {
d76c62
+        if (virStringHasCaseSuffix(fileName, ".iso") ||
d76c62
+            STREQ(fileName, "emptyBackingString") ||
d76c62
+            (deviceType &&
d76c62
+             (STRCASEEQ(deviceType, "atapi-cdrom") ||
d76c62
+              STRCASEEQ(deviceType, "cdrom-raw") ||
d76c62
+              (STRCASEEQ(deviceType, "scsi-passthru") &&
d76c62
+               STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) {
d76c62
+            /*
d76c62
+             * This function was called in order to parse a harddisk device,
d76c62
+             * but .iso files, 'atapi-cdrom', 'cdrom-raw', and 'scsi-passthru'
d76c62
+             * CDROM devices are for CDROM devices only. Just ignore it, another
d76c62
+             * call to this function to parse a CDROM device may handle it.
d76c62
+             */
d76c62
+            goto ignore;
d76c62
+        } else if (virStringHasCaseSuffix(fileName, ".vmdk")) {
d76c62
             char *tmp;
d76c62
 
d76c62
             if (deviceType != NULL) {
d76c62
@@ -2253,20 +2267,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
d76c62
             if (mode)
d76c62
                 (*def)->transient = STRCASEEQ(mode,
d76c62
                                               "independent-nonpersistent");
d76c62
-        } else if (virStringHasCaseSuffix(fileName, ".iso") ||
d76c62
-                   STREQ(fileName, "emptyBackingString") ||
d76c62
-                   (deviceType &&
d76c62
-                    (STRCASEEQ(deviceType, "atapi-cdrom") ||
d76c62
-                     STRCASEEQ(deviceType, "cdrom-raw") ||
d76c62
-                     (STRCASEEQ(deviceType, "scsi-passthru") &&
d76c62
-                      STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) {
d76c62
-            /*
d76c62
-             * This function was called in order to parse a harddisk device,
d76c62
-             * but .iso files, 'atapi-cdrom', 'cdrom-raw', and 'scsi-passthru'
d76c62
-             * CDROM devices are for CDROM devices only. Just ignore it, another
d76c62
-             * call to this function to parse a CDROM device may handle it.
d76c62
-             */
d76c62
-            goto ignore;
d76c62
         } else {
d76c62
             virReportError(VIR_ERR_INTERNAL_ERROR,
d76c62
                            _("Invalid or not yet handled value '%s' "
d76c62
@@ -2276,7 +2276,15 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
d76c62
             goto cleanup;
d76c62
         }
d76c62
     } else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
d76c62
-        if (virStringHasCaseSuffix(fileName, ".iso")) {
d76c62
+        if (virStringHasCaseSuffix(fileName, ".vmdk")) {
d76c62
+            /*
d76c62
+             * This function was called in order to parse a CDROM device, but
d76c62
+             * .vmdk files are for harddisk devices only. Just ignore it,
d76c62
+             * another call to this function to parse a harddisk device may
d76c62
+             * handle it.
d76c62
+             */
d76c62
+            goto ignore;
d76c62
+        } else if (virStringHasCaseSuffix(fileName, ".iso")) {
d76c62
             char *tmp;
d76c62
 
d76c62
             if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
d76c62
@@ -2294,14 +2302,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
d76c62
                 goto cleanup;
d76c62
             }
d76c62
             VIR_FREE(tmp);
d76c62
-        } else if (virStringHasCaseSuffix(fileName, ".vmdk")) {
d76c62
-            /*
d76c62
-             * This function was called in order to parse a CDROM device, but
d76c62
-             * .vmdk files are for harddisk devices only. Just ignore it,
d76c62
-             * another call to this function to parse a harddisk device may
d76c62
-             * handle it.
d76c62
-             */
d76c62
-            goto ignore;
d76c62
         } else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
d76c62
             virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
d76c62
 
d76c62
-- 
d76c62
2.25.1
d76c62