Show the rbd images that are mapped via the rbd kernel module
(default) or other supported device.
-:command:`device map` [-t | --device-type *device-type*] [--cookie *device-cookie*] [--show-cookie] [--read-only] [--exclusive] [-o | --options *device-options*] *image-spec* | *snap-spec*
+:command:`device map` [-t | --device-type *device-type*] [--cookie *device-cookie*] [--show-cookie] [--snap-id *snap-id*] [--read-only] [--exclusive] [-o | --options *device-options*] *image-spec* | *snap-spec*
Map the specified image to a block device via the rbd kernel module
(default) or other supported device (*nbd* on Linux or *ggate* on
FreeBSD).
The --options argument is a comma separated list of device type
specific options (opt1,opt2=val,...).
-:command:`device unmap` [-t | --device-type *device-type*] [-o | --options *device-options*] *image-spec* | *snap-spec* | *device-path*
+:command:`device unmap` [-t | --device-type *device-type*] [-o | --options *device-options*] [--snap-id *snap-id*] *image-spec* | *snap-spec* | *device-path*
Unmap the block device that was mapped via the rbd kernel module
(default) or other supported device.
The --options argument is a comma separated list of device type
specific options (opt1,opt2=val,...).
-:command:`device attach` [-t | --device-type *device-type*] --device *device-path* [--cookie *device-cookie*] [--show-cookie] [--read-only] [--exclusive] [--force] [-o | --options *device-options*] *image-spec* | *snap-spec*
+:command:`device attach` [-t | --device-type *device-type*] --device *device-path* [--cookie *device-cookie*] [--show-cookie] [--snap-id *snap-id*] [--read-only] [--exclusive] [--force] [-o | --options *device-options*] *image-spec* | *snap-spec*
Attach the specified image to the specified block device (currently only
`nbd` on Linux). This operation is unsafe and should not be normally used.
In particular, specifying the wrong image or the wrong block device may
The --options argument is a comma separated list of device type
specific options (opt1,opt2=val,...).
-:command:`device detach` [-t | --device-type *device-type*] [-o | --options *device-options*] *image-spec* | *snap-spec* | *device-path*
+:command:`device detach` [-t | --device-type *device-type*] [-o | --options *device-options*] [--snap-id *snap-id*] *image-spec* | *snap-spec* | *device-path*
Detach the block device that was mapped or attached (currently only `nbd`
on Linux). This operation is unsafe and should not be normally used.
[--snap <snap>] --device <device> [--show-cookie]
[--cookie <cookie>] [--read-only] [--force]
[--exclusive] [--quiesce]
- [--quiesce-hook <quiesce-hook>] [--options <options>]
+ [--quiesce-hook <quiesce-hook>] [--snap-id <snap-id>]
+ [--options <options>]
<image-or-snap-spec>
Attach image to device.
--exclusive disable automatic exclusive lock transitions
--quiesce use quiesce hooks
--quiesce-hook arg quiesce hook path
+ --snap-id arg snapshot id
-o [ --options ] arg device specific options
rbd help device detach
usage: rbd device detach [--device-type <device-type>] [--pool <pool>]
[--namespace <namespace>] [--image <image>]
- [--snap <snap>] [--options <options>]
+ [--snap <snap>] [--snap-id <snap-id>]
+ [--options <options>]
<image-or-snap-or-device-spec>
Detach image from device.
--namespace arg namespace name
--image arg image name
--snap arg snapshot name
+ --snap-id arg snapshot id
-o [ --options ] arg device specific options
rbd help device list
[--namespace <namespace>] [--image <image>]
[--snap <snap>] [--show-cookie] [--cookie <cookie>]
[--read-only] [--exclusive] [--quiesce]
- [--quiesce-hook <quiesce-hook>] [--options <options>]
+ [--quiesce-hook <quiesce-hook>] [--snap-id <snap-id>]
+ [--options <options>]
<image-or-snap-spec>
Map an image to a block device.
--exclusive disable automatic exclusive lock transitions
--quiesce use quiesce hooks
--quiesce-hook arg quiesce hook path
+ --snap-id arg snapshot id
-o [ --options ] arg device specific options
rbd help device unmap
usage: rbd device unmap [--device-type <device-type>] [--pool <pool>]
[--namespace <namespace>] [--image <image>]
- [--snap <snap>] [--options <options>]
+ [--snap <snap>] [--snap-id <snap-id>]
+ [--options <options>]
<image-or-snap-or-device-spec>
Unmap a rbd device.
--namespace arg namespace name
--image arg image name
--snap arg snapshot name
+ --snap-id arg snapshot id
-o [ --options ] arg device specific options
rbd help diff
("exclusive", po::bool_switch(), "disable automatic exclusive lock transitions")
("quiesce", po::bool_switch(), "use quiesce hooks")
("quiesce-hook", po::value<std::string>(), "quiesce hook path");
+ at::add_snap_id_option(options);
add_device_specific_options(options);
}
at::add_namespace_option(options, at::ARGUMENT_MODIFIER_NONE);
at::add_image_option(options, at::ARGUMENT_MODIFIER_NONE);
at::add_snap_option(options, at::ARGUMENT_MODIFIER_NONE);
+ at::add_snap_id_option(options);
add_device_specific_options(options);
}
("exclusive", po::bool_switch(), "disable automatic exclusive lock transitions")
("quiesce", po::bool_switch(), "use quiesce hooks")
("quiesce-hook", po::value<std::string>(), "quiesce hook path");
+ at::add_snap_id_option(options);
add_device_specific_options(options);
}
at::add_namespace_option(options, at::ARGUMENT_MODIFIER_NONE);
at::add_image_option(options, at::ARGUMENT_MODIFIER_NONE);
at::add_snap_option(options, at::ARGUMENT_MODIFIER_NONE);
+ at::add_snap_id_option(options);
add_device_specific_options(options);
}
return -EINVAL;
}
+ if (vm.count(at::SNAPSHOT_ID)) {
+ args.push_back("--snap-id");
+ args.push_back(std::to_string(vm[at::SNAPSHOT_ID].as<uint64_t>()));
+ }
+
if (vm["quiesce"].as<bool>()) {
args.push_back("--quiesce");
}
device_name.clear();
}
+ std::vector<std::string> args;
+
+ args.push_back("detach");
std::string image_name;
if (device_name.empty()) {
int r = utils::get_image_or_snap_spec(vm, &image_name);
if (r < 0) {
return r;
}
- }
- if (device_name.empty() && image_name.empty()) {
- std::cerr << "rbd: detach requires either image name or device path"
- << std::endl;
- return -EINVAL;
- }
+ if (image_name.empty()) {
+ std::cerr << "rbd: detach requires either image name or device path"
+ << std::endl;
+ return -EINVAL;
+ }
- std::vector<std::string> args;
+ if (vm.count(at::SNAPSHOT_ID)) {
+ args.push_back("--snap-id");
+ args.push_back(std::to_string(vm[at::SNAPSHOT_ID].as<uint64_t>()));
+ }
+ }
- args.push_back("detach");
args.push_back(device_name.empty() ? image_name : device_name);
if (vm.count("options")) {
args.push_back(vm["cookie"].as<std::string>());
}
+ if (vm.count(at::SNAPSHOT_ID)) {
+ args.push_back("--snap-id");
+ args.push_back(std::to_string(vm[at::SNAPSHOT_ID].as<uint64_t>()));
+ }
+
if (vm["read-only"].as<bool>()) {
args.push_back("--read-only");
}
device_name.clear();
}
+ std::vector<std::string> args;
+
+ args.push_back("unmap");
std::string image_name;
if (device_name.empty()) {
int r = utils::get_image_or_snap_spec(vm, &image_name);
if (r < 0) {
return r;
}
- }
- if (device_name.empty() && image_name.empty()) {
- std::cerr << "rbd: unmap requires either image name or device path"
- << std::endl;
- return -EINVAL;
- }
+ if (image_name.empty()) {
+ std::cerr << "rbd: unmap requires either image name or device path"
+ << std::endl;
+ return -EINVAL;
+ }
- std::vector<std::string> args;
+ if (vm.count(at::SNAPSHOT_ID)) {
+ args.push_back("--snap-id");
+ args.push_back(std::to_string(vm[at::SNAPSHOT_ID].as<uint64_t>()));
+ }
+ }
- args.push_back("unmap");
args.push_back(device_name.empty() ? image_name : device_name);
if (vm.count("options")) {
break;
}
+ if (cfg->snapid != CEPH_NOSNAP && !cfg->snapname.empty()) {
+ *err_msg << "rbd-nbd: use either snapname or snapid, not both";
+ return -EINVAL;
+ }
+
if (args.begin() != args.end()) {
*err_msg << "rbd-nbd: unknown args: " << *args.begin();
return -EINVAL;