From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, wdongxu@cn.ibm.com, stefanha@redhat.com,
Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH V18 06/25] add interface to block
Date: Tue, 13 Aug 2013 12:31:47 +0800 [thread overview]
Message-ID: <1376368326-7433-7-git-send-email-wdongxu@linux.vnet.ibm.com> (raw)
In-Reply-To: <1376368326-7433-1-git-send-email-wdongxu@linux.vnet.ibm.com>
To make patches easy for reviewing, each block format is
a single patch. Add a new interface to block layer to make
sure origin code can compile and do not change any code
logic.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
block.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
include/block/block.h | 2 ++
include/block/block_int.h | 2 ++
3 files changed, 55 insertions(+)
diff --git a/block.c b/block.c
index 01b66d8..25090dc 100644
--- a/block.c
+++ b/block.c
@@ -366,6 +366,7 @@ typedef struct CreateCo {
BlockDriver *drv;
char *filename;
QEMUOptionParameter *options;
+ QemuOpts *opts;
int ret;
} CreateCo;
@@ -425,6 +426,56 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options)
return bdrv_create(drv, filename, options);
}
+int bdrv_create_new(BlockDriver *drv, const char* filename, QemuOpts *opts)
+{
+ int ret;
+
+ Coroutine *co;
+ CreateCo cco = {
+ .drv = drv,
+ .filename = g_strdup(filename),
+ .opts = opts ?: qemu_opts_create_nofail(drv->bdrv_create_opts),
+ .ret = NOT_DONE,
+ };
+
+ if (!drv->bdrv_create) {
+ ret = -ENOTSUP;
+ goto out;
+ }
+
+ 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;
+
+out:
+ if (!opts) {
+ qemu_opts_del(cco.opts);
+ }
+ g_free(cco.filename);
+ return ret;
+}
+
+int bdrv_create_file_new(const char *filename, QemuOpts *opts)
+{
+ BlockDriver *drv;
+
+ drv = bdrv_find_protocol(filename, true);
+ if (drv == NULL) {
+ return -ENOENT;
+ }
+
+ return bdrv_create_new(drv, filename, opts);
+}
+
/*
* Create a uniquely-named empty temporary file.
* Return 0 upon success, otherwise a negative errno value.
diff --git a/include/block/block.h b/include/block/block.h
index 742fce5..efcaaa4 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -119,6 +119,8 @@ BlockDriver *bdrv_find_whitelisted_format(const char *format_name,
int bdrv_create(BlockDriver *drv, const char* filename,
QEMUOptionParameter *options);
int bdrv_create_file(const char* filename, QEMUOptionParameter *options);
+int bdrv_create_new(BlockDriver *drv, const char* filename, QemuOpts *opts);
+int bdrv_create_file_new(const char *filename, QemuOpts *opts);
BlockDriverState *bdrv_new(const char *device_name);
void bdrv_make_anon(BlockDriverState *bs);
void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index e45f2a0..fb12bba 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -105,6 +105,7 @@ struct BlockDriver {
void (*bdrv_close)(BlockDriverState *bs);
void (*bdrv_rebind)(BlockDriverState *bs);
int (*bdrv_create)(const char *filename, QEMUOptionParameter *options);
+ int (*bdrv_create_new)(const char *filename, QemuOpts *opts);
int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
int (*bdrv_make_empty)(BlockDriverState *bs);
/* aio */
@@ -195,6 +196,7 @@ struct BlockDriver {
/* List of options for creating images, terminated by name == NULL */
QEMUOptionParameter *create_options;
+ QemuOptsList *bdrv_create_opts;
/*
--
1.7.11.7
next prev parent reply other threads:[~2013-08-13 4:33 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 4:31 [Qemu-devel] [PATCH V18 00/25] replace QEMUOptionParameter with QemuOpts parser Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 01/25] qemu-option: add def_value_str in QemuOptDesc struct and rewrite qemu_opts_print Dong Xu Wang
2013-08-27 13:49 ` Kevin Wolf
2013-08-28 8:55 ` Dong Xu Wang
2013-08-28 12:53 ` Eric Blake
2013-08-29 1:49 ` Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 02/25] qemu-option: avoid duplication of default value in QemuOpts Dong Xu Wang
2013-08-28 12:57 ` Eric Blake
2013-08-29 1:49 ` Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 03/25] qemu-option: create four QemuOptsList related functions Dong Xu Wang
2013-08-27 13:54 ` Kevin Wolf
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 04/25] qemu-option: create some QemuOpts functons Dong Xu Wang
2013-08-27 13:58 ` Kevin Wolf
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 05/25] qemu-option: opt->str store digit, without suffixes Dong Xu Wang
2013-08-27 14:01 ` Kevin Wolf
2013-08-13 4:31 ` Dong Xu Wang [this message]
2013-08-27 14:08 ` [Qemu-devel] [PATCH V18 06/25] add interface to block Kevin Wolf
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 07/25] block: add QemuOpts support for cow.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 08/25] block: add QemuOpts support for gluster.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 09/25] block: add QemuOpts support for iscsi.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 10/25] block: add QemuOpts support for qcow.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 11/25] block: add QemuOpts support for qcow2.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 12/25] block: add QemuOpts support for qed.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 13/25] block: add QemuOpts support for raw-posix.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 14/25] block: add QemuOpts support for raw-win32.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 15/25] block: add QemuOpts support for raw.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 16/25] block: add QemuOpts support for rbd.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 17/25] block: add QemuOpts support for sheepdog.c Dong Xu Wang
2013-08-13 4:31 ` [Qemu-devel] [PATCH V18 18/25] block: add QemuOpts support for ssh.c Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 19/25] block: add QemuOpts support for vdi.c Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 20/25] block: add QemuOpts support for vmdk.c Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 21/25] block: add QemuOpts support for vpc.c Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 22/25] block: add QemuOpts support for block.c Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 23/25] block: clean temp code and use QemuOpts in block Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 24/25] qapi: query-command-line-options outputs def_value_str Dong Xu Wang
2013-08-27 14:12 ` Kevin Wolf
2013-08-27 23:13 ` Eric Blake
2013-08-28 8:57 ` Dong Xu Wang
2013-08-13 4:32 ` [Qemu-devel] [PATCH V18 25/25] qemu-option: remove QEMUOptionParameter related functions and struct Dong Xu Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376368326-7433-7-git-send-email-wdongxu@linux.vnet.ibm.com \
--to=wdongxu@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wdongxu@cn.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).