render / rpms / libvirt

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