]>
Commit | Line | Data |
---|---|---|
1dc01b9f DM |
1 | package PVE::Storage::Plugin; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use File::Path; | |
6 | use PVE::Tools qw(run_command); | |
7 | use PVE::JSONSchema qw(get_standard_option); | |
8 | use PVE::Cluster qw(cfs_register_file); | |
9 | ||
10 | use Data::Dumper; | |
11 | ||
12 | use base qw(PVE::SectionConfig); | |
13 | ||
14 | cfs_register_file ('storage.cfg', | |
15 | sub { __PACKAGE__->parse_config(@_); }, | |
16 | sub { __PACKAGE__->write_config(@_); }); | |
17 | ||
18 | my $defaultData = { | |
19 | propertyList => { | |
20 | type => { description => "Storage type." }, | |
21 | storage => get_standard_option('pve-storage-id'), | |
22 | nodes => get_standard_option('pve-node-list', { optional => 1 }), | |
23 | content => { | |
24 | description => "Allowed content types.", | |
25 | type => 'string', format => 'pve-storage-content-list', | |
26 | optional => 1, | |
27 | }, | |
28 | disable => { | |
29 | description => "Flag to disable the storage.", | |
30 | type => 'boolean', | |
31 | optional => 1, | |
32 | }, | |
33 | maxfiles => { | |
34 | description => "Maximal number of backup files per VM. Use '0' for unlimted.", | |
35 | type => 'integer', | |
36 | minimum => 0, | |
37 | optional => 1, | |
38 | }, | |
39 | shared => { | |
40 | description => "Mark storage as shared.", | |
41 | type => 'boolean', | |
42 | optional => 1, | |
43 | }, | |
44 | 'format' => { | |
45 | description => "Default Image format.", | |
46 | type => 'string', format => 'pve-storage-format', | |
47 | optional => 1, | |
48 | }, | |
49 | }, | |
50 | }; | |
51 | ||
52 | sub content_hash_to_string { | |
53 | my $hash = shift; | |
54 | ||
55 | my @cta; | |
56 | foreach my $ct (keys %$hash) { | |
57 | push @cta, $ct if $hash->{$ct}; | |
58 | } | |
59 | ||
60 | return join(',', @cta); | |
61 | } | |
62 | ||
63 | sub valid_content_types { | |
64 | my ($type) = @_; | |
65 | ||
66 | my $def = $defaultData->{plugindata}->{$type}; | |
67 | ||
68 | return {} if !$def; | |
69 | ||
70 | return $def->{content}->[0]; | |
71 | } | |
72 | ||
73 | sub default_format { | |
74 | my ($scfg) = @_; | |
75 | ||
76 | my $type = $scfg->{type}; | |
77 | my $def = $defaultData->{plugindata}->{$type}; | |
78 | ||
79 | my $def_format = 'raw'; | |
80 | my $valid_formats = [ $def_format ]; | |
81 | ||
82 | if (defined($def->{format})) { | |
83 | $def_format = $scfg->{format} || $def->{format}->[1]; | |
84 | $valid_formats = [ sort keys %{$def->{format}->[0]} ]; | |
85 | } | |
86 | ||
87 | return wantarray ? ($def_format, $valid_formats) : $def_format; | |
88 | } | |
89 | ||
90 | PVE::JSONSchema::register_format('pve-storage-path', \&verify_path); | |
91 | sub verify_path { | |
92 | my ($path, $noerr) = @_; | |
93 | ||
94 | # fixme: exclude more shell meta characters? | |
95 | # we need absolute paths | |
96 | if ($path !~ m|^/[^;\(\)]+|) { | |
97 | return undef if $noerr; | |
98 | die "value does not look like a valid absolute path\n"; | |
99 | } | |
100 | return $path; | |
101 | } | |
102 | ||
103 | PVE::JSONSchema::register_format('pve-storage-server', \&verify_server); | |
104 | sub verify_server { | |
105 | my ($server, $noerr) = @_; | |
106 | ||
107 | # fixme: use better regex ? | |
108 | # IP or DNS name | |
109 | if ($server !~ m/^[[:alnum:]\-\.]+$/) { | |
110 | return undef if $noerr; | |
111 | die "value does not look like a valid server name or IP address\n"; | |
112 | } | |
113 | return $server; | |
114 | } | |
115 | ||
116 | # fixme: do we need this | |
117 | #PVE::JSONSchema::register_format('pve-storage-portal', \&verify_portal); | |
118 | #sub verify_portal { | |
119 | # my ($portal, $noerr) = @_; | |
120 | # | |
121 | # # IP with optional port | |
122 | # if ($portal !~ m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d+)?$/) { | |
123 | # return undef if $noerr; | |
124 | # die "value does not look like a valid portal address\n"; | |
125 | # } | |
126 | # return $portal; | |
127 | #} | |
128 | ||
129 | PVE::JSONSchema::register_format('pve-storage-portal-dns', \&verify_portal_dns); | |
130 | sub verify_portal_dns { | |
131 | my ($portal, $noerr) = @_; | |
132 | ||
133 | # IP or DNS name with optional port | |
134 | if ($portal !~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[[:alnum:]\-\.]+)(:\d+)?$/) { | |
135 | return undef if $noerr; | |
136 | die "value does not look like a valid portal address\n"; | |
137 | } | |
138 | return $portal; | |
139 | } | |
140 | ||
141 | PVE::JSONSchema::register_format('pve-storage-content', \&verify_content); | |
142 | sub verify_content { | |
143 | my ($ct, $noerr) = @_; | |
144 | ||
145 | my $valid_content = valid_content_types('dir'); # dir includes all types | |
146 | ||
147 | if (!$valid_content->{$ct}) { | |
148 | return undef if $noerr; | |
149 | die "invalid content type '$ct'\n"; | |
150 | } | |
151 | ||
152 | return $ct; | |
153 | } | |
154 | ||
155 | PVE::JSONSchema::register_format('pve-storage-format', \&verify_format); | |
156 | sub verify_format { | |
157 | my ($fmt, $noerr) = @_; | |
158 | ||
159 | if ($fmt !~ m/(raw|qcow2|vmdk)/) { | |
160 | return undef if $noerr; | |
161 | die "invalid format '$fmt'\n"; | |
162 | } | |
163 | ||
164 | return $fmt; | |
165 | } | |
166 | ||
167 | PVE::JSONSchema::register_format('pve-storage-options', \&verify_options); | |
168 | sub verify_options { | |
169 | my ($value, $noerr) = @_; | |
170 | ||
171 | # mount options (see man fstab) | |
172 | if ($value !~ m/^\S+$/) { | |
173 | return undef if $noerr; | |
174 | die "invalid options '$value'\n"; | |
175 | } | |
176 | ||
177 | return $value; | |
178 | } | |
179 | ||
180 | ||
181 | sub private { | |
182 | return $defaultData; | |
183 | } | |
184 | ||
185 | sub parse_section_header { | |
186 | my ($class, $line) = @_; | |
187 | ||
188 | if ($line =~ m/^(\S+):\s*(\S+)\s*$/) { | |
189 | my ($type, $storeid) = (lc($1), $2); | |
190 | my $errmsg = undef; # set if you want to skip whole section | |
191 | eval { PVE::JSONSchema::parse_storage_id($storeid); }; | |
192 | $errmsg = $@ if $@; | |
193 | my $config = {}; # to return additional attributes | |
194 | return ($type, $storeid, $errmsg, $config); | |
195 | } | |
196 | return undef; | |
197 | } | |
198 | ||
199 | sub decode_value { | |
200 | my ($class, $type, $key, $value) = @_; | |
201 | ||
202 | my $def = $defaultData->{plugindata}->{$type}; | |
203 | ||
204 | if ($key eq 'content') { | |
205 | my $valid_content = $def->{content}->[0]; | |
206 | ||
207 | my $res = {}; | |
208 | ||
209 | foreach my $c (PVE::Tools::split_list($value)) { | |
210 | if (!$valid_content->{$c}) { | |
211 | die "storage does not support content type '$c'\n"; | |
212 | } | |
213 | $res->{$c} = 1; | |
214 | } | |
215 | ||
216 | if ($res->{none} && scalar (keys %$res) > 1) { | |
217 | die "unable to combine 'none' with other content types\n"; | |
218 | } | |
219 | ||
220 | return $res; | |
221 | } elsif ($key eq 'format') { | |
222 | my $valid_formats = $def->{format}->[0]; | |
223 | ||
224 | if (!$valid_formats->{$value}) { | |
225 | die "storage does not support format '$value'\n"; | |
226 | } | |
227 | ||
228 | return $value; | |
229 | } elsif ($key eq 'nodes') { | |
230 | my $res = {}; | |
231 | ||
232 | foreach my $node (PVE::Tools::split_list($value)) { | |
233 | if (PVE::JSONSchema::pve_verify_node_name($node)) { | |
234 | $res->{$node} = 1; | |
235 | } | |
236 | } | |
237 | ||
238 | # fixme: | |
239 | # no node restrictions for local storage | |
240 | #if ($storeid && $storeid eq 'local' && scalar(keys(%$res))) { | |
241 | # die "storage '$storeid' does not allow node restrictions\n"; | |
242 | #} | |
243 | ||
244 | return $res; | |
245 | } | |
246 | ||
247 | return $value; | |
248 | } | |
249 | ||
250 | sub encode_value { | |
251 | my ($class, $type, $key, $value) = @_; | |
252 | ||
253 | if ($key eq 'nodes') { | |
254 | return join(',', keys(%$value)); | |
255 | } elsif ($key eq 'content') { | |
256 | my $res = content_hash_to_string($value) || 'none'; | |
257 | return $res; | |
258 | } | |
259 | ||
260 | return $value; | |
261 | } | |
262 | ||
263 | sub parse_config { | |
264 | my ($class, $filename, $raw) = @_; | |
265 | ||
266 | my $cfg = $class->SUPER::parse_config($filename, $raw); | |
267 | my $ids = $cfg->{ids}; | |
268 | ||
269 | # make sure we have a reasonable 'local:' storage | |
270 | # openvz expects things to be there | |
271 | if (!$ids->{local} || $ids->{local}->{type} ne 'dir' || | |
272 | ($ids->{local}->{path} && $ids->{local}->{path} ne '/var/lib/vz')) { | |
273 | $ids->{local} = { | |
274 | type => 'dir', | |
275 | priority => 0, # force first entry | |
276 | path => '/var/lib/vz', | |
277 | maxfiles => 0, | |
278 | content => { images => 1, rootdir => 1, vztmpl => 1, iso => 1}, | |
279 | }; | |
280 | } | |
281 | ||
282 | # we always need this for OpenVZ | |
283 | $ids->{local}->{content}->{rootdir} = 1; | |
284 | $ids->{local}->{content}->{vztmpl} = 1; | |
285 | delete ($ids->{local}->{disable}); | |
286 | ||
287 | # make sure we have a path | |
288 | $ids->{local}->{path} = '/var/lib/vz' if !$ids->{local}->{path}; | |
289 | ||
290 | # remove node restrictions for local storage | |
291 | delete($ids->{local}->{nodes}); | |
292 | ||
293 | foreach my $storeid (keys %$ids) { | |
294 | my $d = $ids->{$storeid}; | |
295 | my $type = $d->{type}; | |
296 | ||
297 | my $def = $defaultData->{plugindata}->{$type}; | |
298 | ||
299 | if ($def->{content}) { | |
300 | $d->{content} = $def->{content}->[1] if !$d->{content}; | |
301 | } | |
302 | ||
40cd7d27 | 303 | if ($type eq 'iscsi' || $type eq 'nfs' || $type eq 'rbd' || $type eq 'sheepdog' || $type eq 'iscsidirect' || $type eq 'nexenta' ) { |
1dc01b9f DM |
304 | $d->{shared} = 1; |
305 | } | |
306 | } | |
307 | ||
308 | return $cfg; | |
309 | } | |
310 | ||
311 | # Storage implementation | |
312 | ||
313 | sub cluster_lock_storage { | |
314 | my ($class, $storeid, $shared, $timeout, $func, @param) = @_; | |
315 | ||
316 | my $res; | |
317 | if (!$shared) { | |
318 | my $lockid = "pve-storage-$storeid"; | |
319 | my $lockdir = "/var/lock/pve-manager"; | |
320 | mkdir $lockdir; | |
321 | $res = PVE::Tools::lock_file("$lockdir/$lockid", $timeout, $func, @param); | |
322 | die $@ if $@; | |
323 | } else { | |
324 | $res = PVE::Cluster::cfs_lock_storage($storeid, $timeout, $func, @param); | |
325 | die $@ if $@; | |
326 | } | |
327 | return $res; | |
328 | } | |
329 | ||
330 | sub parse_name_dir { | |
331 | my $name = shift; | |
332 | ||
333 | if ($name =~ m!^([^/\s]+\.(raw|qcow2|vmdk))$!) { | |
334 | return ($1, $2); | |
335 | } | |
336 | ||
337 | die "unable to parse volume filename '$name'\n"; | |
338 | } | |
339 | ||
340 | sub parse_volname { | |
341 | my ($class, $volname) = @_; | |
342 | ||
343 | if ($volname =~ m!^(\d+)/(\S+)$!) { | |
344 | my ($vmid, $name) = ($1, $2); | |
345 | parse_name_dir($name); | |
346 | return ('images', $name, $vmid); | |
347 | } elsif ($volname =~ m!^iso/([^/]+\.[Ii][Ss][Oo])$!) { | |
348 | return ('iso', $1); | |
349 | } elsif ($volname =~ m!^vztmpl/([^/]+\.tar\.gz)$!) { | |
350 | return ('vztmpl', $1); | |
351 | } elsif ($volname =~ m!^rootdir/(\d+)$!) { | |
352 | return ('rootdir', $1, $1); | |
353 | } elsif ($volname =~ m!^backup/([^/]+(\.(tar|tar\.gz|tar\.lzo|tgz)))$!) { | |
354 | my $fn = $1; | |
355 | if ($fn =~ m/^vzdump-(openvz|qemu)-(\d+)-.+/) { | |
356 | return ('backup', $fn, $2); | |
357 | } | |
358 | return ('backup', $fn); | |
359 | } | |
360 | ||
361 | die "unable to parse directory volume name '$volname'\n"; | |
362 | } | |
363 | ||
364 | my $vtype_subdirs = { | |
365 | images => 'images', | |
366 | rootdir => 'private', | |
367 | iso => 'template/iso', | |
368 | vztmpl => 'template/cache', | |
369 | backup => 'dump', | |
370 | }; | |
371 | ||
372 | sub get_subdir { | |
373 | my ($class, $scfg, $vtype) = @_; | |
374 | ||
375 | my $path = $scfg->{path}; | |
376 | ||
377 | die "storage definintion has no path\n" if !$path; | |
378 | ||
379 | my $subdir = $vtype_subdirs->{$vtype}; | |
380 | ||
381 | die "unknown vtype '$vtype'\n" if !defined($subdir); | |
382 | ||
383 | return "$path/$subdir"; | |
384 | } | |
385 | ||
386 | sub path { | |
6bf56298 | 387 | my ($class, $scfg, $volname, $storeid) = @_; |
1dc01b9f DM |
388 | |
389 | my ($vtype, $name, $vmid) = $class->parse_volname($volname); | |
390 | ||
391 | my $dir = $class->get_subdir($scfg, $vtype); | |
392 | ||
393 | $dir .= "/$vmid" if $vtype eq 'images'; | |
394 | ||
395 | my $path = "$dir/$name"; | |
396 | ||
397 | return wantarray ? ($path, $vmid, $vtype) : $path; | |
398 | } | |
399 | ||
400 | sub alloc_image { | |
401 | my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_; | |
402 | ||
403 | my $imagedir = $class->get_subdir($scfg, 'images'); | |
404 | $imagedir .= "/$vmid"; | |
405 | ||
406 | mkpath $imagedir; | |
407 | ||
408 | if (!$name) { | |
409 | for (my $i = 1; $i < 100; $i++) { | |
410 | my @gr = <$imagedir/vm-$vmid-disk-$i.*>; | |
411 | if (!scalar(@gr)) { | |
412 | $name = "vm-$vmid-disk-$i.$fmt"; | |
413 | last; | |
414 | } | |
415 | } | |
416 | } | |
417 | ||
418 | die "unable to allocate an image name for VM $vmid in storage '$storeid'\n" | |
419 | if !$name; | |
420 | ||
421 | my (undef, $tmpfmt) = parse_name_dir($name); | |
422 | ||
423 | die "illegal name '$name' - wrong extension for format ('$tmpfmt != '$fmt')\n" | |
424 | if $tmpfmt ne $fmt; | |
425 | ||
426 | my $path = "$imagedir/$name"; | |
427 | ||
428 | die "disk image '$path' already exists\n" if -e $path; | |
429 | ||
430 | run_command("/usr/bin/qemu-img create -f $fmt '$path' ${size}K", | |
431 | errmsg => "unable to create image"); | |
432 | ||
433 | return "$vmid/$name"; | |
434 | } | |
435 | ||
436 | sub free_image { | |
437 | my ($class, $storeid, $scfg, $volname) = @_; | |
438 | ||
439 | my $path = $class->path($scfg, $volname); | |
440 | ||
441 | if (! -f $path) { | |
442 | warn "disk image '$path' does not exists\n"; | |
443 | } else { | |
444 | unlink $path; | |
445 | } | |
446 | ||
447 | return undef; | |
448 | } | |
449 | ||
450 | sub file_size_info { | |
451 | my ($filename, $timeout) = @_; | |
452 | ||
453 | my $cmd = ['/usr/bin/qemu-img', 'info', $filename]; | |
454 | ||
455 | my $format; | |
456 | my $size = 0; | |
457 | my $used = 0; | |
458 | ||
459 | eval { | |
460 | run_command($cmd, timeout => $timeout, outfunc => sub { | |
461 | my $line = shift; | |
462 | ||
463 | if ($line =~ m/^file format:\s+(\S+)\s*$/) { | |
464 | $format = $1; | |
465 | } elsif ($line =~ m/^virtual size:\s\S+\s+\((\d+)\s+bytes\)$/) { | |
466 | $size = int($1); | |
467 | } elsif ($line =~ m/^disk size:\s+(\d+(.\d+)?)([KMGT])\s*$/) { | |
468 | $used = $1; | |
469 | my $u = $3; | |
470 | ||
471 | $used *= 1024 if $u eq 'K'; | |
472 | $used *= (1024*1024) if $u eq 'M'; | |
473 | $used *= (1024*1024*1024) if $u eq 'G'; | |
474 | $used *= (1024*1024*1024*1024) if $u eq 'T'; | |
475 | ||
476 | $used = int($used); | |
477 | } | |
478 | }); | |
479 | }; | |
480 | ||
481 | return wantarray ? ($size, $format, $used) : $size; | |
482 | } | |
483 | ||
e47e548e AD |
484 | sub volume_size_info { |
485 | my ($class, $scfg, $storeid, $volname, $timeout) = @_; | |
486 | my $path = $class->path($scfg, $volname); | |
487 | return file_size_info($path, $timeout); | |
488 | ||
489 | } | |
490 | ||
81f5058c AD |
491 | sub volume_resize { |
492 | my ($class, $scfg, $storeid, $volname, $size, $running) = @_; | |
493 | ||
494 | die "can't resize this image format" if $volname !~ m/\.(raw|qcow2)$/; | |
495 | ||
496 | return 1 if $running; | |
497 | ||
498 | my $path = $class->path($scfg, $volname); | |
499 | ||
500 | my $cmd = ['/usr/bin/qemu-img', 'resize', $path , $size]; | |
501 | ||
502 | run_command($cmd, timeout => 1); | |
503 | ||
504 | return undef; | |
505 | } | |
506 | ||
7dcb0697 AD |
507 | sub volume_snapshot { |
508 | my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; | |
509 | ||
510 | die "can't snapshot this image format" if $volname !~ m/\.(qcow2|qed)$/; | |
511 | ||
512 | return 1 if $running; | |
513 | ||
514 | my $path = $class->path($scfg, $volname); | |
515 | ||
516 | my $cmd = ['/usr/bin/qemu-img', 'snapshot','-c', $snap, $path]; | |
517 | ||
518 | run_command($cmd, timeout => 1); | |
519 | ||
520 | return undef; | |
521 | } | |
522 | ||
41dffa85 AD |
523 | sub volume_snapshot_rollback { |
524 | my ($class, $scfg, $storeid, $volname, $snap) = @_; | |
525 | ||
526 | die "can't rollback snapshot this image format" if $volname !~ m/\.(qcow2|qed)$/; | |
527 | ||
528 | my $path = $class->path($scfg, $volname); | |
529 | ||
530 | my $cmd = ['/usr/bin/qemu-img', 'snapshot','-a', $snap, $path]; | |
531 | ||
532 | run_command($cmd, timeout => 1); | |
533 | ||
534 | return undef; | |
535 | } | |
536 | ||
6000a061 AD |
537 | sub volume_snapshot_delete { |
538 | my ($class, $scfg, $storeid, $volname, $snap, $running) = @_; | |
539 | ||
540 | die "can't delete snapshot for this image format" if $volname !~ m/\.(qcow2|qed)$/; | |
541 | ||
542 | return 1 if $running; | |
543 | ||
544 | my $path = $class->path($scfg, $volname); | |
545 | ||
546 | my $cmd = ['/usr/bin/qemu-img', 'snapshot','-d', $snap, $path]; | |
547 | ||
548 | run_command($cmd, timeout => 1); | |
549 | ||
550 | return undef; | |
551 | } | |
552 | ||
1dc01b9f DM |
553 | sub list_images { |
554 | my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_; | |
555 | ||
556 | my $imagedir = $class->get_subdir($scfg, 'images'); | |
557 | ||
558 | my ($defFmt, $vaidFmts) = default_format($scfg); | |
559 | my $fmts = join ('|', @$vaidFmts); | |
560 | ||
561 | my $res = []; | |
562 | ||
563 | foreach my $fn (<$imagedir/[0-9][0-9]*/*>) { | |
564 | ||
565 | next if $fn !~ m!^(/.+/(\d+)/([^/]+\.($fmts)))$!; | |
566 | $fn = $1; # untaint | |
567 | ||
568 | my $owner = $2; | |
569 | my $name = $3; | |
570 | my $volid = "$storeid:$owner/$name"; | |
571 | ||
572 | if ($vollist) { | |
573 | my $found = grep { $_ eq $volid } @$vollist; | |
574 | next if !$found; | |
575 | } else { | |
576 | next if defined($vmid) && ($owner ne $vmid); | |
577 | } | |
578 | ||
579 | my ($size, $format, $used) = file_size_info($fn); | |
580 | ||
581 | if ($format && $size) { | |
582 | push @$res, { | |
583 | volid => $volid, format => $format, | |
584 | size => $size, vmid => $owner, used => $used }; | |
585 | } | |
586 | ||
587 | } | |
588 | ||
589 | return $res; | |
590 | } | |
591 | ||
592 | sub status { | |
593 | my ($class, $storeid, $scfg, $cache) = @_; | |
594 | ||
595 | my $path = $scfg->{path}; | |
596 | ||
597 | die "storage definintion has no path\n" if !$path; | |
598 | ||
599 | my $timeout = 2; | |
600 | my $res = PVE::Tools::df($path, $timeout); | |
601 | ||
602 | return undef if !$res || !$res->{total}; | |
603 | ||
604 | return ($res->{total}, $res->{avail}, $res->{used}, 1); | |
605 | } | |
606 | ||
607 | sub activate_storage { | |
608 | my ($class, $storeid, $scfg, $cache) = @_; | |
609 | ||
610 | my $path = $scfg->{path}; | |
611 | ||
612 | die "storage definintion has no path\n" if !$path; | |
613 | ||
614 | die "unable to activate storage '$storeid' - " . | |
615 | "directory '$path' does not exist\n" if ! -d $path; | |
616 | ||
617 | if (defined($scfg->{content})) { | |
618 | foreach my $vtype (keys %$vtype_subdirs) { | |
619 | next if !defined($scfg->{content}->{$vtype}); | |
620 | my $subdir = $class->get_subdir($scfg, $vtype); | |
621 | mkpath $subdir if $subdir ne $path; | |
622 | } | |
623 | } | |
624 | } | |
625 | ||
626 | sub deactivate_storage { | |
627 | my ($class, $storeid, $scfg, $cache) = @_; | |
628 | ||
629 | # do nothing by default | |
630 | } | |
631 | ||
632 | sub activate_volume { | |
633 | my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_; | |
634 | ||
635 | my $path = $class->path($scfg, $volname); | |
636 | ||
637 | # check is volume exists | |
638 | if ($scfg->{path}) { | |
639 | die "volume '$storeid:$volname' does not exist\n" if ! -e $path; | |
640 | } else { | |
641 | die "volume '$storeid:$volname' does not exist\n" if ! -b $path; | |
642 | } | |
643 | } | |
644 | ||
645 | sub deactivate_volume { | |
646 | my ($class, $storeid, $scfg, $volname, $cache) = @_; | |
647 | ||
648 | # do nothing by default | |
649 | } | |
650 | ||
c9eeac01 AD |
651 | sub check_connection { |
652 | my ($class, $storeid, $scfg) = @_; | |
653 | # do nothing by default | |
654 | return 1; | |
655 | } | |
656 | ||
e47e548e | 657 | |
1dc01b9f | 658 | 1; |