}
}
+ $class->deactivate_volume($storeid, $scfg, $volname);
+
my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge', $name);
run_rbd_command($cmd, errmsg => "rbd snap purge '$volname' error");
}
sub activate_volume {
- my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
return 1 if !$scfg->{krbd};
my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+ my $pool = $scfg->{pool} ? $scfg->{pool} : 'rbd';
+
+ my $path = "/dev/rbd/$pool/$name";
+ $path .= '@'.$snapname if $snapname;
+ return if -b $path;
+ $name .= '@'.$snapname if $snapname;
my $cmd = &$rbd_cmd($scfg, $storeid, 'map', $name);
run_rbd_command($cmd, errmsg => "can't mount rbd volume $name");
}
sub deactivate_volume {
- my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
return 1 if !$scfg->{krbd};
my $pool = $scfg->{pool} ? $scfg->{pool} : 'rbd';
my $path = "/dev/rbd/$pool/$name";
+ $path .= '@'.$snapname if $snapname;
+ return if ! -b $path;
+
my $cmd = &$rbd_cmd($scfg, $storeid, 'unmap', $path);
run_rbd_command($cmd, errmsg => "can't unmount rbd volume $name");
return 1 if $running;
+ $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
+
my ($vtype, $name, $vmid) = $class->parse_volname($volname);
my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $name, $snap);