[pve-devel] r5156 - in qemu-server/pve2: . PVE/API2/Qemu
svn-commits at proxmox.com
svn-commits at proxmox.com
Wed Sep 15 11:18:55 CEST 2010
Author: dietmar
Date: 2010-09-15 09:18:55 +0000 (Wed, 15 Sep 2010)
New Revision: 5156
Modified:
qemu-server/pve2/PVE/API2/Qemu/Status.pm
qemu-server/pve2/PVE/API2/Qemu/VNC.pm
qemu-server/pve2/nqm
Log:
fix vncproxy implementation
Modified: qemu-server/pve2/PVE/API2/Qemu/Status.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/Status.pm 2010-09-15 09:15:09 UTC (rev 5155)
+++ qemu-server/pve2/PVE/API2/Qemu/Status.pm 2010-09-15 09:18:55 UTC (rev 5156)
@@ -87,13 +87,7 @@
type => 'string',
enum => [qw(start stop reset shutdown cad suspend resume vncticket) ],
},
- ticket => {
- description => "Secret VNC ticket (required by vncticket command).",
- type => 'string',
- optional => 1,
- minLength => 8, # just to improve security
- pattern => '[A-Za-z0-9\+\/\=]+', # base64 characters
- },
+ ticket => get_standard_option('pve-vncticket'),
},
},
returns => { type => 'null'},
Modified: qemu-server/pve2/PVE/API2/Qemu/VNC.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/VNC.pm 2010-09-15 09:15:09 UTC (rev 5155)
+++ qemu-server/pve2/PVE/API2/Qemu/VNC.pm 2010-09-15 09:18:55 UTC (rev 5156)
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use Digest::SHA1;
use PVE::SafeSyslog;
use PVE::Tools qw(extract_param);
@@ -47,15 +48,44 @@
my $node = $param->{node};
# generate ticket, olny first 8 character used by vnc
- my $ticket = Digest::SHA1::sha1_base64 ($userid, rand(), time());
+ my $ticket = Digest::SHA1::sha1_base64 ($user, rand(), time());
my $port = PVE::QemuServer::next_vnc_port();
- print "TEST VNCPROXY\n";
+ my $remip = $rpcenv->get_remote_node_ip($node);
+ my $remcmd = $remip ? ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes', $remip] : [];
+ my $timeout = 30;
- return { port = $port, ticket => $ticket };
+ my $realcmd = sub {
+ my $upid = shift;
+ syslog ('info', "starting vnc proxy $upid\n");
+
+ my $qmcmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid , $ticket];
+
+ my $qmstr = join (' ', @$qmcmd);
+
+ # also redirect stderr (else we get RFB protocol errors)
+ my @cmd = ('/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null");
+
+ unshift @cmd, "echo"; # fixme
+
+ my $cmdstr = join (' ', @cmd);
+ syslog ('info', "CMD: $cmdstr");
+
+ if (system (@cmd) != 0) {
+ my $msg = "VM $vmid vnc proxy failed - $?";
+ syslog ('err', $msg);
+ exit (-1);
+ }
+
+ exit (0);
+ };
+
+ my $upid = $rpcenv->fork_worker('vncproxy', "", $realcmd);
+
+ return { port => $port, ticket => $ticket};
}});
1;
Modified: qemu-server/pve2/nqm
===================================================================
--- qemu-server/pve2/nqm 2010-09-15 09:15:09 UTC (rev 5155)
+++ qemu-server/pve2/nqm 2010-09-15 09:18:55 UTC (rev 5156)
@@ -31,7 +31,7 @@
$rpcenv->set_user('root');
-my $hostname = read_file('hostname');
+my $hostname = $rpcenv->get_hostname();
sub run_vnc_proxy {
my ($vmid) = @_;
More information about the pve-devel
mailing list