mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-06-18 21:45:16 +00:00
qm terminal: add --escape option
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
9e6d6e97c4
commit
aa320bcd16
@ -471,7 +471,13 @@ __PACKAGE__->register_method ({
|
|||||||
type => 'string',
|
type => 'string',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
enum => [qw(serial0 serial1 serial2 serial3)],
|
enum => [qw(serial0 serial1 serial2 serial3)],
|
||||||
}
|
},
|
||||||
|
escape => {
|
||||||
|
description => "Escape character.",
|
||||||
|
type => 'string',
|
||||||
|
optional => 1,
|
||||||
|
default => '^O',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => { type => 'null'},
|
returns => { type => 'null'},
|
||||||
@ -480,6 +486,24 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my $vmid = $param->{vmid};
|
my $vmid = $param->{vmid};
|
||||||
|
|
||||||
|
my $escape = $param->{escape} // '^O';
|
||||||
|
if ($escape =~ /^\^([\x40-\x7a])$/) {
|
||||||
|
$escape = ord($1) & 0x1F;
|
||||||
|
} elsif ($escape =~ /^0x[0-9a-f]+$/i) {
|
||||||
|
$escape = hex($escape);
|
||||||
|
} elsif ($escape =~ /^[0-9]+$/) {
|
||||||
|
$escape = int($escape);
|
||||||
|
} else {
|
||||||
|
die "invalid escape character definition: $escape\n";
|
||||||
|
}
|
||||||
|
my $escapemsg = '';
|
||||||
|
if ($escape) {
|
||||||
|
$escapemsg = sprintf(' (press Ctrl+%c to exit)', $escape+0x40);
|
||||||
|
$escape = sprintf(',escape=0x%x', $escape);
|
||||||
|
} else {
|
||||||
|
$escape = '';
|
||||||
|
}
|
||||||
|
|
||||||
my $conf = PVE::QemuConfig->load_config ($vmid); # check if VM exists
|
my $conf = PVE::QemuConfig->load_config ($vmid); # check if VM exists
|
||||||
|
|
||||||
my $iface = $param->{iface};
|
my $iface = $param->{iface};
|
||||||
@ -501,9 +525,9 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my $socket = "/var/run/qemu-server/${vmid}.$iface";
|
my $socket = "/var/run/qemu-server/${vmid}.$iface";
|
||||||
|
|
||||||
my $cmd = "socat UNIX-CONNECT:$socket STDIO,raw,echo=0,escape=0x0f";
|
my $cmd = "socat UNIX-CONNECT:$socket STDIO,raw,echo=0$escape";
|
||||||
|
|
||||||
print "starting serial terminal on interface $iface (press control-O to exit)\n";
|
print "starting serial terminal on interface ${iface}${escapemsg}\n";
|
||||||
|
|
||||||
system($cmd);
|
system($cmd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user