[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/26] vdi: migrate vdi driver QemuOptionParameter u
From: |
Leandro Dorileo |
Subject: |
[Qemu-devel] [PATCH 20/26] vdi: migrate vdi driver QemuOptionParameter usage |
Date: |
Thu, 20 Mar 2014 21:13:27 -0300 |
Do the directly migration from QemuOptionParameter to QemuOpts on
vdi block driver.
Signed-off-by: Leandro Dorileo <address@hidden>
---
block/vdi.c | 73 ++++++++++++++++++++++++++++---------------------------------
1 file changed, 34 insertions(+), 39 deletions(-)
diff --git a/block/vdi.c b/block/vdi.c
index ae49cd8..4f8a143 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -653,8 +653,7 @@ static int vdi_co_write(BlockDriverState *bs,
return ret;
}
-static int vdi_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int vdi_create(const char *filename, QemuOpts *options, Error **errp)
{
int fd;
int result = 0;
@@ -662,31 +661,23 @@ static int vdi_create(const char *filename,
QEMUOptionParameter *options,
uint32_t blocks;
size_t block_size = DEFAULT_CLUSTER_SIZE;
uint32_t image_type = VDI_TYPE_DYNAMIC;
+ bool stat;
VdiHeader header;
size_t i;
size_t bmap_size;
logout("\n");
- /* Read out options. */
- while (options && options->name) {
- if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
- bytes = options->value.n;
+ bytes = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+
#if defined(CONFIG_VDI_BLOCK_SIZE)
- } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {
- if (options->value.n) {
- /* TODO: Additional checks (SECTOR_SIZE * 2^n, ...). */
- block_size = options->value.n;
- }
-#endif
-#if defined(CONFIG_VDI_STATIC_IMAGE)
- } else if (!strcmp(options->name, BLOCK_OPT_STATIC)) {
- if (options->value.n) {
- image_type = VDI_TYPE_STATIC;
- }
+ /* TODO: Additional checks (SECTOR_SIZE * 2^n, ...). */
+ block_size = qemu_opt_get_size(options, BLOCK_OPT_CLUSTER_SIZE, 0);
#endif
- }
- options++;
+
+ stat = qemu_opt_get_bool(options, BLOCK_OPT_STATIC, false);
+ if (stat) {
+ image_type = VDI_TYPE_STATIC;
}
fd = qemu_open(filename,
@@ -767,29 +758,33 @@ static void vdi_close(BlockDriverState *bs)
error_free(s->migration_blocker);
}
-static QEMUOptionParameter vdi_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
+static QemuOptsList vdi_create_options = {
+ .name = "vdi_create_options",
+ .head = QTAILQ_HEAD_INITIALIZER(vdi_create_options.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
#if defined(CONFIG_VDI_BLOCK_SIZE)
- {
- .name = BLOCK_OPT_CLUSTER_SIZE,
- .type = OPT_SIZE,
- .help = "VDI cluster (block) size",
- .value = { .n = DEFAULT_CLUSTER_SIZE },
- },
+ {
+ .name = BLOCK_OPT_CLUSTER_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "VDI cluster (block) size",
+ .def_val = QEMU_OPT_VAL_SIZE(DEFAULT_CLUSTER_SIZE),
+ },
#endif
#if defined(CONFIG_VDI_STATIC_IMAGE)
- {
- .name = BLOCK_OPT_STATIC,
- .type = OPT_FLAG,
- .help = "VDI static (pre-allocated) image"
- },
+ {
+ .name = BLOCK_OPT_STATIC,
+ .type = QEMU_OPT_BOOL,
+ .help = "VDI static (pre-allocated) image"
+ },
#endif
- /* TODO: An additional option to set UUID values might be useful. */
- { NULL }
+ /* TODO: An additional option to set UUID values might be useful. */
+ { NULL }
+ },
};
static BlockDriver bdrv_vdi = {
@@ -811,7 +806,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_get_info = vdi_get_info,
- .create_options = vdi_create_options,
+ .create_options = &vdi_create_options,
.bdrv_check = vdi_check,
};
--
1.9.0
- [Qemu-devel] [PATCH 14/26] raw-posix: migrate raw-posix driver QemuOptionParameter usage, (continued)
- [Qemu-devel] [PATCH 14/26] raw-posix: migrate raw-posix driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 15/26] raw-win32: migrate cow driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 16/26] raw_bsd: migrate raw_bsd driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 21/26] vhdx: migrate vhdx driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 22/26] vmdk: migrate vmdk driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 23/26] vpc: migrate vpc driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 24/26] vvfat: migrate vvfat driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 25/26] QemuOpt: get rid of QEMUOptionParameter, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 26/26] qemu-img: migrate QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 18/26] sheepdog: migrate sheepdog driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 20/26] vdi: migrate vdi driver QemuOptionParameter usage,
Leandro Dorileo <=
- [Qemu-devel] [PATCH 19/26] ssh: migrate ssh driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20
- [Qemu-devel] [PATCH 17/26] rbd: migrate rbd driver QemuOptionParameter usage, Leandro Dorileo, 2014/03/20