rbd: use ListChildrenAttributes() instead of ListChildren()

This commit modifies listSnapAndChildren() to make use of
ListChildrenAttributes() instead of ListChildren() which
allows us to filter out images in trash.
This commit also order the alive images so that temp clone
images are followed by images backing volume snapshots so
that temp clone images are flattened first.

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R
2025-03-10 15:15:45 +05:30
committed by mergify[bot]
parent 355a8fab9f
commit 796e6b6c44
12 changed files with 163 additions and 40 deletions

View File

@ -81,25 +81,22 @@ func (image *Image) EncryptionLoad2(opts []EncryptionOptions) error {
}
length := len(opts)
cspecs := (*C.rbd_encryption_spec_t)(C.malloc(
C.size_t(C.sizeof_rbd_encryption_spec_t * length)))
specs := unsafe.Slice(cspecs, length)
cspecs := make([]C.rbd_encryption_spec_t, length)
freeFuncs := make([]func(), length)
for idx, option := range opts {
f := option.(encryptionOptions2).writeEncryptionSpec(&specs[idx])
f := option.(encryptionOptions2).writeEncryptionSpec(&cspecs[idx])
freeFuncs[idx] = f
}
defer func() {
for _, f := range freeFuncs {
f()
}
C.free(unsafe.Pointer(cspecs))
}()
ret := C.rbd_encryption_load2(
image.image,
cspecs,
(*C.rbd_encryption_spec_t)(unsafe.Pointer(&cspecs[0])),
C.size_t(length))
return getError(ret)
}