[pve-devel] applied: [PATCH v3 container] close #1940: pct console: added ability to specify escape sequence

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Oct 9 15:06:42 CEST 2018


On 10/9/18 1:34 PM, Tim Marx wrote:
> added clarification about behavior when passing -1 to escapechar
> restored former behavior in other uses of get_console_command
> added meaningful tag to commit message
>  

applied, thanks!

> Signed-off-by: Tim Marx <t.marx at proxmox.com>
> ---
>  src/PVE/API2/LXC.pm | 4 ++--
>  src/PVE/CLI/pct.pm  | 9 ++++++++-
>  src/PVE/LXC.pm      | 9 ++++++---
>  3 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index cbcc393..6b3395b 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -733,7 +733,7 @@ __PACKAGE__->register_method ({
>  	    ['/usr/bin/ssh', '-e', 'none', '-t', $remip] : [];
>  
>  	my $conf = PVE::LXC::Config->load_config($vmid, $node);
> -	my $concmd = PVE::LXC::get_console_command($vmid, $conf, 1);
> +	my $concmd = PVE::LXC::get_console_command($vmid, $conf, -1);
>  
>  	my $shcmd = [ '/usr/bin/dtach', '-A',
>  		      "/var/run/dtach/vzctlconsole$vmid",
> @@ -836,7 +836,7 @@ __PACKAGE__->register_method ({
>  	    ['/usr/bin/ssh', '-e', 'none', '-t', $remip, '--'] : [];
>  
>  	my $conf = PVE::LXC::Config->load_config($vmid, $node);
> -	my $concmd = PVE::LXC::get_console_command($vmid, $conf, 1);
> +	my $concmd = PVE::LXC::get_console_command($vmid, $conf, -1);
>  
>  	my $shcmd = [ '/usr/bin/dtach', '-A',
>  		      "/var/run/dtach/vzctlconsole$vmid",
> diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
> index 6296d6f..9d3a230 100755
> --- a/src/PVE/CLI/pct.pm
> +++ b/src/PVE/CLI/pct.pm
> @@ -119,6 +119,13 @@ __PACKAGE__->register_method ({
>      	additionalProperties => 0,
>  	properties => {
>  	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_running }),
> +	    escape => {
> +		description => "Escape sequence prefix. For example to use <Ctrl+b q> as the escape sequence pass '^b'.",
> +		default =>  '^a',
> +		type => 'string',
> +		pattern => '\^?[a-z]',
> +		optional => 1,
> +	    },
>  	},
>      },
>      returns => { type => 'null' },
> @@ -129,7 +136,7 @@ __PACKAGE__->register_method ({
>  	# test if container exists on this node
>  	my $conf = PVE::LXC::Config->load_config($param->{vmid});
>  
> -	my $cmd = PVE::LXC::get_console_command($param->{vmid}, $conf);
> +	my $cmd = PVE::LXC::get_console_command($param->{vmid}, $conf, $param->{escape});
>  	exec(@$cmd);
>      }});
>  
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index 89f289e..a2a2c54 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -664,17 +664,20 @@ sub verify_searchdomain_list {
>  }
>  
>  sub get_console_command {
> -    my ($vmid, $conf, $noescapechar) = @_;
> +    my ($vmid, $conf, $escapechar) = @_;
> +    
> +    # '-1' as $escapechar disables keyboard escape sequence
> +    # any other passed char (a-z) will result in <Ctrl+$escapechar q>
>  
>      my $cmode = PVE::LXC::Config->get_cmode($conf);
>  
>      my $cmd = [];
>      if ($cmode eq 'console') {
>  	push @$cmd, 'lxc-console', '-n',  $vmid, '-t', 0;
> -	push @$cmd, '-e', -1 if $noescapechar;
> +	push @$cmd, '-e', $escapechar if $escapechar;
>      } elsif ($cmode eq 'tty') {
>  	push @$cmd, 'lxc-console', '-n',  $vmid;
> -	push @$cmd, '-e', -1 if $noescapechar;
> +	push @$cmd, '-e', $escapechar if $escapechar;
>      } elsif ($cmode eq 'shell') {
>  	push @$cmd, 'lxc-attach', '--clear-env', '-n', $vmid;
>      } else {
> 





More information about the pve-devel mailing list