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

ryan woodsmall rwoodsmall at gmail.com
Wed Jan 22 07:58:57 UTC 2014


Below works, but it still special cases Fusion. I'm not sure it's better, but
I think the VMWARE_DRIVER_FUSION pattern string could be changed to just
"VMware Fusion " then tmp checked against "Information:" and discarded
if a match is found using the tokenized output of virStringSplit. Something
like this in the loop over the tokenized driver command check output:

**
if ((tmp == NULL) || (strncmp(tmp, "Information:", strlen("Information:")) == 0))
    continue;
**

This could potentially be extensible with an array of discard substrings for
each VMware driver that are iteratable. That may be a bit outside my grasp...

Am I completely barking up the wrong tree here? Heading to bed, sorry for the
bad patches!

  -r


diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index c96bd62..a2ad7bd 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 = 0;
     const char *pattern;
-    const char *tmp;
+    const char *tmp = NULL;
+    char **verbuftok = NULL;
 
     switch (type) {
         case VMWARE_DRIVER_PLAYER:
@@ -241,7 +243,22 @@ vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
             return -1;
     }
 
-    if ((tmp = STRSKIP(verbuf, pattern)) == NULL) {
+    verbuftok = virStringSplit(verbuf, "\n", 0);
+    if (type == VMWARE_DRIVER_FUSION) {
+        tmp = STRSKIP(verbuf, pattern);
+    }else{
+        for (; 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;




More information about the libvir-list mailing list