diff -ru --exclude='*.o' --exclude='*.a' opennebula-1.9.90_org/src/vmm/XenDriver.cc opennebula-1.9.90/src/vmm/XenDriver.cc
--- opennebula-1.9.90_org/src/vmm/XenDriver.cc	2010-09-22 11:16:49.000000000 +0100
+++ opennebula-1.9.90/src/vmm/XenDriver.cc	2010-10-08 15:14:28.000000000 +0100
@@ -364,12 +364,14 @@
                 {
                     file << ",vnclisten=" << listen;
                 }
-
                 if ( !port.empty() )
                 {
-                    file << ",vncdisplay=" << port;
+                    if ( atoi(port.c_str()) >= 5900 ) {
+                        file << ",vncdisplay=" << (atoi(port.c_str())-5900);
+                    } else {
+                        goto error_vncdisplay;
+                    }
                 }
-
                 if ( !passwd.empty() )
                 {
                     file << ",vncpasswd=" << passwd;
@@ -441,4 +443,10 @@
     vm->log("VMM", Log::ERROR, "Wrong target value in DISK.");
     file.close();
     return -1;
+error_vncdisplay:
+    vm->log("VMM", Log::ERROR, 
+            "Could not generate a valid xen vncdisplay number, "
+            "vnc port number must be equal or above 5900.");
+    file.close();
+    return -1;
 }
