return string(prefix + strlen(RBD_DATA_PREFIX));
}
+std::string mirror_image_state(rbd_mirror_image_state_t mirror_image_state) {
+ switch (mirror_image_state) {
+ case RBD_MIRROR_IMAGE_DISABLING:
+ return "disabling";
+ case RBD_MIRROR_IMAGE_ENABLED:
+ return "enabled";
+ case RBD_MIRROR_IMAGE_DISABLED:
+ return "disabled";
+ default:
+ return "unknown";
+ }
+}
+
} // namespace utils
} // namespace rbd
uint8_t old_format;
uint64_t overlap, features, flags;
bool snap_protected = false;
+ librbd::mirror_image_t mirror_image;
int r;
r = image.stat(info, sizeof(info));
return r;
}
+ if (features & RBD_FEATURE_JOURNALING) {
+ r = image.mirror_image_get(&mirror_image);
+ if (r < 0) {
+ return r;
+ }
+ }
+
char prefix[RBD_MAX_BLOCK_NAME_SIZE + 1];
strncpy(prefix, info.block_name_prefix, RBD_MAX_BLOCK_NAME_SIZE);
prefix[RBD_MAX_BLOCK_NAME_SIZE] = '\0';
}
}
+ if (features & RBD_FEATURE_JOURNALING) {
+ if (f) {
+ f->dump_string("mirroring_state",
+ utils::mirror_image_state(mirror_image.state));
+ if (mirror_image.state != RBD_MIRROR_IMAGE_DISABLED) {
+ f->dump_string("mirroring_global_id", mirror_image.global_id);
+ }
+ } else {
+ std::cout << "\tmirroring state: "
+ << utils::mirror_image_state(mirror_image.state) << std::endl;
+ if (mirror_image.state != RBD_MIRROR_IMAGE_DISABLED) {
+ std::cout << "\tmirroring global id: " << mirror_image.global_id
+ << std::endl;
+ }
+ }
+ }
+
if (f) {
f->close_section();
f->flush(std::cout);