mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-29 22:43:44 +00:00
code cleanups
This commit is contained in:
parent
2c9e8036f5
commit
f34ebd5259
@ -512,7 +512,7 @@ __PACKAGE__->register_method({
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
subclass => "PVE::API2::Firewall::VM",
|
subclass => "PVE::API2::Firewall::VM",
|
||||||
path => '{vmid}/firewall',
|
path => '{vmid}/firewall',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1004,7 +1004,7 @@ my $update_vm_api = sub {
|
|||||||
} elsif($opt eq 'tablet' && $param->{$opt} == 0){
|
} elsif($opt eq 'tablet' && $param->{$opt} == 0){
|
||||||
PVE::QemuServer::vm_deviceunplug($vmid, $conf, $opt);
|
PVE::QemuServer::vm_deviceunplug($vmid, $conf, $opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($opt eq 'cores' && $conf->{maxcpus}){
|
if($opt eq 'cores' && $conf->{maxcpus}){
|
||||||
PVE::QemuServer::qemu_cpu_hotplug($vmid, $conf, $param->{$opt});
|
PVE::QemuServer::qemu_cpu_hotplug($vmid, $conf, $param->{$opt});
|
||||||
}
|
}
|
||||||
@ -1429,7 +1429,7 @@ __PACKAGE__->register_method({
|
|||||||
# check is done by verifying the VNC ticket (inside VNC protocol).
|
# check is done by verifying the VNC ticket (inside VNC protocol).
|
||||||
|
|
||||||
my $port = $param->{port};
|
my $port = $param->{port};
|
||||||
|
|
||||||
return { port => $port };
|
return { port => $port };
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -1468,12 +1468,12 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $port = PVE::QemuServer::spice_port($vmid);
|
my $port = PVE::QemuServer::spice_port($vmid);
|
||||||
|
|
||||||
my ($ticket, undef, $remote_viewer_config) =
|
my ($ticket, undef, $remote_viewer_config) =
|
||||||
PVE::AccessControl::remote_viewer_config($authuser, $vmid, $node, $proxy, $title, $port);
|
PVE::AccessControl::remote_viewer_config($authuser, $vmid, $node, $proxy, $title, $port);
|
||||||
|
|
||||||
PVE::QemuServer::vm_mon_cmd($vmid, "set_password", protocol => 'spice', password => $ticket);
|
PVE::QemuServer::vm_mon_cmd($vmid, "set_password", protocol => 'spice', password => $ticket);
|
||||||
PVE::QemuServer::vm_mon_cmd($vmid, "expire_password", protocol => 'spice', time => "+30");
|
PVE::QemuServer::vm_mon_cmd($vmid, "expire_password", protocol => 'spice', time => "+30");
|
||||||
|
|
||||||
return $remote_viewer_config;
|
return $remote_viewer_config;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -2284,7 +2284,7 @@ __PACKAGE__->register_method({
|
|||||||
UUID::generate($uuid);
|
UUID::generate($uuid);
|
||||||
UUID::unparse($uuid, $uuid_str);
|
UUID::unparse($uuid, $uuid_str);
|
||||||
my $smbios1 = PVE::QemuServer::parse_smbios1($newconf->{smbios1} || '');
|
my $smbios1 = PVE::QemuServer::parse_smbios1($newconf->{smbios1} || '');
|
||||||
$smbios1->{uuid} = $uuid_str;
|
$smbios1->{uuid} = $uuid_str;
|
||||||
$newconf->{smbios1} = PVE::QemuServer::print_smbios1($smbios1);
|
$newconf->{smbios1} = PVE::QemuServer::print_smbios1($smbios1);
|
||||||
|
|
||||||
delete $newconf->{template};
|
delete $newconf->{template};
|
||||||
@ -2484,9 +2484,9 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
|
PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
# try to deactivate volumes - avoid lvm LVs to be active on several nodes
|
# try to deactivate volumes - avoid lvm LVs to be active on several nodes
|
||||||
PVE::Storage::deactivate_volumes($storecfg, [ $newdrive->{file} ])
|
PVE::Storage::deactivate_volumes($storecfg, [ $newdrive->{file} ])
|
||||||
if !$running;
|
if !$running;
|
||||||
};
|
};
|
||||||
warn $@ if $@;
|
warn $@ if $@;
|
||||||
|
@ -2591,7 +2591,7 @@ sub config_to_command {
|
|||||||
my $total_cores = $sockets * $cores;
|
my $total_cores = $sockets * $cores;
|
||||||
my $allowed_cores = $cpuinfo->{cpus};
|
my $allowed_cores = $cpuinfo->{cpus};
|
||||||
|
|
||||||
die "MAX $allowed_cores Cores allowed per VM on this Node"
|
die "MAX $allowed_cores cores allowed per VM on this node\n"
|
||||||
if ($allowed_cores < $total_cores);
|
if ($allowed_cores < $total_cores);
|
||||||
|
|
||||||
if ($maxcpus) {
|
if ($maxcpus) {
|
||||||
@ -4935,9 +4935,9 @@ sub snapshot_create {
|
|||||||
eval { vm_mon_cmd($vmid, "savevm-end") if $running; };
|
eval { vm_mon_cmd($vmid, "savevm-end") if $running; };
|
||||||
warn $@ if $@;
|
warn $@ if $@;
|
||||||
|
|
||||||
#savevm-end is async, we need to wait
|
# savevm-end is async, we need to wait
|
||||||
if($running) {
|
if ($running) {
|
||||||
for(;;) {
|
for (;;) {
|
||||||
my $stat = vm_mon_cmd_nocheck($vmid, "query-savevm");
|
my $stat = vm_mon_cmd_nocheck($vmid, "query-savevm");
|
||||||
if (!$stat->{bytes}) {
|
if (!$stat->{bytes}) {
|
||||||
last;
|
last;
|
||||||
@ -5190,7 +5190,7 @@ sub qemu_drive_mirror {
|
|||||||
|
|
||||||
#fixme : sometime drive-mirror timeout, but works fine after.
|
#fixme : sometime drive-mirror timeout, but works fine after.
|
||||||
# (I have see the problem with big volume > 200GB), so we need to eval
|
# (I have see the problem with big volume > 200GB), so we need to eval
|
||||||
eval { vm_mon_cmd($vmid, "drive-mirror", %$opts); };
|
eval { vm_mon_cmd($vmid, "drive-mirror", %$opts); };
|
||||||
# ignore errors here
|
# ignore errors here
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
@ -5207,12 +5207,12 @@ sub qemu_drive_mirror {
|
|||||||
my $busy = $stat->{busy};
|
my $busy = $stat->{busy};
|
||||||
|
|
||||||
print "transferred: $transferred bytes remaining: $remaining bytes total: $total bytes progression: $percent % busy: $busy\n";
|
print "transferred: $transferred bytes remaining: $remaining bytes total: $total bytes progression: $percent % busy: $busy\n";
|
||||||
|
|
||||||
if ($stat->{len} == $stat->{offset}) {
|
if ($stat->{len} == $stat->{offset}) {
|
||||||
if ($busy eq 'false') {
|
if ($busy eq 'false') {
|
||||||
|
|
||||||
last if $vmiddst != $vmid;
|
last if $vmiddst != $vmid;
|
||||||
|
|
||||||
# try to switch the disk if source and destination are on the same guest
|
# try to switch the disk if source and destination are on the same guest
|
||||||
eval { vm_mon_cmd($vmid, "block-job-complete", device => "drive-$drive") };
|
eval { vm_mon_cmd($vmid, "block-job-complete", device => "drive-$drive") };
|
||||||
last if !$@;
|
last if !$@;
|
||||||
@ -5247,7 +5247,7 @@ sub qemu_drive_mirror {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
eval { &$cancel_job(); };
|
eval { &$cancel_job(); };
|
||||||
die "mirroring error: $err";
|
die "mirroring error: $err";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user