]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Diskmanage.pm
refactor disk/storage checks for Disk API
[pve-storage.git] / PVE / Diskmanage.pm
index e1db2ae67c803af87a031d92bb64810f8000706c..5a5fc87799fc767406fadac086391352d39c2b4a 100644 (file)
@@ -456,6 +456,14 @@ sub get_disks {
 
        $used = 'ZFS' if $zfslist->{$devpath};
 
+       # we replaced cciss/ with cciss! above
+       # but in the result we need cciss/ again
+       # because the caller might want to check the
+       # result again with the original parameter
+       if ($dev =~ m|^cciss!|) {
+           $dev =~ s|^cciss!|cciss/|;
+       }
+
        $disklist->{$dev} = {
            vendor => $sysdata->{vendor},
            model => $data->{model} || $sysdata->{model},
@@ -587,4 +595,19 @@ sub get_blockdev {
     return $block_dev;
 }
 
+sub locked_disk_action {
+    my ($sub) = @_;
+    my $res = PVE::Tools::lock_file('/run/lock/pve-diskmanage.lck', undef, $sub);
+    die $@ if $@;
+    return $res;
+}
+
+sub check_unused {
+    my ($dev) = @_;
+
+    die "device $dev is already in use\n" if disk_is_used($dev);
+
+    return undef;
+}
+
 1;