[libvirt] ESX [10/12]: Replace esxUtil_EqualSuffix() with virFileHasSuffix()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* src/esx/esx_util.[ch]: remove esxUtil_EqualSuffix()
* src/esx/esx_driver.c, src/esx/esx_vmx.c: replace esxUtil_EqualSuffix() with
  virFileHasSuffix()
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 9c9045e..5a93d1f 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2690,7 +2690,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
         goto failure;
     }
 
-    if (! esxUtil_EqualSuffix(fileName, ".vmdk")) {
+    if (! virFileHasSuffix(fileName, ".vmdk")) {
         ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
                   "Expecting source of first disk '%s' to be a VMDK image",
                   def->disks[0]->src);
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 67bbcb8..3e53921 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -585,17 +585,3 @@ esxUtil_GetConfigBoolean(virConnectPtr conn, virConfPtr conf,
 
     return 0;
 }
-
-
-
-int
-esxUtil_EqualSuffix(const char *string, const char *suffix)
-{
-    int difference = (int)strlen(string) - (int)strlen(suffix);
-
-    if (difference < 0) {
-        return -1;
-    } else {
-        return STRCASEEQ(string + difference, suffix);
-    }
-}
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index 8e3f039..c466b44 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -61,6 +61,4 @@ int esxUtil_GetConfigBoolean(virConnectPtr conn, virConfPtr conf,
                              const char *name, int *boolean_, int default_,
                              int optional);
 
-int esxUtil_EqualSuffix(const char *string, const char *suffix);
-
 #endif /* __ESX_UTIL_H__ */
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index f9595f4..c98b847 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -982,7 +982,7 @@ esxVMX_ParseConfig(virConnectPtr conn, esxVI_Context *ctx, const char *vmx,
         goto failure;
     }
 
-    if (guestOS != NULL && esxUtil_EqualSuffix(guestOS, "-64")) {
+    if (guestOS != NULL && virFileHasSuffix(guestOS, "-64")) {
         def->os.arch = strdup("x86_64");
     } else {
         def->os.arch = strdup("i686");
@@ -1488,7 +1488,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 
     /* Setup virDomainDiskDef */
     if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
-        if (esxUtil_EqualSuffix(fileName, ".vmdk")) {
+        if (virFileHasSuffix(fileName, ".vmdk")) {
             if (deviceType != NULL) {
                 if (bus == VIR_DOMAIN_DISK_BUS_SCSI &&
                     STRCASENEQ(deviceType, "scsi-hardDisk")) {
@@ -1524,7 +1524,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
             if ((*def)->src == NULL) {
                 goto failure;
             }
-        } else if (esxUtil_EqualSuffix(fileName, ".iso") ||
+        } else if (virFileHasSuffix(fileName, ".iso") ||
                    STREQ(deviceType, "atapi-cdrom")) {
             /*
              * This function was called in order to parse a harddisk device,
@@ -1540,7 +1540,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
             goto failure;
         }
     } else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
-        if (esxUtil_EqualSuffix(fileName, ".iso")) {
+        if (virFileHasSuffix(fileName, ".iso")) {
             if (deviceType != NULL) {
                 if (STRCASENEQ(deviceType, "cdrom-image")) {
                     ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
@@ -1557,7 +1557,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
             if ((*def)->src == NULL) {
                 goto failure;
             }
-        } else if (esxUtil_EqualSuffix(fileName, ".vmdk")) {
+        } else if (virFileHasSuffix(fileName, ".vmdk")) {
             /*
              * This function was called in order to parse a CDROM device, but
              * .vmdk files are for harddisk devices only. Just ignore it,
@@ -1577,7 +1577,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
             goto failure;
         }
     } else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
-        if (esxUtil_EqualSuffix(fileName, ".flp")) {
+        if (virFileHasSuffix(fileName, ".flp")) {
             if (fileType != NULL) {
                 if (STRCASENEQ(fileType, "file")) {
                     ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
@@ -2444,7 +2444,7 @@ esxVMX_FormatHardDisk(virConnectPtr conn, esxVI_Context *ctx,
                       entryPrefix, controller, id, deviceTypePrefix);
 
     if (def->src != NULL) {
-        if (! esxUtil_EqualSuffix(def->src, ".vmdk")) {
+        if (! virFileHasSuffix(def->src, ".vmdk")) {
             ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
                       "Image file for %s harddisk '%s' has unsupported suffix, "
                       "expecting '.vmdk'", busName, def->dst);
@@ -2526,7 +2526,7 @@ esxVMX_FormatCDROM(virConnectPtr conn, esxVI_Context *ctx,
                           entryPrefix, controller, id);
 
         if (def->src != NULL) {
-            if (! esxUtil_EqualSuffix(def->src, ".iso")) {
+            if (! virFileHasSuffix(def->src, ".iso")) {
                 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
                           "Image file for %s cdrom '%s' has unsupported "
                           "suffix, expecting '.iso'", busName, def->dst);
@@ -2590,7 +2590,7 @@ esxVMX_FormatFloppy(virConnectPtr conn, esxVI_Context *ctx,
                           controller);
 
         if (def->src != NULL) {
-            if (! esxUtil_EqualSuffix(def->src, ".flp")) {
+            if (! virFileHasSuffix(def->src, ".flp")) {
                 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
                           "Image file for floppy '%s' has unsupported suffix, "
                           "expecting '.flp'", def->dst);
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]