[pve-devel] [PATCH] add next_spiceproxy_socket sub

Alexandre Derumier aderumier at odiso.com
Fri Jun 21 10:31:15 CEST 2013


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 data/PVE/Tools.pm |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/data/PVE/Tools.pm b/data/PVE/Tools.pm
index 0ec74d8..f6be447 100644
--- a/data/PVE/Tools.pm
+++ b/data/PVE/Tools.pm
@@ -35,6 +35,7 @@ extract_param
 
 my $pvelogdir = "/var/log/pve";
 my $pvetaskdir = "$pvelogdir/tasks";
+my $var_run_tmpdir = "/var/run/qemu-server";
 
 mkdir $pvelogdir;
 mkdir $pvetaskdir;
@@ -705,6 +706,23 @@ sub next_vnc_port {
     return next_unused_port(5900, 6000);
 }
 
+sub next_spiceproxy_socket {
+
+    my $sockets = {};
+
+    dir_glob_foreach($var_run_tmpdir, '(\d+)\.spiceproxy', sub {
+	my (undef, $id) = @_;
+	$sockets->{$id} = 1;
+    });
+
+    for (my $i = 1; $i < 1000; $i++) {
+        if (!$sockets->{$i}) {
+            return ($var_run_tmpdir."/$i.spiceproxy", $i);
+        }
+    }
+    die "no free spiceproxy socket available";
+}
+
 # NOTE: NFS syscall can't be interrupted, so alarm does 
 # not work to provide timeouts.
 # from 'man nfs': "Only SIGKILL can interrupt a pending NFS operation"
-- 
1.7.10.4




More information about the pve-devel mailing list