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

[libvirt] [vmware] Fix VMware driver version checking on Linux



> Daniel

Excellent point, Daniel. Try two is below. The verbuf string is tokenized on
newline, then iterated over with blank lines ignored. First match of the
VMware driver pattern will break out of the loop with tmp set correctly or
the default NULL if it's not found. This should allow vmwareExtractVersion
to work as expected without change and VMware Fusion/Player/Workstation to
continue working on OS X and Linux.

Tested successfully with VMware Player 5.0.3 and 6.0.1 on an SL6 box. Would
appreciate a Fusion test on OS X if possible.

  -r

(sorry if this reply shows up incorrectly, my git skills are... lacking.)


diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index c96bd62..1f5b4ae 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -222,8 +222,10 @@ vmwareSetSentinal(const char **prog, const char *key)
 int
 vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
 {
+    int tok;
     const char *pattern;
-    const char *tmp;
+    const char *tmp = NULL;
+    char **verbuftok = NULL;
 
     switch (type) {
         case VMWARE_DRIVER_PLAYER:
@@ -241,7 +243,18 @@ vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
             return -1;
     }
 
-    if ((tmp = STRSKIP(verbuf, pattern)) == NULL) {
+    verbuftok = virStringSplit(verbuf, "\n", 0);
+    for(tok = 0; verbuftok[tok] != NULL; tok++){
+        if (strlen(verbuftok[tok]) > 0) {
+            tmp = STRSKIP(verbuftok[tok], pattern);
+            if (tmp == NULL)
+                continue;
+            else
+                break;
+        }
+    }
+
+    if (tmp == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to parse %sversion"), pattern);
         return -1;


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