From 6284986e0180471e43a89dfd51169a3ecae7f1b3 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 19 Feb 2020 16:40:14 +0100 Subject: [PATCH] rbd/features: add Image.UpdateFeatures() Signed-off-by: Niels de Vos --- rbd/features.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rbd/features.go b/rbd/features.go index ed9edda..86afae4 100644 --- a/rbd/features.go +++ b/rbd/features.go @@ -106,3 +106,20 @@ func (image *Image) GetFeatures() (features uint64, err error) { return features, nil } + +// UpdateFeatures updates the features on the Image. +// +// Implements: +// int rbd_update_features(rbd_image_t image, uint64_t features, +// uint8_t enabled); +func (image *Image) UpdateFeatures(features uint64, enabled bool) error { + if image.image == nil { + return RbdErrorImageNotOpen + } + + cEnabled := C.uint8_t(0) + if enabled { + cEnabled = 1 + } + return getError(C.rbd_update_features(image.image, C.uint64_t(features), cEnabled)) +}