[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v28 22/33] raw-posix.c: replace QEMUOptionParameter
From: |
Chunyan Liu |
Subject: |
[Qemu-devel] [PATCH v28 22/33] raw-posix.c: replace QEMUOptionParameter with QemuOpts |
Date: |
Thu, 5 Jun 2014 17:21:01 +0800 |
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Dong Xu Wang <address@hidden>
Signed-off-by: Chunyan Liu <address@hidden>
---
block/raw-posix.c | 59 +++++++++++++++++++++++++------------------------------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index b7f0f26..e0a75db 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1240,8 +1240,7 @@ static int64_t
raw_get_allocated_file_size(BlockDriverState *bs)
return (int64_t)st.st_blocks * 512;
}
-static int raw_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
{
int fd;
int result = 0;
@@ -1250,12 +1249,8 @@ static int raw_create(const char *filename,
QEMUOptionParameter *options,
strstart(filename, "file:", &filename);
/* Read out options */
- while (options && options->name) {
- if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
- total_size = options->value.n / BDRV_SECTOR_SIZE;
- }
- options++;
- }
+ total_size =
+ qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
0644);
@@ -1440,13 +1435,17 @@ static int raw_get_info(BlockDriverState *bs,
BlockDriverInfo *bdi)
return 0;
}
-static QEMUOptionParameter raw_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
- { NULL }
+static QemuOptsList raw_create_opts = {
+ .name = "raw-create-opts",
+ .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ { /* end of list */ }
+ }
};
static BlockDriver bdrv_file = {
@@ -1461,7 +1460,7 @@ static BlockDriver bdrv_file = {
.bdrv_reopen_commit = raw_reopen_commit,
.bdrv_reopen_abort = raw_reopen_abort,
.bdrv_close = raw_close,
- .bdrv_create = raw_create,
+ .bdrv_create2 = raw_create,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_co_get_block_status = raw_co_get_block_status,
.bdrv_co_write_zeroes = raw_co_write_zeroes,
@@ -1478,7 +1477,7 @@ static BlockDriver bdrv_file = {
.bdrv_get_allocated_file_size
= raw_get_allocated_file_size,
- .create_options = raw_create_options,
+ .create_opts = &raw_create_opts,
};
/***********************************************/
@@ -1799,7 +1798,7 @@ static coroutine_fn int
hdev_co_write_zeroes(BlockDriverState *bs,
return -ENOTSUP;
}
-static int hdev_create(const char *filename, QEMUOptionParameter *options,
+static int hdev_create(const char *filename, QemuOpts *opts,
Error **errp)
{
int fd;
@@ -1820,12 +1819,8 @@ static int hdev_create(const char *filename,
QEMUOptionParameter *options,
(void)has_prefix;
/* Read out options */
- while (options && options->name) {
- if (!strcmp(options->name, "size")) {
- total_size = options->value.n / BDRV_SECTOR_SIZE;
- }
- options++;
- }
+ total_size =
+ qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
fd = qemu_open(filename, O_WRONLY | O_BINARY);
if (fd < 0) {
@@ -1862,8 +1857,8 @@ static BlockDriver bdrv_host_device = {
.bdrv_reopen_prepare = raw_reopen_prepare,
.bdrv_reopen_commit = raw_reopen_commit,
.bdrv_reopen_abort = raw_reopen_abort,
- .bdrv_create = hdev_create,
- .create_options = raw_create_options,
+ .bdrv_create2 = hdev_create,
+ .create_opts = &raw_create_opts,
.bdrv_co_write_zeroes = hdev_co_write_zeroes,
.bdrv_aio_readv = raw_aio_readv,
@@ -2006,8 +2001,8 @@ static BlockDriver bdrv_host_floppy = {
.bdrv_reopen_prepare = raw_reopen_prepare,
.bdrv_reopen_commit = raw_reopen_commit,
.bdrv_reopen_abort = raw_reopen_abort,
- .bdrv_create = hdev_create,
- .create_options = raw_create_options,
+ .bdrv_create2 = hdev_create,
+ .create_opts = &raw_create_opts,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_aio_writev = raw_aio_writev,
@@ -2131,8 +2126,8 @@ static BlockDriver bdrv_host_cdrom = {
.bdrv_reopen_prepare = raw_reopen_prepare,
.bdrv_reopen_commit = raw_reopen_commit,
.bdrv_reopen_abort = raw_reopen_abort,
- .bdrv_create = hdev_create,
- .create_options = raw_create_options,
+ .bdrv_create2 = hdev_create,
+ .create_opts = &raw_create_opts,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_aio_writev = raw_aio_writev,
@@ -2262,8 +2257,8 @@ static BlockDriver bdrv_host_cdrom = {
.bdrv_reopen_prepare = raw_reopen_prepare,
.bdrv_reopen_commit = raw_reopen_commit,
.bdrv_reopen_abort = raw_reopen_abort,
- .bdrv_create = hdev_create,
- .create_options = raw_create_options,
+ .bdrv_create2 = hdev_create,
+ .create_opts = &raw_create_opts,
.bdrv_aio_readv = raw_aio_readv,
.bdrv_aio_writev = raw_aio_writev,
--
1.7.12.4
- [Qemu-devel] [PATCH v28 09/33] QemuOpts: add conversion between QEMUOptionParameter to QemuOpts, (continued)
- [Qemu-devel] [PATCH v28 09/33] QemuOpts: add conversion between QEMUOptionParameter to QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 10/33] QemuOpts: add qemu_opts_append to replace append_option_parameters, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 11/33] QemuOpts: check NULL input for qemu_opts_del, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 15/33] gluster.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 17/33] nfs.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 12/33] change block layer to support both QemuOpts and QEMUOptionParamter, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 14/33] cow.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 13/33] vvfat.c: handle cross_driver's create_options and create_opts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 16/33] iscsi.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 18/33] qcow.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 22/33] raw-posix.c: replace QEMUOptionParameter with QemuOpts,
Chunyan Liu <=
- [Qemu-devel] [PATCH v28 19/33] QemuOpts: export qemu_opt_find, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 20/33] qcow2.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 21/33] qed.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 24/33] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 23/33] raw-win32.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 25/33] rbd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 26/33] sheepdog.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 27/33] ssh.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 28/33] vdi.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05
- [Qemu-devel] [PATCH v28 29/33] vhdx.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/06/05