render / rpms / libvirt

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