X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FAPI2%2FQemu.pm;h=54db5ab0caaf43255dcf8d73fb9262eddd31c32c;hb=af6d2db4b3dd54dee517a3ae6a49eac43c068af9;hp=3342458929cff5176d7ad734854bdd112a94d16f;hpb=3ab7663a918ae831b5ddca068c9f0568a2799947;p=qemu-server.git diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 33424589..54db5ab0 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -15,6 +15,8 @@ use PVE::Exception qw(raise raise_param_exc raise_perm_exc); use PVE::Storage; use PVE::JSONSchema qw(get_standard_option); use PVE::RESTHandler; +use PVE::ReplicationConfig; +use PVE::GuestHelpers; use PVE::QemuConfig; use PVE::QemuServer; use PVE::QemuMigrate; @@ -1010,7 +1012,7 @@ my $update_vm_api = sub { foreach my $opt (@delete) { $modified->{$opt} = 1; $conf = PVE::QemuConfig->load_config($vmid); # update/reload - if (!defined($conf->{$opt})) { + if (!defined($conf->{$opt}) && !defined($conf->{pending}->{$opt})) { warn "cannot delete '$opt' - not set in current configuration!\n"; $modified->{$opt} = 0; next; @@ -1279,6 +1281,10 @@ __PACKAGE__->register_method({ die "unable to remove VM $vmid - used in HA resources\n" if PVE::HA::Config::vm_is_ha_managed($vmid); + # do not allow destroy if there are replication jobs + my $repl_conf = PVE::ReplicationConfig->new(); + $repl_conf->check_for_existing_jobs($vmid); + # early tests (repeat after locking) die "VM $vmid is running - destroy failed\n" if PVE::QemuServer::check_running($vmid); @@ -2851,13 +2857,17 @@ __PACKAGE__->register_method({ } else { - my $realcmd = sub { - my $upid = shift; + my $code = sub { + my $realcmd = sub { + my $upid = shift; + + PVE::QemuMigrate->migrate($target, $targetip, $vmid, $param); + }; - PVE::QemuMigrate->migrate($target, $targetip, $vmid, $param); + return $rpcenv->fork_worker('qmigrate', $vmid, $authuser, $realcmd); }; - return $rpcenv->fork_worker('qmigrate', $vmid, $authuser, $realcmd); + return PVE::GuestHelpers::guest_migration_lock($vmid, 10, $code); } }});