* [Qemu-devel] [PATCH 1/2] block: make bdrv_create adopt coroutine
@ 2012-05-05 3:13 zwu.kernel
0 siblings, 0 replies; 4+ messages in thread
From: zwu.kernel @ 2012-05-05 3:13 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, Zhi Yong Wu, marcandre.lureau, stefanha
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
block.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/block.c b/block.c
index 43c794c..3ff78c5 100644
--- a/block.c
+++ b/block.c
@@ -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;
+ const 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)
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/2] block: make bdrv_create adopt coroutine
@ 2012-05-05 3:28 zwu.kernel
2012-05-07 8:32 ` Kevin Wolf
0 siblings, 1 reply; 4+ messages in thread
From: zwu.kernel @ 2012-05-05 3:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, Zhi Yong Wu, marcandre.lureau, stefanha
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
block.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/block.c b/block.c
index 43c794c..5de55fe 100644
--- a/block.c
+++ b/block.c
@@ -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)
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_create adopt coroutine
2012-05-05 3:28 zwu.kernel
@ 2012-05-07 8:32 ` Kevin Wolf
2012-05-07 8:39 ` Zhi Yong Wu
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Wolf @ 2012-05-07 8:32 UTC (permalink / raw)
To: zwu.kernel; +Cc: Zhi Yong Wu, marcandre.lureau, qemu-devel, stefanha
Am 05.05.2012 05:28, schrieb zwu.kernel@gmail.com:
> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>
> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_create adopt coroutine
2012-05-07 8:32 ` Kevin Wolf
@ 2012-05-07 8:39 ` Zhi Yong Wu
0 siblings, 0 replies; 4+ messages in thread
From: Zhi Yong Wu @ 2012-05-07 8:39 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Zhi Yong Wu, marcandre.lureau, qemu-devel, stefanha
On Mon, May 7, 2012 at 4:32 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 05.05.2012 05:28, schrieb zwu.kernel@gmail.com:
>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>
>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>> ---
>> 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
OK, will send v2.
> --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.
>
> In short: Please read http://wiki.qemu.org/Contribute/SubmitAPatch once
> again and be sure to follow its advices.
>
> Kevin
--
Regards,
Zhi Yong Wu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-07 8:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-05 3:13 [Qemu-devel] [PATCH 1/2] block: make bdrv_create adopt coroutine zwu.kernel
-- strict thread matches above, loose matches on Subject: below --
2012-05-05 3:28 zwu.kernel
2012-05-07 8:32 ` Kevin Wolf
2012-05-07 8:39 ` Zhi Yong Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).