1 package PVE
::Storage
::RBDPlugin
;
12 use PVE
::Cluster
qw(cfs_read_file);;
13 use PVE
::JSONSchema
qw(get_standard_option);
16 use PVE
::Storage
::Plugin
;
17 use PVE
::Tools
qw(run_command trim file_read_firstline);
19 use base
qw(PVE::Storage::Plugin);
21 my $get_parent_image_name = sub {
23 return undef if !$parent;
24 return $parent->{image
} . "@" . $parent->{snapshot
};
27 my $librados_connect = sub {
28 my ($scfg, $storeid, $options) = @_;
30 my $librados_config = PVE
::CephConfig
::ceph_connect_option
($scfg, $storeid);
32 my $rados = PVE
::RADOS-
>new(%$librados_config);
38 my ($scfg, $volume) = @_;
39 my $path = $scfg->{pool
} ?
$scfg->{pool
} : 'rbd';
40 $path .= "/$scfg->{namespace}" if defined($scfg->{namespace
});
41 $path .= "/$volume" if defined($volume);
45 my sub get_rbd_dev_path
{
46 my ($scfg, $storeid, $volume) = @_;
50 # NOTE: the config doesn't support this currently (but it could!), hack for qemu-server tests
51 $cluster_id = $scfg->{fsid
};
52 } elsif ($scfg->{monhost
}) {
53 my $rados = $librados_connect->($scfg, $storeid);
54 $cluster_id = $rados->mon_command({ prefix
=> 'fsid', format
=> 'json' })->{fsid
};
56 $cluster_id = cfs_read_file
('ceph.conf')->{global
}->{fsid
};
59 my $uuid_pattern = "([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})";
60 if ($cluster_id =~ qr/^${uuid_pattern}$/is) {
61 $cluster_id = $1; # use untained value
63 die "cluster fsid has invalid format\n";
66 my $rbd_path = get_rbd_path
($scfg, $volume);
67 my $pve_path = "/dev/rbd-pve/${cluster_id}/${rbd_path}";
68 my $path = "/dev/rbd/${rbd_path}";
70 if (!-e
$pve_path && -e
$path) {
71 # possibly mapped before rbd-pve rule existed
72 my $real_dev = abs_path
($path);
73 my ($rbd_id) = ($real_dev =~ m
|/dev/rbd
([0-9]+)$|);
74 my $dev_cluster_id = file_read_firstline
("/sys/devices/rbd/${rbd_id}/cluster_fsid");
75 return $path if $cluster_id eq $dev_cluster_id;
81 my ($binary, $scfg, $storeid, $op, @options) = @_;
83 my $cmd_option = PVE
::CephConfig
::ceph_connect_option
($scfg, $storeid);
84 my $pool = $scfg->{pool
} ?
$scfg->{pool
} : 'rbd';
86 my $cmd = [$binary, '-p', $pool];
88 if (defined(my $namespace = $scfg->{namespace
})) {
89 # some subcommands will fail if the --namespace parameter is present
90 my $no_namespace_parameter = {
93 push @$cmd, '--namespace', "$namespace" if !$no_namespace_parameter->{$op};
95 push @$cmd, '-c', $cmd_option->{ceph_conf
} if ($cmd_option->{ceph_conf
});
96 push @$cmd, '-m', $cmd_option->{mon_host
} if ($cmd_option->{mon_host
});
97 push @$cmd, '--auth_supported', $cmd_option->{auth_supported
} if ($cmd_option->{auth_supported
});
98 push @$cmd, '-n', "client.$cmd_option->{userid}" if ($cmd_option->{userid
});
99 push @$cmd, '--keyring', $cmd_option->{keyring
} if ($cmd_option->{keyring
});
103 push @$cmd, @options if scalar(@options);
109 my ($scfg, $storeid, $op, @options) = @_;
111 return $build_cmd->('/usr/bin/rbd', $scfg, $storeid, $op, @options);
114 my $rados_cmd = sub {
115 my ($scfg, $storeid, $op, @options) = @_;
117 return $build_cmd->('/usr/bin/rados', $scfg, $storeid, $op, @options);
120 # needed for volumes created using ceph jewel (or higher)
121 my $krbd_feature_update = sub {
122 my ($scfg, $storeid, $name) = @_;
124 my (@disable, @enable);
125 my ($kmajor, $kminor) = PVE
::ProcFSTools
::kernel_version
();
127 if ($kmajor > 5 || $kmajor == 5 && $kminor >= 3) {
128 # 'deep-flatten' can only be disabled, not enabled after image creation
129 push @enable, 'fast-diff', 'object-map';
131 push @disable, 'fast-diff', 'object-map', 'deep-flatten';
135 push @enable, 'exclusive-lock';
137 push @disable, 'exclusive-lock';
140 my $active_features_list = (rbd_volume_info
($scfg, $storeid, $name))[4];
141 my $active_features = { map { $_ => 1 } @$active_features_list };
143 my $to_disable = join(',', grep { $active_features->{$_} } @disable);
144 my $to_enable = join(',', grep { !$active_features->{$_} } @enable );
147 print "disable RBD image features this kernel RBD drivers is not compatible with: $to_disable\n";
148 my $cmd = $rbd_cmd->($scfg, $storeid, 'feature', 'disable', $name, $to_disable);
151 errmsg
=> "could not disable krbd-incompatible image features '$to_disable' for rbd image: $name",
155 print "enable RBD image features this kernel RBD drivers supports: $to_enable\n";
157 my $cmd = $rbd_cmd->($scfg, $storeid, 'feature', 'enable', $name, $to_enable);
160 errmsg
=> "could not enable krbd-compatible image features '$to_enable' for rbd image: $name",
167 sub run_rbd_command
{
168 my ($cmd, %args) = @_;
171 my $errmsg = $args{errmsg
} . ": " || "";
172 if (!exists($args{errfunc
})) {
173 # ' error: 2014-02-06 11:51:59.839135 7f09f94d0760 -1 librbd: snap_unprotect: can't unprotect;
174 # at least 1 child(ren) in pool cephstor1
175 $args{errfunc
} = sub {
177 if ($line =~ m/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]+ [\-\d]+ librbd: (.*)$/) {
182 print STDERR
$lasterr;
187 eval { run_command
($cmd, %args); };
189 die $errmsg . $lasterr if length($lasterr);
197 my ($scfg, $storeid) = @_;
199 my $pool = $scfg->{pool
} ?
$scfg->{pool
} : 'rbd';
200 $pool .= "/$scfg->{namespace}" if defined($scfg->{namespace
});
203 my $parser = sub { $raw .= shift };
205 my $cmd = $rbd_cmd->($scfg, $storeid, 'ls', '-l', '--format', 'json');
207 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> $parser);
211 die $err if $err && $err !~ m/doesn't contain rbd images/ ;
216 } elsif ($raw =~ m/^(\[.*\])$/s) { # untaint
217 $result = JSON
::decode_json
($1);
219 die "got unexpected data from rbd ls: '$raw'\n";
224 foreach my $el (@$result) {
225 next if defined($el->{snapshot
});
227 my $image = $el->{image
};
229 my ($owner) = $image =~ m/^(?:vm|base)-(\d+)-/;
230 next if !defined($owner);
232 $list->{$pool}->{$image} = {
235 parent
=> $get_parent_image_name->($el->{parent
}),
244 my ($scfg, $storeid, $name) = @_;
246 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'ls', $name, '--format', 'json');
249 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> sub { $raw .= shift; });
252 if ($raw =~ m/^(\[.*\])$/s) { # untaint
253 $list = eval { JSON
::decode_json
($1) };
254 die "invalid JSON output from 'rbd snap ls $name': $@\n" if $@;
256 die "got unexpected data from 'rbd snap ls $name': '$raw'\n";
259 $list = [] if !defined($list);
262 foreach my $el (@$list) {
263 my $snap = $el->{name
};
264 my $protected = defined($el->{protected
}) && $el->{protected
} eq "true" ?
1 : undef;
267 id
=> $el->{id
} // undef,
268 size
=> $el->{size
} // 0,
269 protected
=> $protected,
275 sub rbd_volume_info
{
276 my ($scfg, $storeid, $volname, $snap) = @_;
280 my @options = ('info', $volname, '--format', 'json');
282 push @options, '--snap', $snap;
285 $cmd = $rbd_cmd->($scfg, $storeid, @options);
288 my $parser = sub { $raw .= shift };
290 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> $parser);
295 } elsif ($raw =~ m/^(\{.*\})$/s) { # untaint
296 $volume = JSON
::decode_json
($1);
298 die "got unexpected data from rbd info: '$raw'\n";
301 $volume->{parent
} = $get_parent_image_name->($volume->{parent
});
302 $volume->{protected
} = defined($volume->{protected
}) && $volume->{protected
} eq "true" ?
1 : undef;
304 return $volume->@{qw(size parent format protected features)};
315 content
=> [ {images
=> 1, rootdir
=> 1}, { images
=> 1 }],
322 description
=> "IP addresses of monitors (for external clusters).",
323 type
=> 'string', format
=> 'pve-storage-portal-dns-list',
326 description
=> "Pool.",
330 description
=> "Data Pool (for erasure coding only)",
334 description
=> "Namespace.",
338 description
=> "RBD Id.",
342 description
=> "Authsupported.",
346 description
=> "Always access rbd through krbd kernel module.",
350 description
=> "Client keyring contents (for external clusters).",
358 nodes
=> { optional
=> 1 },
359 disable
=> { optional
=> 1 },
360 monhost
=> { optional
=> 1},
361 pool
=> { optional
=> 1 },
362 'data-pool' => { optional
=> 1 },
363 namespace
=> { optional
=> 1 },
364 username
=> { optional
=> 1 },
365 content
=> { optional
=> 1 },
366 krbd
=> { optional
=> 1 },
367 keyring
=> { optional
=> 1 },
368 bwlimit
=> { optional
=> 1 },
372 # Storage implementation
375 my ($class, $storeid, $scfg, %param) = @_;
377 my $secret = $param{keyring
} if defined $param{keyring
} // undef;
378 PVE
::CephConfig
::ceph_create_keyfile
($scfg->{type
}, $storeid, $secret);
384 my ($class, $storeid, $scfg, %param) = @_;
386 if (exists($param{keyring
})) {
387 if (defined($param{keyring
})) {
388 PVE
::CephConfig
::ceph_create_keyfile
($scfg->{type
}, $storeid, $param{keyring
});
390 PVE
::CephConfig
::ceph_remove_keyfile
($scfg->{type
}, $storeid);
398 my ($class, $storeid, $scfg) = @_;
399 PVE
::CephConfig
::ceph_remove_keyfile
($scfg->{type
}, $storeid);
404 my ($class, $volname) = @_;
406 if ($volname =~ m/^((base-(\d+)-\S+)\/)?
((base
)?
(vm
)?
-(\d
+)-\S
+)$/) {
407 return ('images', $4, $7, $2, $3, $5, 'raw');
410 die "unable to parse rbd volume name '$volname'\n";
414 my ($class, $scfg, $volname, $storeid, $snapname) = @_;
416 my $cmd_option = PVE
::CephConfig
::ceph_connect_option
($scfg, $storeid);
417 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
418 $name .= '@'.$snapname if $snapname;
420 my $rbd_dev_path = get_rbd_dev_path
($scfg, $storeid, $name);
421 return ($rbd_dev_path, $vmid, $vtype) if $scfg->{krbd
};
423 my $rbd_path = get_rbd_path
($scfg, $name);
424 my $path = "rbd:${rbd_path}";
426 $path .= ":conf=$cmd_option->{ceph_conf}" if $cmd_option->{ceph_conf
};
427 if (defined($scfg->{monhost
})) {
428 my $monhost = PVE
::CephConfig
::hostlist
($scfg->{monhost
}, ';');
429 $monhost =~ s/:/\\:/g;
430 $path .= ":mon_host=$monhost";
431 $path .= ":auth_supported=$cmd_option->{auth_supported}";
434 $path .= ":id=$cmd_option->{userid}:keyring=$cmd_option->{keyring}" if ($cmd_option->{keyring
});
436 return ($path, $vmid, $vtype);
439 sub find_free_diskname
{
440 my ($class, $storeid, $scfg, $vmid, $fmt, $add_fmt_suffix) = @_;
442 my $cmd = $rbd_cmd->($scfg, $storeid, 'ls');
448 if ($line =~ m/^(.*)$/) { # untaint
449 push @$disk_list, $1;
454 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> $parser);
458 die $err if $err && $err !~ m/doesn't contain rbd images/;
460 return PVE
::Storage
::Plugin
::get_next_vm_diskname
($disk_list, $storeid, $vmid, undef, $scfg);
464 my ($class, $storeid, $scfg, $volname) = @_;
466 my $snap = '__base__';
468 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
469 $class->parse_volname($volname);
471 die "create_base not possible with base image\n" if $isBase;
473 my ($size, $parent, $format, undef) = rbd_volume_info
($scfg, $storeid, $name);
474 die "rbd volume info on '$name' failed\n" if !($size);
476 die "rbd image must be at format V2" if $format ne "2";
478 die "volname '$volname' contains wrong information about parent $parent $basename\n"
479 if $basename && (!$parent || $parent ne $basename."@".$snap);
482 $newname =~ s/^vm-/base-/;
484 my $newvolname = $basename ?
"$basename/$newname" : "$newname";
486 my $cmd = $rbd_cmd->(
490 get_rbd_path
($scfg, $name),
491 get_rbd_path
($scfg, $newname),
493 run_rbd_command
($cmd, errmsg
=> "rbd rename '$name' error");
495 eval { $class->unmap_volume($storeid, $scfg, $volname); };
498 my $running = undef; #fixme : is create_base always offline ?
500 $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
502 my (undef, undef, undef, $protected) = rbd_volume_info
($scfg, $storeid, $newname, $snap);
505 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $newname, '--snap', $snap);
506 run_rbd_command
($cmd, errmsg
=> "rbd protect $newname snap '$snap' error");
514 my ($class, $scfg, $storeid, $volname, $vmid, $snapname) = @_;
516 my $snap = '__base__';
517 $snap = $snapname if length $snapname;
519 my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
520 $class->parse_volname($volname);
522 die "$volname is not a base image and snapname is not provided\n"
523 if !$isBase && !length($snapname);
525 my $name = $class->find_free_diskname($storeid, $scfg, $vmid);
527 warn "clone $volname: $basename snapname $snap to $name\n";
529 if (length($snapname)) {
530 my (undef, undef, undef, $protected) = rbd_volume_info
($scfg, $storeid, $volname, $snapname);
533 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $volname, '--snap', $snapname);
534 run_rbd_command
($cmd, errmsg
=> "rbd protect $volname snap $snapname error");
538 my $newvol = "$basename/$name";
539 $newvol = $name if length($snapname);
542 get_rbd_path
($scfg, $basename),
545 push @options, ('--data-pool', $scfg->{'data-pool'}) if $scfg->{'data-pool'};
547 my $cmd = $rbd_cmd->($scfg, $storeid, 'clone', @options, get_rbd_path
($scfg, $name));
548 run_rbd_command
($cmd, errmsg
=> "rbd clone '$basename' error");
554 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
557 die "illegal name '$name' - should be 'vm-$vmid-*'\n"
558 if $name && $name !~ m/^vm-$vmid-/;
560 $name = $class->find_free_diskname($storeid, $scfg, $vmid) if !$name;
563 '--image-format' , 2,
564 '--size', int(($size + 1023) / 1024),
566 push @options, ('--data-pool', $scfg->{'data-pool'}) if $scfg->{'data-pool'};
568 my $cmd = $rbd_cmd->($scfg, $storeid, 'create', @options, $name);
569 run_rbd_command
($cmd, errmsg
=> "rbd create '$name' error");
575 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
577 my ($vtype, $name, $vmid, undef, undef, undef) =
578 $class->parse_volname($volname);
581 my $snaps = rbd_ls_snap
($scfg, $storeid, $name);
582 foreach my $snap (keys %$snaps) {
583 if ($snaps->{$snap}->{protected
}) {
584 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
585 run_rbd_command
($cmd, errmsg
=> "rbd unprotect $name snap '$snap' error");
589 $class->deactivate_volume($storeid, $scfg, $volname);
591 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'purge', $name);
592 run_rbd_command
($cmd, errmsg
=> "rbd snap purge '$name' error");
594 $cmd = $rbd_cmd->($scfg, $storeid, 'rm', $name);
595 run_rbd_command
($cmd, errmsg
=> "rbd rm '$name' error");
601 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
603 $cache->{rbd
} = rbd_ls
($scfg, $storeid) if !$cache->{rbd
};
605 my $dat = $cache->{rbd
}->{get_rbd_path
($scfg)};
606 return [] if !$dat; # nothing found
609 for my $image (sort keys %$dat) {
610 my $info = $dat->{$image};
611 my ($volname, $parent, $owner) = $info->@{'name', 'parent', 'vmid'};
613 if ($parent && $parent =~ m/^(base-\d+-\S+)\@__base__$/) {
614 $info->{volid
} = "$storeid:$1/$volname";
616 $info->{volid
} = "$storeid:$volname";
620 my $found = grep { $_ eq $info->{volid
} } @$vollist;
623 next if defined ($vmid) && ($owner ne $vmid);
626 $info->{format
} = 'raw';
635 my ($class, $storeid, $scfg, $cache) = @_;
637 my $rados = $librados_connect->($scfg, $storeid);
638 my $df = $rados->mon_command({ prefix
=> 'df', format
=> 'json' });
640 my $pool = $scfg->{'data-pool'} // $scfg->{pool
} // 'rbd';
642 my ($d) = grep { $_->{name
} eq $pool } @{$df->{pools
}};
645 warn "could not get usage stats for pool '$pool'\n";
649 # max_avail -> max available space for data w/o replication in the pool
650 # bytes_used -> data w/o replication in the pool
651 my $free = $d->{stats
}->{max_avail
};
652 my $used = $d->{stats
}->{stored
} // $d->{stats
}->{bytes_used
};
653 my $total = $used + $free;
656 return ($total, $free, $used, $active);
659 sub activate_storage
{
660 my ($class, $storeid, $scfg, $cache) = @_;
664 sub deactivate_storage
{
665 my ($class, $storeid, $scfg, $cache) = @_;
670 my ($class, $storeid, $scfg, $volname, $snapname) = @_;
672 my ($vtype, $img_name, $vmid) = $class->parse_volname($volname);
674 my $name = $img_name;
675 $name .= '@'.$snapname if $snapname;
677 my $kerneldev = get_rbd_dev_path
($scfg, $storeid, $name);
679 return $kerneldev if -b
$kerneldev; # already mapped
681 # features can only be enabled/disabled for image, not for snapshot!
682 $krbd_feature_update->($scfg, $storeid, $img_name);
684 my $cmd = $rbd_cmd->($scfg, $storeid, 'map', $name);
685 run_rbd_command
($cmd, errmsg
=> "can't map rbd volume $name");
691 my ($class, $storeid, $scfg, $volname, $snapname) = @_;
693 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
694 $name .= '@'.$snapname if $snapname;
696 my $kerneldev = get_rbd_dev_path
($scfg, $storeid, $name);
699 my $cmd = $rbd_cmd->($scfg, $storeid, 'unmap', $kerneldev);
700 run_rbd_command
($cmd, errmsg
=> "can't unmap rbd device $kerneldev");
706 sub activate_volume
{
707 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
709 $class->map_volume($storeid, $scfg, $volname, $snapname) if $scfg->{krbd
};
714 sub deactivate_volume
{
715 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
717 $class->unmap_volume($storeid, $scfg, $volname, $snapname);
722 sub volume_size_info
{
723 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
725 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
726 my ($size, undef) = rbd_volume_info
($scfg, $storeid, $name);
731 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
733 return 1 if $running && !$scfg->{krbd
}; # FIXME???
735 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
737 my $cmd = $rbd_cmd->($scfg, $storeid, 'resize', '--allow-shrink', '--size', ($size/1024/1024), $name);
738 run_rbd_command
($cmd, errmsg
=> "rbd resize '$volname' error");
742 sub volume_snapshot
{
743 my ($class, $scfg, $storeid, $volname, $snap) = @_;
745 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
747 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'create', '--snap', $snap, $name);
748 run_rbd_command
($cmd, errmsg
=> "rbd snapshot '$volname' error");
752 sub volume_snapshot_rollback
{
753 my ($class, $scfg, $storeid, $volname, $snap) = @_;
755 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
757 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'rollback', '--snap', $snap, $name);
758 run_rbd_command
($cmd, errmsg
=> "rbd snapshot $volname to '$snap' error");
761 sub volume_snapshot_delete
{
762 my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
764 return 1 if $running && !$scfg->{krbd
}; # FIXME: ????
766 $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
768 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
770 my (undef, undef, undef, $protected) = rbd_volume_info
($scfg, $storeid, $name, $snap);
772 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
773 run_rbd_command
($cmd, errmsg
=> "rbd unprotect $name snap '$snap' error");
776 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'rm', '--snap', $snap, $name);
778 run_rbd_command
($cmd, errmsg
=> "rbd snapshot '$volname' error");
783 sub volume_snapshot_needs_fsfreeze
{
787 sub volume_has_feature
{
788 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
791 snapshot
=> { current
=> 1, snap
=> 1},
792 clone
=> { base
=> 1, snap
=> 1},
793 template
=> { current
=> 1},
794 copy
=> { base
=> 1, current
=> 1, snap
=> 1},
795 sparseinit
=> { base
=> 1, current
=> 1},
796 rename => {current
=> 1},
799 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) = $class->parse_volname($volname);
805 $key = $isBase ?
'base' : 'current';
807 return 1 if $features->{$feature}->{$key};
813 my ($class, $scfg, $storeid, $source_volname, $target_vmid, $target_volname) = @_;
823 ) = $class->parse_volname($source_volname);
824 $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format)
828 my $cmd = $rbd_cmd->($scfg, $storeid, 'info', $target_volname);
829 run_rbd_command
($cmd, errmsg
=> "exist check", quiet
=> 1);
831 die "target volume '${target_volname}' already exists\n" if !$@;
833 my $cmd = $rbd_cmd->($scfg, $storeid, 'rename', $source_image, $target_volname);
837 errmsg
=> "could not rename image '${source_image}' to '${target_volname}'",
840 eval { $class->unmap_volume($storeid, $scfg, $source_volname); };
843 $base_name = $base_name ?
"${base_name}/" : '';
845 return "${storeid}:${base_name}${target_volname}";