[pve-devel] [PATCH v2 container] close #1940: added ability to specify escape sequence

Tim Marx t.marx at proxmox.com
Tue Oct 9 10:47:30 CEST 2018


moved regex into property definition to make use of unified api logic
removed inline/whitespace

Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
 src/PVE/CLI/pct.pm | 8 +++++++-
 src/PVE/LXC.pm     | 6 +++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index 6296d6f..5ac821e 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -119,6 +119,12 @@ __PACKAGE__->register_method ({
     	additionalProperties => 0,
 	properties => {
 	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_running }),
+	    escape => {
+		description => "Escape character.",
+		type => 'string',
+		pattern => '\^?([a-z])',
+		optional => 1,
+	    },
 	},
     },
     returns => { type => 'null' },
@@ -129,7 +135,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..09960a8 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -664,17 +664,17 @@ sub verify_searchdomain_list {
 }
 
 sub get_console_command {
-    my ($vmid, $conf, $noescapechar) = @_;
+    my ($vmid, $conf, $escapechar) = @_;
 
     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 {
-- 
2.11.0




More information about the pve-devel mailing list