block: make bdrv_create adopt coroutine
PATCH 1/2 block: make bdrv_create adopt coroutine
From: Zhi Yong Wu <[email protected]>
--- block.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 47 insertions(+), 1 deletions(-)
block.c +47 -1
@@ -341,13 +341,59 @@ BlockDriver *bdrv_find_whitelisted_format(const char *format_name)return drv &&bdrv_is_whitelisted (drv) ? drv :NULL ; } +typedef struct CreateCo { +BlockDriver *drv; +char *filename; +QEMUOptionParameter *options; +int ret; +}CreateCo ; + +static void coroutine_fn bdrv_create_co_entry(void *opaque) +{ +CreateCo *cco = opaque; +assert (cco->drv); + + cco->ret = cco->drv->bdrv_create (cco->filename, cco->options); +} + +static int bdrv_create_co (BlockDriver *drv, +const char *filename, +QEMUOptionParameter *options) +{ +int ret; + +Coroutine *co; +CreateCo cco = { + .drv = drv, + .filename =g_strdup (filename), + .options = options, + .ret =NOT_DONE , + }; + +if (qemu_in_coroutine ()) { +/* Fast-path if already in coroutine context */ +bdrv_create_co_entry (&cco); + }else { + co =qemu_coroutine_create (bdrv_create_co_entry); +qemu_coroutine_enter (co, &cco); +while (cco.ret ==NOT_DONE ) { +qemu_aio_wait (); + } + } + + ret = cco.ret; +g_free (cco.filename); + +return ret; +} +int bdrv_create (BlockDriver *drv,const char * filename,QEMUOptionParameter *options) {if (!drv->bdrv_create)return -ENOTSUP ; -return drv->bdrv_create (filename, options); +return bdrv_create_co (drv, filename, options); }int bdrv_create_file (const char * filename,QEMUOptionParameter *options)
Signature · 1 line
1.7.6
Am 05.05.2012 05:28, schrieb [email protected]:
Quoted 6 lines
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>--- block.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 47 insertions(+), 1 deletions(-)
What's this? A version 2 of half the patch series, with the implicit assumption that I should take patch 2 from version 1? You should resend the whole series, you should ensure proper email threading, and you should include a v2 in the subject line (git format-patch --subject-prefix="PATCH v2"). Your commit messages are lacking, too. I have no idea _why_ you are making the change.
In short: Please read http://wiki.qemu.org/Contribute/SubmitAPatch once again and be sure to follow its advices.
Kevin
Quoted 8 lines · Kevin Wolf
Am 05.05.2012 05:28, schrieb [email protected]:
Quoted 6 lines
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>---
block.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-1 files changed, 47 insertions(+), 1 deletions(-)
Quoted 4 lines
What's this? A version 2 of half the patch series, with the implicit assumption that I should take patch 2 from version 1? You should resend the whole series, you should ensure proper email threading, and you should include a v2 in the subject line (git format-patch
OK, will send v2.
Quoted 2 lines
--subject-prefix="PATCH v2"). Your commit messages are lacking, too. I have no idea _why_ you are making the change.
The patchset will fix one issue about qcow2 preallocation function reported by marcandre.
Quoted 5 lines
In short: Please read http://wiki.qemu.org/Contribute/SubmitAPatch once again and be sure to follow its advices.
Kevin
Signature · 3 lines
Regards, Zhi Yong Wu