[pve-devel] r5473 - in pve-common/trunk/data: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Feb 2 08:47:03 CET 2011


Author: dietmar
Date: 2011-02-02 08:47:03 +0100 (Wed, 02 Feb 2011)
New Revision: 5473

Modified:
   pve-common/trunk/data/ChangeLog
   pve-common/trunk/data/PVE/Tools.pm
Log:


Modified: pve-common/trunk/data/ChangeLog
===================================================================
--- pve-common/trunk/data/ChangeLog	2011-02-01 11:44:52 UTC (rev 5472)
+++ pve-common/trunk/data/ChangeLog	2011-02-02 07:47:03 UTC (rev 5473)
@@ -1,3 +1,7 @@
+2011-02-02  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/Tools.pm (next_vnc_port): moved from qemu-server
+
 2011-01-28  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/SafeSyslog.pm (initlog): enable default for facility.

Modified: pve-common/trunk/data/PVE/Tools.pm
===================================================================
--- pve-common/trunk/data/PVE/Tools.pm	2011-02-01 11:44:52 UTC (rev 5472)
+++ pve-common/trunk/data/PVE/Tools.pm	2011-02-02 07:47:03 UTC (rev 5473)
@@ -2,6 +2,7 @@
 
 use strict;
 use POSIX;
+use IO::Socket::INET;
 use IO::Select;
 use IO::File;
 use IPC::Open3;
@@ -398,4 +399,23 @@
     return $res;
 }
 
+sub next_vnc_port {
+
+    for (my $p = 5900; $p < 6000; $p++) {
+
+	my $sock = IO::Socket::INET->new (Listen => 5,
+					  LocalAddr => 'localhost',
+					  LocalPort => $p,
+					  ReuseAddr => 1,
+					  Proto     => 0);
+
+	if ($sock) {
+	    close ($sock);
+	    return $p;
+	}
+    }
+
+    die "unable to find free vnc port";
+};
+
 1;




More information about the pve-devel mailing list