1 package PVE
::Storage
::RBDPlugin
;
12 use PVE
::Cluster
qw(cfs_read_file);;
13 use PVE
::JSONSchema
qw(get_standard_option);
16 use PVE
::RPCEnvironment
;
17 use PVE
::Storage
::Plugin
;
18 use PVE
::Tools
qw(run_command trim file_read_firstline);
20 use base
qw(PVE::Storage::Plugin);
22 my $get_parent_image_name = sub {
24 return undef if !$parent;
25 return $parent->{image
} . "@" . $parent->{snapshot
};
28 my $librados_connect = sub {
29 my ($scfg, $storeid, $options) = @_;
31 $options->{timeout
} = 60
32 if !defined($options->{timeout
}) && PVE
::RPCEnvironment-
>is_worker();
34 my $librados_config = PVE
::CephConfig
::ceph_connect_option
($scfg, $storeid, $options->%*);
36 my $rados = PVE
::RADOS-
>new(%$librados_config);
42 my ($scfg, $volume) = @_;
43 my $path = $scfg->{pool
} ?
$scfg->{pool
} : 'rbd';
44 $path .= "/$scfg->{namespace}" if defined($scfg->{namespace
});
45 $path .= "/$volume" if defined($volume);
49 my sub get_rbd_dev_path
{
50 my ($scfg, $storeid, $volume) = @_;
54 # NOTE: the config doesn't support this currently (but it could!), hack for qemu-server tests
55 $cluster_id = $scfg->{fsid
};
56 } elsif ($scfg->{monhost
}) {
57 my $rados = $librados_connect->($scfg, $storeid);
58 $cluster_id = $rados->mon_command({ prefix
=> 'fsid', format
=> 'json' })->{fsid
};
60 $cluster_id = cfs_read_file
('ceph.conf')->{global
}->{fsid
};
63 my $uuid_pattern = "([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})";
64 if ($cluster_id =~ qr/^${uuid_pattern}$/is) {
65 $cluster_id = $1; # use untained value
67 die "cluster fsid has invalid format\n";
70 my $rbd_path = get_rbd_path
($scfg, $volume);
71 my $pve_path = "/dev/rbd-pve/${cluster_id}/${rbd_path}";
72 my $path = "/dev/rbd/${rbd_path}";
74 if (!-e
$pve_path && -e
$path) {
75 # possibly mapped before rbd-pve rule existed
76 my $real_dev = abs_path
($path);
77 my ($rbd_id) = ($real_dev =~ m
|/dev/rbd
([0-9]+)$|);
78 my $dev_cluster_id = file_read_firstline
("/sys/devices/rbd/${rbd_id}/cluster_fsid");
79 return $path if $cluster_id eq $dev_cluster_id;
85 my ($binary, $scfg, $storeid, $op, @options) = @_;
87 my $cmd_option = PVE
::CephConfig
::ceph_connect_option
($scfg, $storeid);
88 my $pool = $scfg->{pool
} ?
$scfg->{pool
} : 'rbd';
90 my $cmd = [$binary, '-p', $pool];
92 if (defined(my $namespace = $scfg->{namespace
})) {
93 # some subcommands will fail if the --namespace parameter is present
94 my $no_namespace_parameter = {
97 push @$cmd, '--namespace', "$namespace" if !$no_namespace_parameter->{$op};
99 push @$cmd, '-c', $cmd_option->{ceph_conf
} if ($cmd_option->{ceph_conf
});
100 push @$cmd, '-m', $cmd_option->{mon_host
} if ($cmd_option->{mon_host
});
101 push @$cmd, '--auth_supported', $cmd_option->{auth_supported
} if ($cmd_option->{auth_supported
});
102 push @$cmd, '-n', "client.$cmd_option->{userid}" if ($cmd_option->{userid
});
103 push @$cmd, '--keyring', $cmd_option->{keyring
} if ($cmd_option->{keyring
});
107 push @$cmd, @options if scalar(@options);
113 my ($scfg, $storeid, $op, @options) = @_;
115 return $build_cmd->('/usr/bin/rbd', $scfg, $storeid, $op, @options);
118 my $rados_cmd = sub {
119 my ($scfg, $storeid, $op, @options) = @_;
121 return $build_cmd->('/usr/bin/rados', $scfg, $storeid, $op, @options);
124 # needed for volumes created using ceph jewel (or higher)
125 my $krbd_feature_update = sub {
126 my ($scfg, $storeid, $name) = @_;
128 my (@disable, @enable);
129 my ($kmajor, $kminor) = PVE
::ProcFSTools
::kernel_version
();
131 if ($kmajor > 5 || $kmajor == 5 && $kminor >= 3) {
132 # 'deep-flatten' can only be disabled, not enabled after image creation
133 push @enable, 'fast-diff', 'object-map';
135 push @disable, 'fast-diff', 'object-map', 'deep-flatten';
139 push @enable, 'exclusive-lock';
141 push @disable, 'exclusive-lock';
144 my $active_features_list = (rbd_volume_info
($scfg, $storeid, $name))[4];
145 my $active_features = { map { $_ => 1 } @$active_features_list };
147 my $to_disable = join(',', grep { $active_features->{$_} } @disable);
148 my $to_enable = join(',', grep { !$active_features->{$_} } @enable );
151 print "disable RBD image features this kernel RBD drivers is not compatible with: $to_disable\n";
152 my $cmd = $rbd_cmd->($scfg, $storeid, 'feature', 'disable', $name, $to_disable);
155 errmsg
=> "could not disable krbd-incompatible image features '$to_disable' for rbd image: $name",
159 print "enable RBD image features this kernel RBD drivers supports: $to_enable\n";
161 my $cmd = $rbd_cmd->($scfg, $storeid, 'feature', 'enable', $name, $to_enable);
164 errmsg
=> "could not enable krbd-compatible image features '$to_enable' for rbd image: $name",
171 sub run_rbd_command
{
172 my ($cmd, %args) = @_;
175 my $errmsg = $args{errmsg
} . ": " || "";
176 if (!exists($args{errfunc
})) {
177 # ' error: 2014-02-06 11:51:59.839135 7f09f94d0760 -1 librbd: snap_unprotect: can't unprotect;
178 # at least 1 child(ren) in pool cephstor1
179 $args{errfunc
} = sub {
181 if ($line =~ m/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [0-9a-f]+ [\-\d]+ librbd: (.*)$/) {
186 print STDERR
$lasterr;
191 eval { run_command
($cmd, %args); };
193 die $errmsg . $lasterr if length($lasterr);
201 my ($scfg, $storeid) = @_;
203 my $pool = $scfg->{pool
} ?
$scfg->{pool
} : 'rbd';
204 $pool .= "/$scfg->{namespace}" if defined($scfg->{namespace
});
207 my $parser = sub { $raw .= shift };
209 my $cmd = $rbd_cmd->($scfg, $storeid, 'ls', '-l', '--format', 'json');
211 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> $parser);
215 die $err if $err && $err !~ m/doesn't contain rbd images/ ;
220 } elsif ($raw =~ m/^(\[.*\])$/s) { # untaint
221 $result = JSON
::decode_json
($1);
223 die "got unexpected data from rbd ls: '$raw'\n";
228 foreach my $el (@$result) {
229 next if defined($el->{snapshot
});
231 my $image = $el->{image
};
233 my ($owner) = $image =~ m/^(?:vm|base)-(\d+)-/;
234 next if !defined($owner);
236 $list->{$pool}->{$image} = {
239 parent
=> $get_parent_image_name->($el->{parent
}),
248 my ($scfg, $storeid, $name) = @_;
250 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'ls', $name, '--format', 'json');
253 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> sub { $raw .= shift; });
256 if ($raw =~ m/^(\[.*\])$/s) { # untaint
257 $list = eval { JSON
::decode_json
($1) };
258 die "invalid JSON output from 'rbd snap ls $name': $@\n" if $@;
260 die "got unexpected data from 'rbd snap ls $name': '$raw'\n";
263 $list = [] if !defined($list);
266 foreach my $el (@$list) {
267 my $snap = $el->{name
};
268 my $protected = defined($el->{protected
}) && $el->{protected
} eq "true" ?
1 : undef;
271 id
=> $el->{id
} // undef,
272 size
=> $el->{size
} // 0,
273 protected
=> $protected,
279 sub rbd_volume_info
{
280 my ($scfg, $storeid, $volname, $snap) = @_;
284 my @options = ('info', $volname, '--format', 'json');
286 push @options, '--snap', $snap;
289 $cmd = $rbd_cmd->($scfg, $storeid, @options);
292 my $parser = sub { $raw .= shift };
294 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> $parser);
299 } elsif ($raw =~ m/^(\{.*\})$/s) { # untaint
300 $volume = JSON
::decode_json
($1);
302 die "got unexpected data from rbd info: '$raw'\n";
305 $volume->{parent
} = $get_parent_image_name->($volume->{parent
});
306 $volume->{protected
} = defined($volume->{protected
}) && $volume->{protected
} eq "true" ?
1 : undef;
308 return $volume->@{qw(size parent format protected features)};
319 content
=> [ {images
=> 1, rootdir
=> 1}, { images
=> 1 }],
326 description
=> "IP addresses of monitors (for external clusters).",
327 type
=> 'string', format
=> 'pve-storage-portal-dns-list',
330 description
=> "Pool.",
334 description
=> "Data Pool (for erasure coding only)",
338 description
=> "Namespace.",
342 description
=> "RBD Id.",
346 description
=> "Authsupported.",
350 description
=> "Always access rbd through krbd kernel module.",
354 description
=> "Client keyring contents (for external clusters).",
362 nodes
=> { optional
=> 1 },
363 disable
=> { optional
=> 1 },
364 monhost
=> { optional
=> 1},
365 pool
=> { optional
=> 1 },
366 'data-pool' => { optional
=> 1 },
367 namespace
=> { optional
=> 1 },
368 username
=> { optional
=> 1 },
369 content
=> { optional
=> 1 },
370 krbd
=> { optional
=> 1 },
371 keyring
=> { optional
=> 1 },
372 bwlimit
=> { optional
=> 1 },
376 # Storage implementation
379 my ($class, $storeid, $scfg, %param) = @_;
381 my $secret = $param{keyring
} if defined $param{keyring
} // undef;
382 PVE
::CephConfig
::ceph_create_keyfile
($scfg->{type
}, $storeid, $secret);
388 my ($class, $storeid, $scfg, %param) = @_;
390 if (exists($param{keyring
})) {
391 if (defined($param{keyring
})) {
392 PVE
::CephConfig
::ceph_create_keyfile
($scfg->{type
}, $storeid, $param{keyring
});
394 PVE
::CephConfig
::ceph_remove_keyfile
($scfg->{type
}, $storeid);
402 my ($class, $storeid, $scfg) = @_;
403 PVE
::CephConfig
::ceph_remove_keyfile
($scfg->{type
}, $storeid);
408 my ($class, $volname) = @_;
410 if ($volname =~ m/^((base-(\d+)-\S+)\/)?
((base
)?
(vm
)?
-(\d
+)-\S
+)$/) {
411 return ('images', $4, $7, $2, $3, $5, 'raw');
414 die "unable to parse rbd volume name '$volname'\n";
418 my ($class, $scfg, $volname, $storeid, $snapname) = @_;
420 my $cmd_option = PVE
::CephConfig
::ceph_connect_option
($scfg, $storeid);
421 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
422 $name .= '@'.$snapname if $snapname;
425 my $rbd_dev_path = get_rbd_dev_path
($scfg, $storeid, $name);
426 return ($rbd_dev_path, $vmid, $vtype);
429 my $rbd_path = get_rbd_path
($scfg, $name);
430 my $path = "rbd:${rbd_path}";
432 $path .= ":conf=$cmd_option->{ceph_conf}" if $cmd_option->{ceph_conf
};
433 if (defined($scfg->{monhost
})) {
434 my $monhost = PVE
::CephConfig
::hostlist
($scfg->{monhost
}, ';');
435 $monhost =~ s/:/\\:/g;
436 $path .= ":mon_host=$monhost";
437 $path .= ":auth_supported=$cmd_option->{auth_supported}";
440 $path .= ":id=$cmd_option->{userid}:keyring=$cmd_option->{keyring}" if ($cmd_option->{keyring
});
442 return ($path, $vmid, $vtype);
445 sub find_free_diskname
{
446 my ($class, $storeid, $scfg, $vmid, $fmt, $add_fmt_suffix) = @_;
448 my $cmd = $rbd_cmd->($scfg, $storeid, 'ls');
454 if ($line =~ m/^(.*)$/) { # untaint
455 push @$disk_list, $1;
460 run_rbd_command
($cmd, errmsg
=> "rbd error", errfunc
=> sub {}, outfunc
=> $parser);
464 die $err if $err && $err !~ m/doesn't contain rbd images/;
466 return PVE
::Storage
::Plugin
::get_next_vm_diskname
($disk_list, $storeid, $vmid, undef, $scfg);
470 my ($class, $storeid, $scfg, $volname) = @_;
472 my $snap = '__base__';
474 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
475 $class->parse_volname($volname);
477 die "create_base not possible with base image\n" if $isBase;
479 my ($size, $parent, $format, undef) = rbd_volume_info
($scfg, $storeid, $name);
480 die "rbd volume info on '$name' failed\n" if !($size);
482 die "rbd image must be at format V2" if $format ne "2";
484 die "volname '$volname' contains wrong information about parent $parent $basename\n"
485 if $basename && (!$parent || $parent ne $basename."@".$snap);
488 $newname =~ s/^vm-/base-/;
490 my $newvolname = $basename ?
"$basename/$newname" : "$newname";
492 my $cmd = $rbd_cmd->(
496 get_rbd_path
($scfg, $name),
497 get_rbd_path
($scfg, $newname),
499 run_rbd_command
($cmd, errmsg
=> "rbd rename '$name' error");
501 eval { $class->unmap_volume($storeid, $scfg, $volname); };
504 my $running = undef; #fixme : is create_base always offline ?
506 $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
508 my (undef, undef, undef, $protected) = rbd_volume_info
($scfg, $storeid, $newname, $snap);
511 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $newname, '--snap', $snap);
512 run_rbd_command
($cmd, errmsg
=> "rbd protect $newname snap '$snap' error");
520 my ($class, $scfg, $storeid, $volname, $vmid, $snapname) = @_;
522 my $snap = '__base__';
523 $snap = $snapname if length $snapname;
525 my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
526 $class->parse_volname($volname);
528 die "$volname is not a base image and snapname is not provided\n"
529 if !$isBase && !length($snapname);
531 my $name = $class->find_free_diskname($storeid, $scfg, $vmid);
533 warn "clone $volname: $basename snapname $snap to $name\n";
535 if (length($snapname)) {
536 my (undef, undef, undef, $protected) = rbd_volume_info
($scfg, $storeid, $volname, $snapname);
539 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $volname, '--snap', $snapname);
540 run_rbd_command
($cmd, errmsg
=> "rbd protect $volname snap $snapname error");
544 my $newvol = "$basename/$name";
545 $newvol = $name if length($snapname);
548 get_rbd_path
($scfg, $basename),
551 push @options, ('--data-pool', $scfg->{'data-pool'}) if $scfg->{'data-pool'};
553 my $cmd = $rbd_cmd->($scfg, $storeid, 'clone', @options, get_rbd_path
($scfg, $name));
554 run_rbd_command
($cmd, errmsg
=> "rbd clone '$basename' error");
560 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
563 die "illegal name '$name' - should be 'vm-$vmid-*'\n"
564 if $name && $name !~ m/^vm-$vmid-/;
566 $name = $class->find_free_diskname($storeid, $scfg, $vmid) if !$name;
569 '--image-format' , 2,
570 '--size', int(($size + 1023) / 1024),
572 push @options, ('--data-pool', $scfg->{'data-pool'}) if $scfg->{'data-pool'};
574 my $cmd = $rbd_cmd->($scfg, $storeid, 'create', @options, $name);
575 run_rbd_command
($cmd, errmsg
=> "rbd create '$name' error");
581 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
583 my ($vtype, $name, $vmid, undef, undef, undef) =
584 $class->parse_volname($volname);
587 my $snaps = rbd_ls_snap
($scfg, $storeid, $name);
588 foreach my $snap (keys %$snaps) {
589 if ($snaps->{$snap}->{protected
}) {
590 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
591 run_rbd_command
($cmd, errmsg
=> "rbd unprotect $name snap '$snap' error");
595 $class->deactivate_volume($storeid, $scfg, $volname);
597 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'purge', $name);
598 run_rbd_command
($cmd, errmsg
=> "rbd snap purge '$name' error");
600 $cmd = $rbd_cmd->($scfg, $storeid, 'rm', $name);
601 run_rbd_command
($cmd, errmsg
=> "rbd rm '$name' error");
607 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
609 $cache->{rbd
} = rbd_ls
($scfg, $storeid) if !$cache->{rbd
};
611 my $dat = $cache->{rbd
}->{get_rbd_path
($scfg)};
612 return [] if !$dat; # nothing found
615 for my $image (sort keys %$dat) {
616 my $info = $dat->{$image};
617 my ($volname, $parent, $owner) = $info->@{'name', 'parent', 'vmid'};
619 if ($parent && $parent =~ m/^(base-\d+-\S+)\@__base__$/) {
620 $info->{volid
} = "$storeid:$1/$volname";
622 $info->{volid
} = "$storeid:$volname";
626 my $found = grep { $_ eq $info->{volid
} } @$vollist;
629 next if defined ($vmid) && ($owner ne $vmid);
632 $info->{format
} = 'raw';
641 my ($class, $storeid, $scfg, $cache) = @_;
643 my $rados = $librados_connect->($scfg, $storeid);
644 my $df = $rados->mon_command({ prefix
=> 'df', format
=> 'json' });
646 my $pool = $scfg->{'data-pool'} // $scfg->{pool
} // 'rbd';
648 my ($d) = grep { $_->{name
} eq $pool } @{$df->{pools
}};
651 warn "could not get usage stats for pool '$pool'\n";
655 # max_avail -> max available space for data w/o replication in the pool
656 # bytes_used -> data w/o replication in the pool
657 my $free = $d->{stats
}->{max_avail
};
658 my $used = $d->{stats
}->{stored
} // $d->{stats
}->{bytes_used
};
659 my $total = $used + $free;
662 return ($total, $free, $used, $active);
665 sub activate_storage
{
666 my ($class, $storeid, $scfg, $cache) = @_;
670 sub deactivate_storage
{
671 my ($class, $storeid, $scfg, $cache) = @_;
676 my ($class, $storeid, $scfg, $volname, $snapname) = @_;
678 my ($vtype, $img_name, $vmid) = $class->parse_volname($volname);
680 my $name = $img_name;
681 $name .= '@'.$snapname if $snapname;
683 my $kerneldev = get_rbd_dev_path
($scfg, $storeid, $name);
685 return $kerneldev if -b
$kerneldev; # already mapped
687 # features can only be enabled/disabled for image, not for snapshot!
688 $krbd_feature_update->($scfg, $storeid, $img_name);
690 my $cmd = $rbd_cmd->($scfg, $storeid, 'map', $name);
691 run_rbd_command
($cmd, errmsg
=> "can't map rbd volume $name");
697 my ($class, $storeid, $scfg, $volname, $snapname) = @_;
699 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
700 $name .= '@'.$snapname if $snapname;
702 my $kerneldev = get_rbd_dev_path
($scfg, $storeid, $name);
705 my $cmd = $rbd_cmd->($scfg, $storeid, 'unmap', $kerneldev);
706 run_rbd_command
($cmd, errmsg
=> "can't unmap rbd device $kerneldev");
712 sub activate_volume
{
713 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
715 $class->map_volume($storeid, $scfg, $volname, $snapname) if $scfg->{krbd
};
720 sub deactivate_volume
{
721 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
723 $class->unmap_volume($storeid, $scfg, $volname, $snapname);
728 sub volume_size_info
{
729 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
731 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
732 my ($size, undef) = rbd_volume_info
($scfg, $storeid, $name);
737 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
739 return 1 if $running && !$scfg->{krbd
}; # FIXME???
741 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
743 my $cmd = $rbd_cmd->($scfg, $storeid, 'resize', '--allow-shrink', '--size', ($size/1024/1024), $name);
744 run_rbd_command
($cmd, errmsg
=> "rbd resize '$volname' error");
748 sub volume_snapshot
{
749 my ($class, $scfg, $storeid, $volname, $snap) = @_;
751 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
753 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'create', '--snap', $snap, $name);
754 run_rbd_command
($cmd, errmsg
=> "rbd snapshot '$volname' error");
758 sub volume_snapshot_rollback
{
759 my ($class, $scfg, $storeid, $volname, $snap) = @_;
761 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
763 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'rollback', '--snap', $snap, $name);
764 run_rbd_command
($cmd, errmsg
=> "rbd snapshot $volname to '$snap' error");
767 sub volume_snapshot_delete
{
768 my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
770 return 1 if $running && !$scfg->{krbd
}; # FIXME: ????
772 $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
774 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
776 my (undef, undef, undef, $protected) = rbd_volume_info
($scfg, $storeid, $name, $snap);
778 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
779 run_rbd_command
($cmd, errmsg
=> "rbd unprotect $name snap '$snap' error");
782 my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'rm', '--snap', $snap, $name);
784 run_rbd_command
($cmd, errmsg
=> "rbd snapshot '$volname' error");
789 sub volume_snapshot_needs_fsfreeze
{
793 sub volume_has_feature
{
794 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
797 snapshot
=> { current
=> 1, snap
=> 1},
798 clone
=> { base
=> 1, snap
=> 1},
799 template
=> { current
=> 1},
800 copy
=> { base
=> 1, current
=> 1, snap
=> 1},
801 sparseinit
=> { base
=> 1, current
=> 1},
802 rename => {current
=> 1},
805 my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) = $class->parse_volname($volname);
811 $key = $isBase ?
'base' : 'current';
813 return 1 if $features->{$feature}->{$key};
819 my ($class, $scfg, $storeid, $source_volname, $target_vmid, $target_volname) = @_;
829 ) = $class->parse_volname($source_volname);
830 $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format)
834 my $cmd = $rbd_cmd->($scfg, $storeid, 'info', $target_volname);
835 run_rbd_command
($cmd, errmsg
=> "exist check", quiet
=> 1);
837 die "target volume '${target_volname}' already exists\n" if !$@;
839 my $cmd = $rbd_cmd->($scfg, $storeid, 'rename', $source_image, $target_volname);
843 errmsg
=> "could not rename image '${source_image}' to '${target_volname}'",
846 eval { $class->unmap_volume($storeid, $scfg, $source_volname); };
849 $base_name = $base_name ?
"${base_name}/" : '';
851 return "${storeid}:${base_name}${target_volname}";