]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/API2/Qemu.pm
fix cluster_lock_storage() call
[qemu-server.git] / PVE / API2 / Qemu.pm
index 001344a49c8f8bbd9998f90c6756a3c8ce76125d..3895b189a677ccf0d9fa6b1444a8a286441a5b09 100644 (file)
@@ -53,8 +53,7 @@ my $check_storage_access = sub {
            die "no storage ID specified (and no default storage)\n" if !$storeid;
            $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
        } else {
-           my $path = $rpcenv->check_volume_access($authuser, $storecfg, $vmid, $volid);
-           die "image '$path' does not exists\n" if (!(-f $path || -b $path));
+           $rpcenv->check_volume_access($authuser, $storecfg, $vmid, $volid);
        }
     });
 };
@@ -87,6 +86,8 @@ my $create_disks = sub {
            $res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
        } else {
            my $path = $rpcenv->check_volume_access($authuser, $storecfg, $vmid, $volid);
+           PVE::Storage::activate_volumes($storecfg, [ $volid ])
+               if PVE::Storage::parse_volume_id ($volid, 1);
            die "image '$path' does not exists\n" if (!(-f $path || -b $path));
            $res->{$ds} = $settings->{$ds};
        }
@@ -298,9 +299,13 @@ __PACKAGE__->register_method({
 
            if ($archive eq '-') {
                die "pipe requires cli environment\n"
-                   && $rpcenv->{type} ne 'cli';
+                   if $rpcenv->{type} ne 'cli';
            } else {
                my $path = $rpcenv->check_volume_access($authuser, $storecfg, $vmid, $archive);
+
+               PVE::Storage::activate_volumes($storecfg, [ $archive ])
+                   if PVE::Storage::parse_volume_id ($archive, 1);
+
                die "can't find archive file '$archive'\n" if !($path && -f $path);
                $archive = $path;
            }
@@ -902,11 +907,12 @@ __PACKAGE__->register_method({
 
        my $delVMfromPoolFn = sub {                    
            my $usercfg = cfs_read_file("user.cfg");
-           my $pool = $usercfg->{vms}->{$vmid};
-           if (my $data = $usercfg->{pools}->{$pool}) {
-               delete $data->{vms}->{$vmid};
-               delete $usercfg->{vms}->{$vmid};
-               cfs_write_file("user.cfg", $usercfg);
+           if (my $pool = $usercfg->{vms}->{$vmid}) {
+               if (my $data = $usercfg->{pools}->{$pool}) {
+                   delete $data->{vms}->{$vmid};
+                   delete $usercfg->{vms}->{$vmid};
+                   cfs_write_file("user.cfg", $usercfg);
+               }
            }
        };
 
@@ -1174,7 +1180,8 @@ __PACKAGE__->register_method({
 
        my $storecfg = PVE::Storage::config();
 
-       if (&$vm_is_ha_managed($vmid)) {
+       if (&$vm_is_ha_managed($vmid) && !$stateuri &&
+           $rpcenv->{type} ne 'ha') {
 
            my $hacmd = sub {
                my $upid = shift;
@@ -1262,7 +1269,7 @@ __PACKAGE__->register_method({
 
        my $storecfg = PVE::Storage::config();
 
-       if (&$vm_is_ha_managed($vmid)) {
+       if (&$vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
 
            my $hacmd = sub {
                my $upid = shift;
@@ -1631,7 +1638,10 @@ __PACKAGE__->register_method({
                if !$param->{online};
        }
 
-       if (&$vm_is_ha_managed($vmid)) {
+       my $storecfg = PVE::Storage::config();
+       PVE::QemuServer::check_storage_availability($storecfg, $conf, $target);
+
+       if (&$vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
 
            my $hacmd = sub {
                my $upid = shift;