qcow2: cleanup created file when qcow2_co_create
PATCH 1/1 qcow2: cleanup created file when qcow2_co_create
This is basically the same thing as commit
'crypto.c: cleanup created file when block_crypto_co_create_opts_luks fails' does but for qcow2 files to ensure that we don't leave qcow2 files when creation fails.
--- block/qcow2.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
block/qcow2.c +11 -0
@@ -3794,6 +3794,17 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,/* Create the qcow2 image (format layer) */ ret =qcow2_co_create (create_options, errp);if (ret <0 ) { + +Error *local_delete_err =NULL ; +int r_del =bdrv_co_delete_file (bs, &local_delete_err); +/* +* ENOTSUP will happen if the block driver doesn't support +* the 'bdrv_co_delete_file' interface. This is a predictable +* scenario and shouldn't be reported back to the user. +*/ +if ((r_del <0 ) && (r_del != -ENOTSUP )) { +error_report_err (local_delete_err); + } goto finish; }
Signature · 1 line
2.26.2
Quoted 22 lines · Maxim Levitsky
This is basically the same thing as commit
'crypto.c: cleanup created file whenblock_crypto_co_create_opts_luksfails' does but for qcow2 files to ensure that we don't leave qcow2 files when creation fails.Signed-off-by Maxim Levitsky <[email protected]>--- block/qcow2.c | 11 +++++++++++ 1 file changed, 11 insertions(+)block/qcow2.c +4
-0@@ -3794,6 +3794,17 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,/* Create the qcow2 image (format layer) */ ret =qcow2_co_create (create_options, errp);if (ret <0 ) { + +Error *local_delete_err =NULL ; +int r_del =bdrv_co_delete_file (bs, &local_delete_err); +/*
block/qcow2.c static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, · line 3810
Quoted 10 lines
block/qcow2.c +7
-0+* ENOTSUP will happen if the block driver doesn't support +* the 'bdrv_co_delete_file' interface. This is a predictable +* scenario and shouldn't be reported back to the user. +*/ +if ((r_del <0 ) && (r_del != -ENOTSUP )) { +error_report_err (local_delete_err); + } goto finish; }
Any update on this? Do you think we can add this to 5.1 or is it too late? Best regards,
Maxim Levitsky
Quoted 6 lines · Maxim Levitsky
This is basically the same thing as commit
'crypto.c: cleanup created file whenblock_crypto_co_create_opts_luksfails' does but for qcow2 files to ensure that we don't leave qcow2 files when creation fails.Signed-off-by Maxim Levitsky <[email protected]>
Very kind ping on this patch.
Best regards,
Maxim levitsky
Quoted 26 lines
--- block/qcow2.c | 11 +++++++++++ 1 file changed, 11 insertions(+)block/qcow2.c +11
-0@@ -3794,6 +3794,17 @@ static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,/* Create the qcow2 image (format layer) */ ret =qcow2_co_create (create_options, errp);if (ret <0 ) { + +Error *local_delete_err =NULL ; +int r_del =bdrv_co_delete_file (bs, &local_delete_err); +/* +* ENOTSUP will happen if the block driver doesn't support +* the 'bdrv_co_delete_file' interface. This is a predictable +* scenario and shouldn't be reported back to the user. +*/ +if ((r_del <0 ) && (r_del != -ENOTSUP )) { +error_report_err (local_delete_err); + } goto finish; }
block/qcow2.c static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, · line 3807
Quoted 12 lines · Maxim Levitsky
if (ret < 0) {block/qcow2.c +11
-0+ +Error *local_delete_err =NULL ; +int r_del =bdrv_co_delete_file (bs, &local_delete_err); +/* +* ENOTSUP will happen if the block driver doesn't support +* the 'bdrv_co_delete_file' interface. This is a predictable +* scenario and shouldn't be reported back to the user. +*/ +if ((r_del <0 ) && (r_del != -ENOTSUP )) { +error_report_err (local_delete_err); + }
I think you're leaking the error on ENOTSUP.
Berto
Quoted 14 lines · Alberto Garcia
block/qcow2.c static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv, · line 3807
Quoted 12 lines · Maxim Levitsky
if (ret < 0) {block/qcow2.c +11
-0+ +Error *local_delete_err =NULL ; +int r_del =bdrv_co_delete_file (bs, &local_delete_err); +/* +* ENOTSUP will happen if the block driver doesn't support +* the 'bdrv_co_delete_file' interface. This is a predictable +* scenario and shouldn't be reported back to the user. +*/ +if ((r_del <0 ) && (r_del != -ENOTSUP )) { +error_report_err (local_delete_err); + }
Quoted 1 line
I think you're leaking the error on ENOTSUP.
Indeed, just like in the original code from where I copy&pasta'ed this from. I'll send a patch to fix this and update the patch as well.
Thanks,
Best regards,
Maxim Levitsky
Quoted 3 lines
Berto