]> git.proxmox.com Git - pve-storage.git/blame_incremental - PVE/Storage/LVMPlugin.pm
lvm thin: don't assume that a thin pool and its volumes are active
[pve-storage.git] / PVE / Storage / LVMPlugin.pm
... / ...
CommitLineData
1package PVE::Storage::LVMPlugin;
2
3use strict;
4use warnings;
5
6use IO::File;
7
8use PVE::Tools qw(run_command trim);
9use PVE::Storage::Plugin;
10use PVE::JSONSchema qw(get_standard_option);
11
12use base qw(PVE::Storage::Plugin);
13
14# lvm helper functions
15
16my $ignore_no_medium_warnings = sub {
17 my $line = shift;
18 # ignore those, most of the time they're from (virtual) IPMI/iKVM devices
19 # and just spam the log..
20 if ($line !~ /open failed: No medium found/) {
21 print STDERR "$line\n";
22 }
23};
24
25sub lvm_pv_info {
26 my ($device) = @_;
27
28 die "no device specified" if !$device;
29
30 my $has_label = 0;
31
32 my $cmd = ['/usr/bin/file', '-L', '-s', $device];
33 run_command($cmd, outfunc => sub {
34 my $line = shift;
35 $has_label = 1 if $line =~ m/LVM2/;
36 });
37
38 return undef if !$has_label;
39
40 $cmd = ['/sbin/pvs', '--separator', ':', '--noheadings', '--units', 'k',
41 '--unbuffered', '--nosuffix', '--options',
42 'pv_name,pv_size,vg_name,pv_uuid', $device];
43
44 my $pvinfo;
45 run_command($cmd, outfunc => sub {
46 my $line = shift;
47
48 $line = trim($line);
49
50 my ($pvname, $size, $vgname, $uuid) = split(':', $line);
51
52 die "found multiple pvs entries for device '$device'\n"
53 if $pvinfo;
54
55 $pvinfo = {
56 pvname => $pvname,
57 size => int($size),
58 vgname => $vgname,
59 uuid => $uuid,
60 };
61 });
62
63 return $pvinfo;
64}
65
66sub clear_first_sector {
67 my ($dev) = shift;
68
69 if (my $fh = IO::File->new($dev, "w")) {
70 my $buf = 0 x 512;
71 syswrite $fh, $buf;
72 $fh->close();
73 }
74}
75
76sub lvm_create_volume_group {
77 my ($device, $vgname, $shared) = @_;
78
79 my $res = lvm_pv_info($device);
80
81 if ($res->{vgname}) {
82 return if $res->{vgname} eq $vgname; # already created
83 die "device '$device' is already used by volume group '$res->{vgname}'\n";
84 }
85
86 clear_first_sector($device); # else pvcreate fails
87
88 # we use --metadatasize 250k, which reseults in "pe_start = 512"
89 # so pe_start is aligned on a 128k boundary (advantage for SSDs)
90 my $cmd = ['/sbin/pvcreate', '--metadatasize', '250k', $device];
91
92 run_command($cmd, errmsg => "pvcreate '$device' error");
93
94 $cmd = ['/sbin/vgcreate', $vgname, $device];
95 # push @$cmd, '-c', 'y' if $shared; # we do not use this yet
96
97 run_command($cmd, errmsg => "vgcreate $vgname $device error", errfunc => $ignore_no_medium_warnings, outfunc => $ignore_no_medium_warnings);
98}
99
100sub lvm_destroy_volume_group {
101 my ($vgname) = @_;
102
103 run_command(
104 ['vgremove', '-y', $vgname],
105 errmsg => "unable to remove volume group $vgname",
106 errfunc => $ignore_no_medium_warnings,
107 outfunc => $ignore_no_medium_warnings,
108 );
109}
110
111sub lvm_vgs {
112 my ($includepvs) = @_;
113
114 my $cmd = ['/sbin/vgs', '--separator', ':', '--noheadings', '--units', 'b',
115 '--unbuffered', '--nosuffix', '--options'];
116
117 my $cols = [qw(vg_name vg_size vg_free lv_count)];
118
119 if ($includepvs) {
120 push @$cols, qw(pv_name pv_size pv_free);
121 }
122
123 push @$cmd, join(',', @$cols);
124
125 my $vgs = {};
126 eval {
127 run_command($cmd, outfunc => sub {
128 my $line = shift;
129 $line = trim($line);
130
131 my ($name, $size, $free, $lvcount, $pvname, $pvsize, $pvfree) = split (':', $line);
132
133 $vgs->{$name} //= {
134 size => int ($size),
135 free => int ($free),
136 lvcount => int($lvcount)
137 };
138
139 if (defined($pvname) && defined($pvsize) && defined($pvfree)) {
140 push @{$vgs->{$name}->{pvs}}, {
141 name => $pvname,
142 size => int($pvsize),
143 free => int($pvfree),
144 };
145 }
146 },
147 errfunc => $ignore_no_medium_warnings,
148 );
149 };
150 my $err = $@;
151
152 # just warn (vgs return error code 5 if clvmd does not run)
153 # but output is still OK (list without clustered VGs)
154 warn $err if $err;
155
156 return $vgs;
157}
158
159sub lvm_list_volumes {
160 my ($vgname) = @_;
161
162 my $option_list = 'vg_name,lv_name,lv_size,lv_attr,pool_lv,data_percent,metadata_percent,snap_percent,uuid,tags,metadata_size,time';
163
164 my $cmd = [
165 '/sbin/lvs', '--separator', ':', '--noheadings', '--units', 'b',
166 '--unbuffered', '--nosuffix',
167 '--config', 'report/time_format="%s"',
168 '--options', $option_list,
169 ];
170
171 push @$cmd, $vgname if $vgname;
172
173 my $lvs = {};
174 run_command($cmd, outfunc => sub {
175 my $line = shift;
176
177 $line = trim($line);
178
179 my ($vg_name, $lv_name, $lv_size, $lv_attr, $pool_lv, $data_percent, $meta_percent, $snap_percent, $uuid, $tags, $meta_size, $ctime) = split(':', $line);
180 return if !$vg_name;
181 return if !$lv_name;
182
183 my $lv_type = substr($lv_attr, 0, 1);
184
185 my $d = {
186 lv_size => int($lv_size),
187 lv_state => substr($lv_attr, 4, 1),
188 lv_type => $lv_type,
189 };
190 $d->{pool_lv} = $pool_lv if $pool_lv;
191 $d->{tags} = $tags if $tags;
192 $d->{ctime} = $ctime;
193
194 if ($lv_type eq 't') {
195 $data_percent ||= 0;
196 $meta_percent ||= 0;
197 $snap_percent ||= 0;
198 $d->{metadata_size} = int($meta_size);
199 $d->{metadata_used} = int(($meta_percent * $meta_size)/100);
200 $d->{used} = int(($data_percent * $lv_size)/100);
201 }
202 $lvs->{$vg_name}->{$lv_name} = $d;
203 },
204 errfunc => $ignore_no_medium_warnings,
205 );
206
207 return $lvs;
208}
209
210# Configuration
211
212sub type {
213 return 'lvm';
214}
215
216sub plugindata {
217 return {
218 content => [ {images => 1, rootdir => 1}, { images => 1 }],
219 };
220}
221
222sub properties {
223 return {
224 vgname => {
225 description => "Volume group name.",
226 type => 'string', format => 'pve-storage-vgname',
227 },
228 base => {
229 description => "Base volume. This volume is automatically activated.",
230 type => 'string', format => 'pve-volume-id',
231 },
232 saferemove => {
233 description => "Zero-out data when removing LVs.",
234 type => 'boolean',
235 },
236 saferemove_throughput => {
237 description => "Wipe throughput (cstream -t parameter value).",
238 type => 'string',
239 },
240 tagged_only => {
241 description => "Only use logical volumes tagged with 'pve-vm-ID'.",
242 type => 'boolean',
243 }
244 };
245}
246
247sub options {
248 return {
249 vgname => { fixed => 1 },
250 nodes => { optional => 1 },
251 shared => { optional => 1 },
252 disable => { optional => 1 },
253 saferemove => { optional => 1 },
254 saferemove_throughput => { optional => 1 },
255 content => { optional => 1 },
256 base => { fixed => 1, optional => 1 },
257 tagged_only => { optional => 1 },
258 bwlimit => { optional => 1 },
259 };
260}
261
262# Storage implementation
263
264sub on_add_hook {
265 my ($class, $storeid, $scfg, %param) = @_;
266
267 if (my $base = $scfg->{base}) {
268 my ($baseid, $volname) = PVE::Storage::parse_volume_id($base);
269
270 my $cfg = PVE::Storage::config();
271 my $basecfg = PVE::Storage::storage_config ($cfg, $baseid, 1);
272 die "base storage ID '$baseid' does not exist\n" if !$basecfg;
273
274 # we only support iscsi for now
275 die "unsupported base type '$basecfg->{type}'"
276 if $basecfg->{type} ne 'iscsi';
277
278 my $path = PVE::Storage::path($cfg, $base);
279
280 PVE::Storage::activate_storage($cfg, $baseid);
281
282 lvm_create_volume_group($path, $scfg->{vgname}, $scfg->{shared});
283 }
284
285 return;
286}
287
288sub parse_volname {
289 my ($class, $volname) = @_;
290
291 PVE::Storage::Plugin::parse_lvm_name($volname);
292
293 if ($volname =~ m/^(vm-(\d+)-\S+)$/) {
294 return ('images', $1, $2, undef, undef, undef, 'raw');
295 }
296
297 die "unable to parse lvm volume name '$volname'\n";
298}
299
300sub filesystem_path {
301 my ($class, $scfg, $volname, $snapname) = @_;
302
303 die "lvm snapshot is not implemented"if defined($snapname);
304
305 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
306
307 my $vg = $scfg->{vgname};
308
309 my $path = "/dev/$vg/$name";
310
311 return wantarray ? ($path, $vmid, $vtype) : $path;
312}
313
314sub create_base {
315 my ($class, $storeid, $scfg, $volname) = @_;
316
317 die "can't create base images in lvm storage\n";
318}
319
320sub clone_image {
321 my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
322
323 die "can't clone images in lvm storage\n";
324}
325
326sub find_free_diskname {
327 my ($class, $storeid, $scfg, $vmid, $fmt, $add_fmt_suffix) = @_;
328
329 my $vg = $scfg->{vgname};
330
331 my $lvs = lvm_list_volumes($vg);
332
333 my $disk_list = [ keys %{$lvs->{$vg}} ];
334
335 return PVE::Storage::Plugin::get_next_vm_diskname($disk_list, $storeid, $vmid, undef, $scfg);
336}
337
338sub lvcreate {
339 my ($vg, $name, $size, $tags) = @_;
340
341 if ($size =~ m/\d$/) { # no unit is given
342 $size .= "k"; # default to kilobytes
343 }
344
345 my $cmd = ['/sbin/lvcreate', '-aly', '-Wy', '--yes', '--size', $size, '--name', $name];
346 for my $tag (@$tags) {
347 push @$cmd, '--addtag', $tag;
348 }
349 push @$cmd, $vg;
350
351 run_command($cmd, errmsg => "lvcreate '$vg/$name' error");
352}
353
354sub lvrename {
355 my ($vg, $oldname, $newname) = @_;
356
357 run_command(
358 ['/sbin/lvrename', $vg, $oldname, $newname],
359 errmsg => "lvrename '${vg}/${oldname}' to '${newname}' error",
360 );
361}
362
363sub alloc_image {
364 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
365
366 die "unsupported format '$fmt'" if $fmt ne 'raw';
367
368 die "illegal name '$name' - should be 'vm-$vmid-*'\n"
369 if $name && $name !~ m/^vm-$vmid-/;
370
371 my $vgs = lvm_vgs();
372
373 my $vg = $scfg->{vgname};
374
375 die "no such volume group '$vg'\n" if !defined ($vgs->{$vg});
376
377 my $free = int($vgs->{$vg}->{free});
378
379 die "not enough free space ($free < $size)\n" if $free < $size;
380
381 $name = $class->find_free_diskname($storeid, $scfg, $vmid)
382 if !$name;
383
384 lvcreate($vg, $name, $size, ["pve-vm-$vmid"]);
385
386 return $name;
387}
388
389sub free_image {
390 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
391
392 my $vg = $scfg->{vgname};
393
394 # we need to zero out LVM data for security reasons
395 # and to allow thin provisioning
396
397 my $zero_out_worker = sub {
398 print "zero-out data on image $volname (/dev/$vg/del-$volname)\n";
399
400 # wipe throughput up to 10MB/s by default; may be overwritten with saferemove_throughput
401 my $throughput = '-10485760';
402 if ($scfg->{saferemove_throughput}) {
403 $throughput = $scfg->{saferemove_throughput};
404 }
405
406 my $cmd = [
407 '/usr/bin/cstream',
408 '-i', '/dev/zero',
409 '-o', "/dev/$vg/del-$volname",
410 '-T', '10',
411 '-v', '1',
412 '-b', '1048576',
413 '-t', "$throughput"
414 ];
415 eval { run_command($cmd, errmsg => "zero out finished (note: 'No space left on device' is ok here)"); };
416 warn $@ if $@;
417
418 $class->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
419 my $cmd = ['/sbin/lvremove', '-f', "$vg/del-$volname"];
420 run_command($cmd, errmsg => "lvremove '$vg/del-$volname' error");
421 });
422 print "successfully removed volume $volname ($vg/del-$volname)\n";
423 };
424
425 my $cmd = ['/sbin/lvchange', '-aly', "$vg/$volname"];
426 run_command($cmd, errmsg => "can't activate LV '$vg/$volname' to zero-out its data");
427 $cmd = ['/sbin/lvchange', '--refresh', "$vg/$volname"];
428 run_command($cmd, errmsg => "can't refresh LV '$vg/$volname' to zero-out its data");
429
430 if ($scfg->{saferemove}) {
431 # avoid long running task, so we only rename here
432 $cmd = ['/sbin/lvrename', $vg, $volname, "del-$volname"];
433 run_command($cmd, errmsg => "lvrename '$vg/$volname' error");
434 return $zero_out_worker;
435 } else {
436 my $tmpvg = $scfg->{vgname};
437 $cmd = ['/sbin/lvremove', '-f', "$tmpvg/$volname"];
438 run_command($cmd, errmsg => "lvremove '$tmpvg/$volname' error");
439 }
440
441 return undef;
442}
443
444my $check_tags = sub {
445 my ($tags) = @_;
446
447 return defined($tags) && $tags =~ /(^|,)pve-vm-\d+(,|$)/;
448};
449
450sub list_images {
451 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
452
453 my $vgname = $scfg->{vgname};
454
455 $cache->{lvs} = lvm_list_volumes() if !$cache->{lvs};
456
457 my $res = [];
458
459 if (my $dat = $cache->{lvs}->{$vgname}) {
460
461 foreach my $volname (keys %$dat) {
462
463 next if $volname !~ m/^vm-(\d+)-/;
464 my $owner = $1;
465
466 my $info = $dat->{$volname};
467
468 next if $scfg->{tagged_only} && !&$check_tags($info->{tags});
469
470 # Allow mirrored and RAID LVs
471 next if $info->{lv_type} !~ m/^[-mMrR]$/;
472
473 my $volid = "$storeid:$volname";
474
475 if ($vollist) {
476 my $found = grep { $_ eq $volid } @$vollist;
477 next if !$found;
478 } else {
479 next if defined($vmid) && ($owner ne $vmid);
480 }
481
482 push @$res, {
483 volid => $volid, format => 'raw', size => $info->{lv_size}, vmid => $owner,
484 ctime => $info->{ctime},
485 };
486 }
487 }
488
489 return $res;
490}
491
492sub status {
493 my ($class, $storeid, $scfg, $cache) = @_;
494
495 $cache->{vgs} = lvm_vgs() if !$cache->{vgs};
496
497 my $vgname = $scfg->{vgname};
498
499 if (my $info = $cache->{vgs}->{$vgname}) {
500 return ($info->{size}, $info->{free}, $info->{size} - $info->{free}, 1);
501 }
502
503 return undef;
504}
505
506sub activate_storage {
507 my ($class, $storeid, $scfg, $cache) = @_;
508
509 $cache->{vgs} = lvm_vgs() if !$cache->{vgs};
510
511 # In LVM2, vgscans take place automatically;
512 # this is just to be sure
513 if ($cache->{vgs} && !$cache->{vgscaned} &&
514 !$cache->{vgs}->{$scfg->{vgname}}) {
515 $cache->{vgscaned} = 1;
516 my $cmd = ['/sbin/vgscan', '--ignorelockingfailure', '--mknodes'];
517 eval { run_command($cmd, outfunc => sub {}); };
518 warn $@ if $@;
519 }
520
521 # we do not acticate any volumes here ('vgchange -aly')
522 # instead, volumes are activate individually later
523}
524
525sub deactivate_storage {
526 my ($class, $storeid, $scfg, $cache) = @_;
527
528 my $cmd = ['/sbin/vgchange', '-aln', $scfg->{vgname}];
529 run_command($cmd, errmsg => "can't deactivate VG '$scfg->{vgname}'");
530}
531
532sub activate_volume {
533 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
534 #fix me lvmchange is not provided on
535 my $path = $class->path($scfg, $volname, $snapname);
536
537 my $lvm_activate_mode = 'ey';
538
539 my $cmd = ['/sbin/lvchange', "-a$lvm_activate_mode", $path];
540 run_command($cmd, errmsg => "can't activate LV '$path'");
541 $cmd = ['/sbin/lvchange', '--refresh', $path];
542 run_command($cmd, errmsg => "can't refresh LV '$path' for activation");
543}
544
545sub deactivate_volume {
546 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
547
548 my $path = $class->path($scfg, $volname, $snapname);
549 return if ! -b $path;
550
551 my $cmd = ['/sbin/lvchange', '-aln', $path];
552 run_command($cmd, errmsg => "can't deactivate LV '$path'");
553}
554
555sub volume_resize {
556 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
557
558 $size = ($size/1024/1024) . "M";
559
560 my $path = $class->path($scfg, $volname);
561 my $cmd = ['/sbin/lvextend', '-L', $size, $path];
562
563 $class->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
564 run_command($cmd, errmsg => "error resizing volume '$path'");
565 });
566
567 return 1;
568}
569
570sub volume_size_info {
571 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
572 my $path = $class->filesystem_path($scfg, $volname);
573
574 my $cmd = ['/sbin/lvs', '--separator', ':', '--noheadings', '--units', 'b',
575 '--unbuffered', '--nosuffix', '--options', 'lv_size', $path];
576
577 my $size;
578 run_command($cmd, timeout => $timeout, errmsg => "can't get size of '$path'",
579 outfunc => sub {
580 $size = int(shift);
581 });
582 return wantarray ? ($size, 'raw', 0, undef) : $size;
583}
584
585sub volume_snapshot {
586 my ($class, $scfg, $storeid, $volname, $snap) = @_;
587
588 die "lvm snapshot is not implemented";
589}
590
591sub volume_snapshot_rollback {
592 my ($class, $scfg, $storeid, $volname, $snap) = @_;
593
594 die "lvm snapshot rollback is not implemented";
595}
596
597sub volume_snapshot_delete {
598 my ($class, $scfg, $storeid, $volname, $snap) = @_;
599
600 die "lvm snapshot delete is not implemented";
601}
602
603sub volume_has_feature {
604 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
605
606 my $features = {
607 copy => { base => 1, current => 1},
608 rename => {current => 1},
609 };
610
611 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
612 $class->parse_volname($volname);
613
614 my $key = undef;
615 if($snapname){
616 $key = 'snap';
617 }else{
618 $key = $isBase ? 'base' : 'current';
619 }
620 return 1 if $features->{$feature}->{$key};
621
622 return undef;
623}
624
625sub volume_export_formats {
626 my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
627 return () if defined($snapshot); # lvm-thin only
628 return volume_import_formats($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots);
629}
630
631sub volume_export {
632 my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots) = @_;
633 die "volume export format $format not available for $class\n"
634 if $format ne 'raw+size';
635 die "cannot export volumes together with their snapshots in $class\n"
636 if $with_snapshots;
637 die "cannot export a snapshot in $class\n" if defined($snapshot);
638 die "cannot export an incremental stream in $class\n" if defined($base_snapshot);
639 my $file = $class->path($scfg, $volname, $storeid);
640 my $size;
641 # should be faster than querying LVM, also checks for the device file's availability
642 run_command(['/sbin/blockdev', '--getsize64', $file], outfunc => sub {
643 my ($line) = @_;
644 die "unexpected output from /sbin/blockdev: $line\n" if $line !~ /^(\d+)$/;
645 $size = int($1);
646 });
647 PVE::Storage::Plugin::write_common_header($fh, $size);
648 run_command(['dd', "if=$file", "bs=64k"], output => '>&'.fileno($fh));
649}
650
651sub volume_import_formats {
652 my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
653 return () if $with_snapshots; # not supported
654 return () if defined($base_snapshot); # not supported
655 return ('raw+size');
656}
657
658sub volume_import {
659 my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots, $allow_rename) = @_;
660 die "volume import format $format not available for $class\n"
661 if $format ne 'raw+size';
662 die "cannot import volumes together with their snapshots in $class\n"
663 if $with_snapshots;
664 die "cannot import an incremental stream in $class\n" if defined($base_snapshot);
665
666 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $file_format) =
667 $class->parse_volname($volname);
668 die "cannot import format $format into a file of format $file_format\n"
669 if $file_format ne 'raw';
670
671 my $vg = $scfg->{vgname};
672 my $lvs = lvm_list_volumes($vg);
673 if ($lvs->{$vg}->{$volname}) {
674 die "volume $vg/$volname already exists\n" if !$allow_rename;
675 warn "volume $vg/$volname already exists - importing with a different name\n";
676 $name = undef;
677 }
678
679 my ($size) = PVE::Storage::Plugin::read_common_header($fh);
680 $size = int($size/1024);
681
682 eval {
683 my $allocname = $class->alloc_image($storeid, $scfg, $vmid, 'raw', $name, $size);
684 my $oldname = $volname;
685 $volname = $allocname;
686 if (defined($name) && $allocname ne $oldname) {
687 die "internal error: unexpected allocated name: '$allocname' != '$oldname'\n";
688 }
689 my $file = $class->path($scfg, $volname, $storeid)
690 or die "internal error: failed to get path to newly allocated volume $volname\n";
691
692 $class->volume_import_write($fh, $file);
693 };
694 if (my $err = $@) {
695 my $cleanup_worker = eval { $class->free_image($storeid, $scfg, $volname, 0) };
696 warn $@ if $@;
697
698 if ($cleanup_worker) {
699 my $rpcenv = PVE::RPCEnvironment::get();
700 my $authuser = $rpcenv->get_user();
701
702 $rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
703 }
704
705 die $err;
706 }
707
708 return "$storeid:$volname";
709}
710
711sub volume_import_write {
712 my ($class, $input_fh, $output_file) = @_;
713 run_command(['dd', "of=$output_file", 'bs=64k'],
714 input => '<&'.fileno($input_fh));
715}
716
717sub rename_volume {
718 my ($class, $scfg, $storeid, $source_volname, $target_vmid, $target_volname) = @_;
719
720 my (
721 undef,
722 $source_image,
723 $source_vmid,
724 $base_name,
725 $base_vmid,
726 undef,
727 $format
728 ) = $class->parse_volname($source_volname);
729 $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format)
730 if !$target_volname;
731
732 my $vg = $scfg->{vgname};
733 my $lvs = lvm_list_volumes($vg);
734 die "target volume '${target_volname}' already exists\n"
735 if ($lvs->{$vg}->{$target_volname});
736
737 lvrename($vg, $source_volname, $target_volname);
738 return "${storeid}:${target_volname}";
739}
740
7411;