1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef LIBRBD_API_IMAGE_H
5 #define LIBRBD_API_IMAGE_H
7 #include "include/rbd/librbd.hpp"
8 #include "include/rados/librados_fwd.hpp"
9 #include "librbd/Types.h"
17 class ProgressContext
;
23 template <typename ImageCtxT
= librbd::ImageCtx
>
25 typedef std::map
<std::string
, std::string
> ImageNameToIds
;
27 static int64_t get_data_pool_id(ImageCtxT
*ictx
);
29 static int get_op_features(ImageCtxT
*ictx
, uint64_t *op_features
);
31 static int list_images(librados::IoCtx
& io_ctx
,
32 std::vector
<image_spec_t
> *images
);
33 static int list_images_v2(librados::IoCtx
& io_ctx
,
34 ImageNameToIds
*images
);
36 static int get_parent(ImageCtxT
*ictx
,
37 librbd::linked_image_spec_t
*parent_image
,
38 librbd::snap_spec_t
*parent_snap
);
40 static int list_children(ImageCtxT
*ictx
,
41 std::vector
<librbd::linked_image_spec_t
> *images
);
42 static int list_children(ImageCtxT
*ictx
,
43 const cls::rbd::ParentImageSpec
&parent_spec
,
44 std::vector
<librbd::linked_image_spec_t
> *images
);
46 static int list_descendants(IoCtx
& io_ctx
, const std::string
&image_id
,
47 const std::optional
<size_t> &max_level
,
48 std::vector
<librbd::linked_image_spec_t
> *images
);
49 static int list_descendants(ImageCtxT
*ictx
,
50 const std::optional
<size_t> &max_level
,
51 std::vector
<librbd::linked_image_spec_t
> *images
);
52 static int list_descendants(ImageCtxT
*ictx
,
53 const cls::rbd::ParentImageSpec
&parent_spec
,
54 const std::optional
<size_t> &max_level
,
55 std::vector
<librbd::linked_image_spec_t
> *images
);
57 static int deep_copy(ImageCtxT
*ictx
, librados::IoCtx
& dest_md_ctx
,
58 const char *destname
, ImageOptions
& opts
,
59 ProgressContext
&prog_ctx
);
60 static int deep_copy(ImageCtxT
*src
, ImageCtxT
*dest
, bool flatten
,
61 ProgressContext
&prog_ctx
);
63 static int snap_set(ImageCtxT
*ictx
,
64 const cls::rbd::SnapshotNamespace
&snap_namespace
,
65 const char *snap_name
);
66 static int snap_set(ImageCtxT
*ictx
, uint64_t snap_id
);
68 static int remove(librados::IoCtx
& io_ctx
, const std::string
&image_name
,
69 ProgressContext
& prog_ctx
);
71 static int flatten_children(ImageCtxT
*ictx
, const char* snap_name
, ProgressContext
& pctx
);
73 static int encryption_format(ImageCtxT
*ictx
, encryption_format_t format
,
74 encryption_options_t opts
, size_t opts_size
,
76 static int encryption_load(ImageCtxT
*ictx
, const encryption_spec_t
*specs
,
77 size_t spec_count
, bool c_api
);
83 extern template class librbd::api::Image
<librbd::ImageCtx
>;
85 #endif // LIBRBD_API_IMAGE_H