Currently, qemu-img can not create qcow2 image format on rbd server. Analysis
the code as followings:
when create qcow2 format image:
qcow2_create2
bdrv_create_file(filename, opts, &local_err); --> Here will create a 0 size
file(e.g: file1) on rbd server.
...
ret = bdrv_pwrite(bs, 0, header, cluster_size); --> So here can not write
qcow2 header into file1 due to the file1's length is 0. Seems
qemu_rbd_aio_writev can not write beyond EOF.
...
As above analysis, there are two methods to solve the above bz as followings:
1, When create file1, just create a fixed-size file1 on rbd server(not 0 size).
2, When write the qcow2 header into file1, just let qemu_rbd_aio_writev can
enlarge the file1. So should add qemu_rbd_truncate inside qemu_rbd_aio_writev.
qemu_rbd_truncate will call rbd_resize, but seems rbd_resize is
synchronous function. If so, when do bdrv_pwrite, guest will hang.This is not
our expected.
For method 1, maybe it's not corresponding to the original principle of qcow2.
Yes, it's very easy to solve the above bz. Nevertheless, I just want to use
method 2 to solve above issue.
For method 2, could anyone give some suggestions on howto realize a
asynchronous rbd_resize. Thanks.
Above analysis also based on stefan's hints. Thanks.
Best Regards,
Jun Li