5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-26 10:03:51 +03:00

code cleanups

This commit is contained in:
Dietmar Maurer 2015-09-17 13:10:19 +02:00
parent 4d8d55f155
commit 0152058a03

View File

@ -392,10 +392,9 @@ __PACKAGE__->register_method({
my $restorefn = sub {
my $vmlist = PVE::Cluster::get_vmlist();
my $nodes = PVE::Cluster::get_members();
if ($vmlist->{ids}->{$vmid}) {
if ($vmlist->{ids}->{$vmid}->{node} eq $node) {
my $current_node = $vmlist->{ids}->{$vmid}->{node};
if ($current_node eq $node) {
my $conf = PVE::QemuServer::load_config($vmid);
&$check_protection($conf, "unable to restore VM $vmid");
@ -406,7 +405,7 @@ __PACKAGE__->register_method({
die "unable to restore vm $vmid - vm is running\n"
if PVE::QemuServer::check_running($vmid);
} else {
die "unable to restore vm $vmid - already existing on cluster node \'$vmlist->{ids}->{$vmid}->{node}\'\n";
die "unable to restore vm $vmid - already existing on cluster node '$current_node'\n";
}
}
@ -907,14 +906,14 @@ my $update_vm_api = sub {
$conf = PVE::QemuServer::load_config($vmid); # update/reload
if ($opt =~ m/^unused/) {
my $drive = PVE::QemuServer::parse_drive($opt, $conf->{$opt});
&$check_protection($conf, "can't remove unused disk \'$drive->{file}\'");
&$check_protection($conf, "can't remove unused disk '$drive->{file}'");
$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk']);
if (PVE::QemuServer::try_deallocate_drive($storecfg, $vmid, $conf, $opt, $drive, $rpcenv, $authuser)) {
delete $conf->{$opt};
PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
}
} elsif (PVE::QemuServer::valid_drivename($opt)) {
&$check_protection($conf, "can't remove drive \'$opt\'");
&$check_protection($conf, "can't remove drive '$opt'");
$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk']);
PVE::QemuServer::vmconfig_register_unused_drive($storecfg, $vmid, $conf, PVE::QemuServer::parse_drive($opt, $conf->{pending}->{$opt}))
if defined($conf->{pending}->{$opt});