diff --git a/qemu-img.c b/qemu-img.c index 2f63d31141..edf75e43ab 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2245,7 +2245,7 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv) Error *local_err = NULL; bool writethrough, src_writethrough, image_opts = false, skip_create = false, progress = false, tgt_image_opts = false; - int64_t ret = -EINVAL; + int64_t ret = -EINVAL, ret2; bool force_share = false; bool explict_min_sparse = false; bool bitmaps = false; @@ -2872,6 +2872,12 @@ static int img_convert(const img_cmd_t *ccmd, int argc, char **argv) ret = convert_copy_bitmaps(blk_bs(s.src[0]), out_bs, skip_broken); } + ret2 = blk_flush(s.target); + if (ret2 < 0) { + error_report("Failed to flush target image: %s", strerror(-ret2)); + ret = ret != 0 ? ret : ret2; + } + out: if (!ret) { qemu_progress_print(100, 0); diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 84283f2434..38794f96ac 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -267,9 +267,10 @@ qemu-img convert exited with status 0 === failing flush after convert with 'writeback' cache mode === +qemu-img: Failed to flush target image: Input/output error qemu-img: Failed flush for 'json:{ /* filtered */ }' during close: Input/output error qemu-img: Failed to flush the L2 table cache: Input/output error qemu-img: Failed to flush the refcount block cache: Input/output error qemu-img: Failed flush for 'json:{ /* filtered */ }' during close: Input/output error -qemu-img convert exited with status 0 +qemu-img convert exited with status 1 *** done