[pve-devel] [PATCH qemu-server 1/2] fix #2787: properly parse 'vga' for vncproxy

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Jun 17 10:41:16 CEST 2020


'vga' is a property string, we can't just assume it starts with the
default key's value.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/API2/Qemu.pm | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 974ee3b..95b1922 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1634,7 +1634,12 @@ __PACKAGE__->register_method({
 	my $websocket = $param->{websocket};
 
 	my $conf = PVE::QemuConfig->load_config($vmid, $node); # check if VM exists
-	my $use_serial = ($conf->{vga} && ($conf->{vga} =~ m/^serial\d+$/));
+	
+	my $serial;
+	if ($conf->{vga}) {
+	    my $vga = PVE::QemuServer::parse_vga($conf->{vga});
+	    $serial = $vga->{type} if $vga->{type} =~ m/^serial\d+$/;
+	}
 
 	my $authpath = "/vms/$vmid";
 
@@ -1650,7 +1655,7 @@ __PACKAGE__->register_method({
 	    (undef, $family) = PVE::Cluster::remote_node_ip($node);
 	    my $sshinfo = PVE::SSHInfo::get_ssh_info($node);
 	    # NOTE: kvm VNC traffic is already TLS encrypted or is known unsecure
-	    $remcmd = PVE::SSHInfo::ssh_info_to_command($sshinfo, $use_serial ? '-t' : '-T');
+	    $remcmd = PVE::SSHInfo::ssh_info_to_command($sshinfo, defined($serial) ? '-t' : '-T');
 	} else {
 	    $family = PVE::Tools::get_host_address_family($node);
 	}
@@ -1666,9 +1671,9 @@ __PACKAGE__->register_method({
 
 	    my $cmd;
 
-	    if ($use_serial) {
+	    if (defined($serial)) {
 
-		my $termcmd = [ '/usr/sbin/qm', 'terminal', $vmid, '-iface', $conf->{vga}, '-escape', '0' ];
+		my $termcmd = [ '/usr/sbin/qm', 'terminal', $vmid, '-iface', $serial, '-escape', '0' ];
 
 		$cmd = ['/usr/bin/vncterm', '-rfbport', $port,
 			'-timeout', $timeout, '-authpath', $authpath,
-- 
2.20.1





More information about the pve-devel mailing list