]>
git.proxmox.com Git - pve-storage.git/blob - PVE/Storage.pm
12 use PVE
::Tools
qw(run_command file_read_firstline);
13 use PVE
::Cluster
qw(cfs_read_file cfs_lock_file);
14 use PVE
::Exception
qw(raise_param_exc);
17 use PVE
::RPCEnvironment
;
19 use PVE
::Storage
::Plugin
;
20 use PVE
::Storage
::DirPlugin
;
21 use PVE
::Storage
::LVMPlugin
;
22 use PVE
::Storage
::NFSPlugin
;
23 use PVE
::Storage
::ISCSIPlugin
;
24 use PVE
::Storage
::RBDPlugin
;
25 use PVE
::Storage
::SheepdogPlugin
;
26 use PVE
::Storage
::ISCSIDirectPlugin
;
27 use PVE
::Storage
::NexentaPlugin
;
29 # load and initialize all plugins
30 PVE
::Storage
::DirPlugin-
>register();
31 PVE
::Storage
::LVMPlugin-
>register();
32 PVE
::Storage
::NFSPlugin-
>register();
33 PVE
::Storage
::ISCSIPlugin-
>register();
34 PVE
::Storage
::RBDPlugin-
>register();
35 PVE
::Storage
::SheepdogPlugin-
>register();
36 PVE
::Storage
::ISCSIDirectPlugin-
>register();
37 PVE
::Storage
::NexentaPlugin-
>register();
38 PVE
::Storage
::Plugin-
>init();
40 my $UDEVADM = '/sbin/udevadm';
42 # PVE::Storage utility functions
45 return cfs_read_file
("storage.cfg");
48 sub lock_storage_config
{
49 my ($code, $errmsg) = @_;
51 cfs_lock_file
("storage.cfg", undef, $code);
54 $errmsg ?
die "$errmsg: $err" : die $err;
59 my ($cfg, $storeid, $noerr) = @_;
61 die "no storage id specified\n" if !$storeid;
63 my $scfg = $cfg->{ids
}->{$storeid};
65 die "storage '$storeid' does not exists\n" if (!$noerr && !$scfg);
70 sub storage_check_node
{
71 my ($cfg, $storeid, $node, $noerr) = @_;
73 my $scfg = storage_config
($cfg, $storeid);
76 $node = PVE
::INotify
::nodename
() if !$node || ($node eq 'localhost');
77 if (!$scfg->{nodes
}->{$node}) {
78 die "storage '$storeid' is not available on node '$node'\n" if !$noerr;
86 sub storage_check_enabled
{
87 my ($cfg, $storeid, $node, $noerr) = @_;
89 my $scfg = storage_config
($cfg, $storeid);
91 if ($scfg->{disable
}) {
92 die "storage '$storeid' is disabled\n" if !$noerr;
96 return storage_check_node
($cfg, $storeid, $node, $noerr);
102 return keys %{$cfg->{ids
}};
106 my ($filename, $timeout) = @_;
108 return PVE
::Storage
::Plugin
::file_size_info
($filename, $timeout);
111 sub volume_size_info
{
112 my ($cfg, $volid, $timeout) = @_;
114 my ($storeid, $volname) = parse_volume_id
($volid, 1);
116 my $scfg = storage_config
($cfg, $storeid);
117 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
118 return $plugin->volume_size_info($scfg, $storeid, $volname, $timeout);
119 } elsif ($volid =~ m
|^(/.+)$| && -e
$volid) {
120 return file_size_info
($volid, $timeout);
127 my ($cfg, $volid, $size, $running) = @_;
129 my ($storeid, $volname) = parse_volume_id
($volid, 1);
131 my $scfg = storage_config
($cfg, $storeid);
132 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
133 return $plugin->volume_resize($scfg, $storeid, $volname, $size, $running);
134 } elsif ($volid =~ m
|^(/.+)$| && -e
$volid) {
135 die "resize device is not possible";
141 sub volume_snapshot
{
142 my ($cfg, $volid, $snap, $running) = @_;
144 my ($storeid, $volname) = parse_volume_id
($volid, 1);
146 my $scfg = storage_config
($cfg, $storeid);
147 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
148 return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap, $running);
149 } elsif ($volid =~ m
|^(/.+)$| && -e
$volid) {
150 die "snapshot device is not possible";
152 die "can't snapshot";
157 my ($cfg, $storeid, $vmid) = @_;
159 my $scfg = storage_config
($cfg, $storeid);
160 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
162 my $path = $plugin->get_subdir($scfg, 'images');
164 return $vmid ?
"$path/$vmid" : $path;
167 sub get_private_dir
{
168 my ($cfg, $storeid, $vmid) = @_;
170 my $scfg = storage_config
($cfg, $storeid);
171 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
173 my $path = $plugin->get_subdir($scfg, 'rootdir');
175 return $vmid ?
"$path/$vmid" : $path;
179 my ($cfg, $storeid) = @_;
181 my $scfg = storage_config
($cfg, $storeid);
182 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
184 return $plugin->get_subdir($scfg, 'iso');
188 my ($cfg, $storeid) = @_;
190 my $scfg = storage_config
($cfg, $storeid);
191 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
193 return $plugin->get_subdir($scfg, 'vztmpl');
197 my ($cfg, $storeid) = @_;
199 my $scfg = storage_config
($cfg, $storeid);
200 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
202 return $plugin->get_subdir($scfg, 'backup');
205 # library implementation
210 die "VMID '$vmid' contains illegal characters\n" if $vmid !~ m/^\d+$/;
215 PVE
::JSONSchema
::register_format
('pve-volume-id', \
&parse_volume_id
);
216 sub parse_volume_id
{
217 my ($volid, $noerr) = @_;
219 if ($volid =~ m/^([a-z][a-z0-9\-\_\.]*[a-z0-9]):(.+)$/i) {
220 return wantarray ?
($1, $2) : $1;
222 return undef if $noerr;
223 die "unable to parse volume ID '$volid'\n";
226 # try to map a filesystem path to a volume identifier
227 sub path_to_volume_id
{
228 my ($cfg, $path) = @_;
230 my $ids = $cfg->{ids
};
232 my ($sid, $volname) = parse_volume_id
($path, 1);
234 if (my $scfg = $ids->{$sid}) {
235 if (my $path = $scfg->{path
}) {
236 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
237 my ($vtype, $name, $vmid) = $plugin->parse_volname($volname);
238 return ($vtype, $path);
244 # Note: abs_path() return undef if $path doesn not exist
245 # for example when nfs storage is not mounted
246 $path = abs_path
($path) || $path;
248 foreach my $sid (keys %$ids) {
249 my $scfg = $ids->{$sid};
250 next if !$scfg->{path
};
251 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
252 my $imagedir = $plugin->get_subdir($scfg, 'images');
253 my $isodir = $plugin->get_subdir($scfg, 'iso');
254 my $tmpldir = $plugin->get_subdir($scfg, 'vztmpl');
255 my $backupdir = $plugin->get_subdir($scfg, 'backup');
256 my $privatedir = $plugin->get_subdir($scfg, 'rootdir');
258 if ($path =~ m!^$imagedir/(\d+)/([^/\s]+)$!) {
261 return ('images', "$sid:$vmid/$name");
262 } elsif ($path =~ m!^$isodir/([^/]+\.[Ii][Ss][Oo])$!) {
264 return ('iso', "$sid:iso/$name");
265 } elsif ($path =~ m!^$tmpldir/([^/]+\.tar\.gz)$!) {
267 return ('vztmpl', "$sid:vztmpl/$name");
268 } elsif ($path =~ m!^$privatedir/(\d+)$!) {
270 return ('rootdir', "$sid:rootdir/$vmid");
271 } elsif ($path =~ m!^$backupdir/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz))$!) {
273 return ('iso', "$sid:backup/$name");
277 # can't map path to volume id
282 my ($cfg, $volid) = @_;
284 my ($storeid, $volname) = parse_volume_id
($volid);
286 my $scfg = storage_config
($cfg, $storeid);
288 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
289 my ($path, $owner, $vtype) = $plugin->path($scfg, $volname, $storeid);
290 return wantarray ?
($path, $owner, $vtype) : $path;
293 sub storage_migrate
{
294 my ($cfg, $volid, $target_host, $target_storeid, $target_volname) = @_;
296 my ($storeid, $volname) = parse_volume_id
($volid);
297 $target_volname = $volname if !$target_volname;
299 my $scfg = storage_config
($cfg, $storeid);
301 # no need to migrate shared content
302 return if $storeid eq $target_storeid && $scfg->{shared
};
304 my $tcfg = storage_config
($cfg, $target_storeid);
306 my $target_volid = "${target_storeid}:${target_volname}";
308 my $errstr = "unable to migrate '$volid' to '${target_volid}' on host '$target_host'";
310 # blowfish is a fast block cipher, much faster then 3des
311 my $sshoptions = "-c blowfish -o 'BatchMode=yes'";
312 my $ssh = "/usr/bin/ssh $sshoptions";
314 local $ENV{RSYNC_RSH
} = $ssh;
316 # only implemented for file system based storage
320 my $src_plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
321 my $dst_plugin = PVE
::Storage
::Plugin-
>lookup($tcfg->{type
});
322 my $src = $src_plugin->path($scfg, $volname, $storeid);
323 my $dst = $dst_plugin->path($tcfg, $target_volname, $target_storeid);
325 my $dirname = dirname
($dst);
327 if ($tcfg->{shared
}) { # we can do a local copy
329 run_command
(['/bin/mkdir', '-p', $dirname]);
331 run_command
(['/bin/cp', $src, $dst]);
335 run_command
(['/usr/bin/ssh', "root\@${target_host}",
336 '/bin/mkdir', '-p', $dirname]);
338 # we use rsync with --sparse, so we can't use --inplace,
339 # so we remove file on the target if it already exists to
341 my ($size, $format) = PVE
::Storage
::Plugin
::file_size_info
($src);
342 if ($format && ($format eq 'raw') && $size) {
343 run_command
(['/usr/bin/ssh', "root\@${target_host}",
348 my $cmd = ['/usr/bin/rsync', '--progress', '--sparse', '--whole-file',
349 $src, "root\@${target_host}:$dst"];
353 run_command
($cmd, outfunc
=> sub {
356 if ($line =~ m/^\s*(\d+\s+(\d+)%\s.*)$/) {
359 print "rsync status: $1\n";
369 die "$errstr - target type '$tcfg->{type}' not implemented\n";
372 die "$errstr - source type '$scfg->{type}' not implemented\n";
377 my ($cfg, $storeid, $vmid, $fmt, $name, $size) = @_;
379 die "no storage id specified\n" if !$storeid;
381 PVE
::JSONSchema
::parse_storage_id
($storeid);
383 my $scfg = storage_config
($cfg, $storeid);
385 die "no VMID specified\n" if !$vmid;
387 $vmid = parse_vmid
($vmid);
389 my $defformat = PVE
::Storage
::Plugin
::default_format
($scfg);
391 $fmt = $defformat if !$fmt;
393 activate_storage
($cfg, $storeid);
395 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
397 # lock shared storage
398 return $plugin->cluster_lock_storage($storeid, $scfg->{shared
}, undef, sub {
399 my $volname = $plugin->alloc_image($storeid, $scfg, $vmid, $fmt, $name, $size);
400 return "$storeid:$volname";
405 my ($cfg, $volid) = @_;
407 my ($storeid, $volname) = parse_volume_id
($volid);
409 my $scfg = storage_config
($cfg, $storeid);
411 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
413 activate_storage
($cfg, $storeid);
417 # lock shared storage
418 $plugin->cluster_lock_storage($storeid, $scfg->{shared
}, undef, sub {
419 my $cleanup_worker = $plugin->free_image($storeid, $scfg, $volname);
422 return if !$cleanup_worker;
424 my $rpcenv = PVE
::RPCEnvironment
::get
();
425 my $authuser = $rpcenv->get_user();
427 $rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
430 #list iso or openvz template ($tt = <iso|vztmpl|backup>)
432 my ($cfg, $storeid, $tt) = @_;
434 die "unknown template type '$tt'\n"
435 if !($tt eq 'iso' || $tt eq 'vztmpl' || $tt eq 'backup');
437 my $ids = $cfg->{ids
};
439 storage_check_enabled
($cfg, $storeid) if ($storeid);
445 foreach my $sid (keys %$ids) {
446 next if $storeid && $storeid ne $sid;
448 my $scfg = $ids->{$sid};
449 my $type = $scfg->{type
};
451 next if !storage_check_enabled
($cfg, $sid, undef, 1);
453 next if $tt eq 'iso' && !$scfg->{content
}->{iso
};
454 next if $tt eq 'vztmpl' && !$scfg->{content
}->{vztmpl
};
455 next if $tt eq 'backup' && !$scfg->{content
}->{backup
};
457 activate_storage
($cfg, $sid);
460 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
462 my $path = $plugin->get_subdir($scfg, $tt);
464 foreach my $fn (<$path/*>) {
469 next if $fn !~ m!/([^/]+\.[Ii][Ss][Oo])$!;
471 $info = { volid
=> "$sid:iso/$1", format
=> 'iso' };
473 } elsif ($tt eq 'vztmpl') {
474 next if $fn !~ m!/([^/]+\.tar\.gz)$!;
476 $info = { volid
=> "$sid:vztmpl/$1", format
=> 'tgz' };
478 } elsif ($tt eq 'backup') {
479 next if $fn !~ m!/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz))$!;
481 $info = { volid
=> "$sid:backup/$1", format
=> $2 };
484 $info->{size
} = -s
$fn;
486 push @{$res->{$sid}}, $info;
491 @{$res->{$sid}} = sort {lc($a->{volid
}) cmp lc ($b->{volid
}) } @{$res->{$sid}} if $res->{$sid};
499 my ($cfg, $storeid, $vmid, $vollist) = @_;
501 my $ids = $cfg->{ids
};
503 storage_check_enabled
($cfg, $storeid) if ($storeid);
507 # prepare/activate/refresh all storages
509 my $storage_list = [];
511 foreach my $volid (@$vollist) {
512 my ($sid, undef) = parse_volume_id
($volid);
513 next if !defined($ids->{$sid});
514 next if !storage_check_enabled
($cfg, $sid, undef, 1);
515 push @$storage_list, $sid;
518 foreach my $sid (keys %$ids) {
519 next if $storeid && $storeid ne $sid;
520 next if !storage_check_enabled
($cfg, $sid, undef, 1);
521 push @$storage_list, $sid;
527 activate_storage_list
($cfg, $storage_list, $cache);
529 foreach my $sid (keys %$ids) {
530 next if $storeid && $storeid ne $sid;
531 next if !storage_check_enabled
($cfg, $sid, undef, 1);
533 my $scfg = $ids->{$sid};
534 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
535 $res->{$sid} = $plugin->list_images($sid, $scfg, $vmid, $vollist, $cache);
536 @{$res->{$sid}} = sort {lc($a->{volid
}) cmp lc ($b->{volid
}) } @{$res->{$sid}} if $res->{$sid};
544 my $filename = "/sys/kernel/uevent_seqnum";
547 if (my $fh = IO
::File-
>new($filename, "r")) {
549 if ($line =~ m/^(\d+)$/) {
557 sub activate_storage
{
558 my ($cfg, $storeid, $cache) = @_;
560 $cache = {} if !$cache;
562 my $scfg = storage_check_enabled
($cfg, $storeid);
564 return if $cache->{activated
}->{$storeid};
566 $cache->{uevent_seqnum
} = uevent_seqnum
() if !$cache->{uevent_seqnum
};
568 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
571 my ($baseid, undef) = parse_volume_id
($scfg->{base
});
572 activate_storage
($cfg, $baseid, $cache);
575 if (!$plugin->check_connection($storeid, $scfg)) {
576 die "storage '$storeid' is not online\n";
579 $plugin->activate_storage($storeid, $scfg, $cache);
581 my $newseq = uevent_seqnum
();
583 # only call udevsettle if there are events
584 if ($newseq > $cache->{uevent_seqnum
}) {
586 system ("$UDEVADM settle --timeout=$timeout"); # ignore errors
587 $cache->{uevent_seqnum
} = $newseq;
590 $cache->{activated
}->{$storeid} = 1;
593 sub activate_storage_list
{
594 my ($cfg, $storeid_list, $cache) = @_;
596 $cache = {} if !$cache;
598 foreach my $storeid (@$storeid_list) {
599 activate_storage
($cfg, $storeid, $cache);
603 sub deactivate_storage
{
604 my ($cfg, $storeid) = @_;
606 my $scfg = storage_config
($cfg, $storeid);
607 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
610 $plugin->deactivate_storage($storeid, $scfg, $cache);
613 sub activate_volumes
{
614 my ($cfg, $vollist, $exclusive) = @_;
616 return if !($vollist && scalar(@$vollist));
618 my $storagehash = {};
619 foreach my $volid (@$vollist) {
620 my ($storeid, undef) = parse_volume_id
($volid);
621 $storagehash->{$storeid} = 1;
626 activate_storage_list
($cfg, [keys %$storagehash], $cache);
628 foreach my $volid (@$vollist) {
629 my ($storeid, $volname) = parse_volume_id
($volid);
630 my $scfg = storage_config
($cfg, $storeid);
631 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
632 $plugin->activate_volume($storeid, $scfg, $volname, $exclusive, $cache);
636 sub deactivate_volumes
{
637 my ($cfg, $vollist) = @_;
639 return if !($vollist && scalar(@$vollist));
644 foreach my $volid (@$vollist) {
645 my ($storeid, $volname) = parse_volume_id
($volid);
647 my $scfg = storage_config
($cfg, $storeid);
648 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
651 $plugin->deactivate_volume($storeid, $scfg, $volname, $cache);
655 push @errlist, $volid;
659 die "volume deativation failed: " . join(' ', @errlist)
664 my ($cfg, $content) = @_;
666 my $ids = $cfg->{ids
};
671 foreach my $storeid (keys %$ids) {
673 next if $content && !$ids->{$storeid}->{content
}->{$content};
675 next if !storage_check_enabled
($cfg, $storeid, undef, 1);
677 my $type = $ids->{$storeid}->{type
};
679 $info->{$storeid} = {
684 shared
=> $ids->{$storeid}->{shared
} ?
1 : 0,
685 content
=> PVE
::Storage
::Plugin
::content_hash_to_string
($ids->{$storeid}->{content
}),
689 push @$slist, $storeid;
694 foreach my $storeid (keys %$ids) {
695 my $scfg = $ids->{$storeid};
696 next if !$info->{$storeid};
698 eval { activate_storage
($cfg, $storeid, $cache); };
704 my $plugin = PVE
::Storage
::Plugin-
>lookup($scfg->{type
});
705 my ($total, $avail, $used, $active);
706 eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); };
709 $info->{$storeid}->{total
} = $total;
710 $info->{$storeid}->{avail
} = $avail;
711 $info->{$storeid}->{used
} = $used;
712 $info->{$storeid}->{active
} = $active;
721 my $packed_ip = gethostbyname($server);
722 if (defined $packed_ip) {
723 return inet_ntoa
($packed_ip);
729 my ($server_in) = @_;
732 if (!($server = resolv_server
($server_in))) {
733 die "unable to resolve address for server '${server_in}'\n";
736 my $cmd = ['/sbin/showmount', '--no-headers', '--exports', $server];
739 run_command
($cmd, outfunc
=> sub {
742 # note: howto handle white spaces in export path??
743 if ($line =~ m!^(/\S+)\s+(.+)$!) {
752 my ($portal, $noerr) = @_;
754 if ($portal =~ m/^([^:]+)(:(\d+))?$/) {
758 if (my $ip = resolv_server
($server)) {
760 return $port ?
"$server:$port" : $server;
763 return undef if $noerr;
765 raise_param_exc
({ portal
=> "unable to resolve portal address '$portal'" });
768 # idea is from usbutils package (/usr/bin/usb-devices) script
769 sub __scan_usb_device
{
770 my ($res, $devpath, $parent, $level) = @_;
772 return if ! -d
$devpath;
773 return if $level && $devpath !~ m/^.*[-.](\d+)$/;
774 my $port = $level ?
int($1 - 1) : 0;
776 my $busnum = int(file_read_firstline
("$devpath/busnum"));
777 my $devnum = int(file_read_firstline
("$devpath/devnum"));
784 speed
=> file_read_firstline
("$devpath/speed"),
785 class => hex(file_read_firstline
("$devpath/bDeviceClass")),
786 vendid
=> file_read_firstline
("$devpath/idVendor"),
787 prodid
=> file_read_firstline
("$devpath/idProduct"),
791 my $usbpath = $devpath;
792 $usbpath =~ s
|^.*/\d
+\
-||;
793 $d->{usbpath
} = $usbpath;
796 my $product = file_read_firstline
("$devpath/product");
797 $d->{product
} = $product if $product;
799 my $manu = file_read_firstline
("$devpath/manufacturer");
800 $d->{manufacturer
} = $manu if $manu;
802 my $serial => file_read_firstline
("$devpath/serial");
803 $d->{serial
} = $serial if $serial;
807 foreach my $subdev (<$devpath/$busnum-*>) {
808 next if $subdev !~ m
|/$busnum-[0-9]+(\
.[0-9]+)*$|;
809 __scan_usb_device
($res, $subdev, $devnum, $level + 1);
818 foreach my $device (</sys/bus
/usb
/devices
/usb
*>) {
819 __scan_usb_device
($devlist, $device, 0, 0);
826 my ($portal_in) = @_;
829 if (!($portal = resolv_portal
($portal_in))) {
830 die "unable to parse/resolve portal address '${portal_in}'\n";
833 return PVE
::Storage
::ISCSIPlugin
::iscsi_discovery
($portal);
836 sub storage_default_format
{
837 my ($cfg, $storeid) = @_;
839 my $scfg = storage_config
($cfg, $storeid);
841 return PVE
::Storage
::Plugin
::default_format
($scfg);
845 my ($cfg, $vgname) = @_;
847 foreach my $storeid (keys %{$cfg->{ids
}}) {
848 my $scfg = storage_config
($cfg, $storeid);
849 if ($scfg->{type
} eq 'lvm' && $scfg->{vgname
} eq $vgname) {
858 my ($cfg, $target) = @_;
860 foreach my $storeid (keys %{$cfg->{ids
}}) {
861 my $scfg = storage_config
($cfg, $storeid);
862 if ($scfg->{type
} eq 'iscsi' && $scfg->{target
} eq $target) {
871 my ($cfg, $volid) = @_;
873 foreach my $storeid (keys %{$cfg->{ids
}}) {
874 my $scfg = storage_config
($cfg, $storeid);
875 if ($scfg->{base
} && $scfg->{base
} eq $volid) {
883 sub storage_is_used
{
884 my ($cfg, $storeid) = @_;
886 foreach my $sid (keys %{$cfg->{ids
}}) {
887 my $scfg = storage_config
($cfg, $sid);
888 next if !$scfg->{base
};
889 my ($st) = parse_volume_id
($scfg->{base
});
890 return 1 if $st && $st eq $storeid;
897 my ($list, $func) = @_;
901 foreach my $sid (keys %$list) {
902 foreach my $info (@{$list->{$sid}}) {
903 my $volid = $info->{volid
};
904 my ($sid1, $volname) = parse_volume_id
($volid, 1);
905 if ($sid1 && $sid1 eq $sid) {
906 &$func ($volid, $sid, $info);
908 warn "detected strange volid '$volid' in volume list for '$sid'\n";