add ability to run without graphic card ('vga: serial[n]')

This commit is contained in:
Dietmar Maurer 2013-07-31 09:19:36 +02:00
parent f409f8dc50
commit ef5e2be2a4
2 changed files with 25 additions and 10 deletions

View File

@ -1273,6 +1273,8 @@ __PACKAGE__->register_method({
my $vmid = $param->{vmid}; my $vmid = $param->{vmid};
my $node = $param->{node}; my $node = $param->{node};
my $conf = PVE::QemuServer::load_config($vmid); # check if VM exists
my $authpath = "/vms/$vmid"; my $authpath = "/vms/$vmid";
my $ticket = PVE::AccessControl::assemble_vnc_ticket($authuser, $authpath); my $ticket = PVE::AccessControl::assemble_vnc_ticket($authuser, $authpath);
@ -1283,13 +1285,13 @@ __PACKAGE__->register_method({
my $port = PVE::Tools::next_vnc_port(); my $port = PVE::Tools::next_vnc_port();
my $remip; my $remip;
my $remcmd = [];
if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) { if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
$remip = PVE::Cluster::remote_node_ip($node); $remip = PVE::Cluster::remote_node_ip($node);
}
# NOTE: kvm VNC traffic is already TLS encrypted # NOTE: kvm VNC traffic is already TLS encrypted
my $remcmd = $remip ? ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes', $remip] : []; $remcmd = ['/usr/bin/ssh', '-T', '-o', 'BatchMode=yes', $remip];
}
my $timeout = 10; my $timeout = 10;
@ -1298,12 +1300,24 @@ __PACKAGE__->register_method({
syslog('info', "starting vnc proxy $upid\n"); syslog('info', "starting vnc proxy $upid\n");
my $cmd;
if ($conf->{vga} =~ m/^serial\d+$/) {
my $termcmd = [ '/usr/sbin/qm', 'terminal', $vmid, '-iface', $conf->{vga} ];
#my $termcmd = "/usr/bin/qm terminal -iface $conf->{vga}";
$cmd = ['/usr/bin/vncterm', '-rfbport', $port,
'-timeout', $timeout, '-authpath', $authpath,
'-perm', 'Sys.Console', '-c', @$remcmd, @$termcmd];
} else {
my $qmcmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid]; my $qmcmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid];
my $qmstr = join(' ', @$qmcmd); my $qmstr = join(' ', @$qmcmd);
# also redirect stderr (else we get RFB protocol errors) # also redirect stderr (else we get RFB protocol errors)
my $cmd = ['/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null"]; $cmd = ['/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null"];
}
PVE::Tools::run_command($cmd); PVE::Tools::run_command($cmd);

View File

@ -335,8 +335,8 @@ EODESC
vga => { vga => {
optional => 1, optional => 1,
type => 'string', type => 'string',
description => "Select VGA type. If you want to use high resolution modes (>= 1280x1024x16) then you should use option 'std' or 'vmware'. Default is 'std' for win8/win7/w2k8, and 'cirrur' for other OS types. Option 'qxl' enables the SPICE display sever.", description => "Select VGA type. If you want to use high resolution modes (>= 1280x1024x16) then you should use option 'std' or 'vmware'. Default is 'std' for win8/win7/w2k8, and 'cirrur' for other OS types. Option 'qxl' enables the SPICE display sever. You can also run without any graphic card using a serial devive as terminal.",
enum => [qw(std cirrus vmware qxl)], enum => [qw(std cirrus vmware qxl serial0 serial1 serial2 serial3)],
}, },
watchdog => { watchdog => {
optional => 1, optional => 1,
@ -2306,6 +2306,7 @@ sub config_to_command {
} else { } else {
$tablet = $defaults->{tablet}; $tablet = $defaults->{tablet};
$tablet = 0 if vga_conf_has_spice($vga); # disable for spice because it is not needed $tablet = 0 if vga_conf_has_spice($vga); # disable for spice because it is not needed
$tablet = 0 if $vga =~ m/^serial\d+$/; # disable if we use serial terminal (no vga card)
} }
push @$devices, '-device', 'usb-tablet,id=tablet,bus=uhci.0,port=1' if $tablet; push @$devices, '-device', 'usb-tablet,id=tablet,bus=uhci.0,port=1' if $tablet;
@ -2385,7 +2386,7 @@ sub config_to_command {
push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0; push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0;
push @$cmd, '-vga', $vga if $vga; # for kvm 77 and later push @$cmd, '-vga', $vga if $vga && $vga !~ m/^serial\d+$/; # for kvm 77 and later
# time drift fix # time drift fix
my $tdf = defined($conf->{tdf}) ? $conf->{tdf} : $defaults->{tdf}; my $tdf = defined($conf->{tdf}) ? $conf->{tdf} : $defaults->{tdf};