Skip to contentSkip to conversation

(no subject)

Qemu-devel Jun Li 1 participant 2 messages Dec 6, 2014

lore
Share & tools
lore

Jun Li

author
#0 lore raw

[email protected]
Bcc:
Subject: Re: [Qemu-devel] qcow2: Can create qcow2 image format on rbd server Reply-To:
In-Reply-To: <[email protected]>

Quoted 13 lines · Max Reitz
Quoted 12 lines · Jun Li

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.
...

Quoted 5 lines
Quoted 2 lines

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).

Should be possible by using -o preallocation=falloc or -o preallocation=full.

Sure. If bdrv_create_file(filename, opts, &local_err) create a fixed-size(not 0 size) just as using "preallocation=falloc or preallocation=full", it will create a fixed-size file on rbd server. So it won't exist above issue.

Quoted 9 lines

I can't say a lot about making rbd growable because I know near to nothing about rbd; but there are protocols which really simply don't support writes beyond the end of file, and where that's intended (for instance, while nbd somehow does support it when using the qemu nbd server, normally (strictly according to the protocol) it does not); so for these protocols, you have to use a preallocated image file or an image format which does not grow on writes (such as raw).

Here just want to use rbd_resize to realize rbd growable.

Quoted 4 lines

Of course, while that may be a solution for nbd, it doesn't sound like a good solution for rbd, so writes beyond the EOF should probably be supported there (although once again, I don't know rbd well enough to judge that).

Yes, you are right. Also talked with stefan. Here just want to ask Josh Durgin whether it has other solutions or rbd can support asynchronous rbd_resize.

Regards,
Jun Li

Quoted 19 lines
Quoted 18 lines

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

author
#1 lore raw

Re: [Qemu-devel] your mail

Please ignore it. Sorry...

Quoted 72 lines · Jun Li

[email protected]
Bcc:
Subject: Re: [Qemu-devel] qcow2: Can create qcow2 image format on rbd server Reply-To:
In-Reply-To: <[email protected]>

Quoted 13 lines · Max Reitz
Quoted 12 lines · Jun Li

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.
...

Quoted 5 lines
Quoted 2 lines

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).

Should be possible by using -o preallocation=falloc or -o preallocation=full.

Sure. If bdrv_create_file(filename, opts, &local_err) create a fixed-size(not 0 size) just as using "preallocation=falloc or preallocation=full", it will create a fixed-size file on rbd server. So it won't exist above issue.

Quoted 9 lines

I can't say a lot about making rbd growable because I know near to nothing about rbd; but there are protocols which really simply don't support writes beyond the end of file, and where that's intended (for instance, while nbd somehow does support it when using the qemu nbd server, normally (strictly according to the protocol) it does not); so for these protocols, you have to use a preallocated image file or an image format which does not grow on writes (such as raw).

Here just want to use rbd_resize to realize rbd growable.

Quoted 4 lines

Of course, while that may be a solution for nbd, it doesn't sound like a good solution for rbd, so writes beyond the EOF should probably be supported there (although once again, I don't know rbd well enough to judge that).

Yes, you are right. Also talked with stefan. Here just want to ask Josh Durgin whether it has other solutions or rbd can support asynchronous rbd_resize.

Regards,
Jun Li

Quoted 19 lines
Quoted 18 lines

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