Use the bdrv_co_delete_file interface to delete the underlying file if qcow2 initilization fails (e.g due to bad encryption secret)
This gives the qcow2 the same treatment as to luks. V2: added a patch to fix a memory leak. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1845353 Maxim Levitsky (2): crypto: luks: fix tiny memory leak block: qcow2: remove the created file on initialization error block/crypto.c | 1 + block/qcow2.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) -- 2.26.2