mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-04-30 09:04:14 +00:00
new vga_conf_has_spice() helper
code cleanups
This commit is contained in:
parent
1d794448fc
commit
86b8228b59
@ -1480,9 +1480,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
$status->{ha} = &$vm_is_ha_managed($param->{vmid});
|
$status->{ha} = &$vm_is_ha_managed($param->{vmid});
|
||||||
|
|
||||||
if ($conf->{vga} && ($conf->{vga} eq 'qxl')) {
|
$status->{spice} = 1 if PVE::QemuServer::vga_conf_has_spice($conf->{vga});
|
||||||
$status->{spice} = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}});
|
}});
|
||||||
|
@ -309,13 +309,12 @@ sub phase2 {
|
|||||||
|
|
||||||
my $rport;
|
my $rport;
|
||||||
|
|
||||||
my $spice_port;
|
|
||||||
my $nodename = PVE::INotify::nodename();
|
my $nodename = PVE::INotify::nodename();
|
||||||
|
|
||||||
## start on remote node
|
## start on remote node
|
||||||
my $cmd = [@{$self->{rem_ssh}}];
|
my $cmd = [@{$self->{rem_ssh}}];
|
||||||
|
|
||||||
if($conf->{vga} eq 'qxl'){
|
if (PVE::QemuServer::vga_conf_has_spice($conf->{vga})) {
|
||||||
my $res = PVE::QemuServer::vm_mon_cmd($vmid, 'query-spice');
|
my $res = PVE::QemuServer::vm_mon_cmd($vmid, 'query-spice');
|
||||||
push @$cmd, 'SPICETICKET='.$res->{ticket} if $res->{ticket};
|
push @$cmd, 'SPICETICKET='.$res->{ticket} if $res->{ticket};
|
||||||
}
|
}
|
||||||
@ -327,13 +326,15 @@ sub phase2 {
|
|||||||
push @$cmd, '--machine', $self->{forcemachine};
|
push @$cmd, '--machine', $self->{forcemachine};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $spice_port;
|
||||||
|
|
||||||
PVE::Tools::run_command($cmd, outfunc => sub {
|
PVE::Tools::run_command($cmd, outfunc => sub {
|
||||||
my $line = shift;
|
my $line = shift;
|
||||||
|
|
||||||
if ($line =~ m/^migration listens on port (\d+)$/) {
|
if ($line =~ m/^migration listens on port (\d+)$/) {
|
||||||
$rport = $1;
|
$rport = int($1);
|
||||||
}elsif ($line =~ m/^spice listens on port (\d+)$/) {
|
}elsif ($line =~ m/^spice listens on port (\d+)$/) {
|
||||||
$spice_port = $1;
|
$spice_port = int($1);
|
||||||
}
|
}
|
||||||
}, errfunc => sub {
|
}, errfunc => sub {
|
||||||
my $line = shift;
|
my $line = shift;
|
||||||
@ -391,19 +392,21 @@ sub phase2 {
|
|||||||
PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => $cachesize);
|
PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => $cachesize);
|
||||||
};
|
};
|
||||||
|
|
||||||
if($conf->{vga} eq 'qxl'){
|
if (PVE::QemuServer::vga_conf_has_spice($conf->{vga})) {
|
||||||
my $rpcenv = PVE::RPCEnvironment::get();
|
my $rpcenv = PVE::RPCEnvironment::get();
|
||||||
my $authuser = $rpcenv->get_user();
|
my $authuser = $rpcenv->get_user();
|
||||||
|
|
||||||
my ($ticket, $proxyticket) = PVE::AccessControl::assemble_spice_ticket($authuser, $vmid, $self->{node});
|
my (undef, $proxyticket) = PVE::AccessControl::assemble_spice_ticket($authuser, $vmid, $self->{node});
|
||||||
|
|
||||||
my $filename = "/etc/pve/nodes/".$self->{node}."/pve-ssl.pem";
|
my $filename = "/etc/pve/nodes/$self->{node}/pve-ssl.pem";
|
||||||
my $subject = PVE::QemuServer::read_x509_subject_spice($filename);
|
my $subject = PVE::QemuServer::read_x509_subject_spice($filename);
|
||||||
|
|
||||||
$self->log('info', "spice client_migrate_info");
|
$self->log('info', "spice client_migrate_info");
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "client_migrate_info", protocol => 'spice', hostname => $proxyticket, 'tls-port' => int($spice_port), 'cert-subject' => $subject);
|
PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "client_migrate_info", protocol => 'spice',
|
||||||
|
hostname => $proxyticket, 'tls-port' => $spice_port,
|
||||||
|
'cert-subject' => $subject);
|
||||||
};
|
};
|
||||||
$self->log('info', "client_migrate_info error: $@") if $@;
|
$self->log('info', "client_migrate_info error: $@") if $@;
|
||||||
|
|
||||||
@ -580,7 +583,7 @@ sub phase3_cleanup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $timer = 0;
|
my $timer = 0;
|
||||||
if($conf->{vga} eq 'qxl'){
|
if (PVE::QemuServer::vga_conf_has_spice($conf->{vga})) {
|
||||||
$self->log('info', "Waiting for spice server migration");
|
$self->log('info', "Waiting for spice server migration");
|
||||||
while (1) {
|
while (1) {
|
||||||
my $res = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, 'query-spice');
|
my $res = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, 'query-spice');
|
||||||
|
@ -2231,6 +2231,12 @@ sub foreach_volid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub vga_conf_has_spice {
|
||||||
|
my ($vga) = @_;
|
||||||
|
|
||||||
|
return $vga && ($vga eq 'qxl');
|
||||||
|
}
|
||||||
|
|
||||||
sub config_to_command {
|
sub config_to_command {
|
||||||
my ($storecfg, $vmid, $conf, $defaults, $forcemachine) = @_;
|
my ($storecfg, $vmid, $conf, $defaults, $forcemachine) = @_;
|
||||||
|
|
||||||
@ -2299,7 +2305,7 @@ sub config_to_command {
|
|||||||
$tablet = $conf->{tablet};
|
$tablet = $conf->{tablet};
|
||||||
} else {
|
} else {
|
||||||
$tablet = $defaults->{tablet};
|
$tablet = $defaults->{tablet};
|
||||||
$tablet = 0 if $vga eq 'qxl'; # disable for spice because it is not needed
|
$tablet = 0 if vga_conf_has_spice($vga); # disable for spice because it is not needed
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -2456,7 +2462,7 @@ sub config_to_command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $spice_port;
|
my $spice_port;
|
||||||
if ($vga eq 'qxl') {
|
if (vga_conf_has_spice($vga)) {
|
||||||
my $pciaddr = print_pci_addr("spice", $bridges);
|
my $pciaddr = print_pci_addr("spice", $bridges);
|
||||||
|
|
||||||
$spice_port = PVE::Tools::next_unused_port(61000, 61099);
|
$spice_port = PVE::Tools::next_unused_port(61000, 61099);
|
||||||
|
Loading…
Reference in New Issue
Block a user