@@ -662,31 +662,26 @@ static void qcow_close(BlockDriverState *bs)
error_free(s->migration_blocker);
}
-static int qcow_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int qcow_create(const char *filename, QemuOpts *options, Error **errp)
{
int header_size, backing_filename_len, l1_size, shift, i;
QCowHeader header;
uint8_t *tmp;
int64_t total_size = 0;
const char *backing_file = NULL;
- int flags = 0;
+ uint64_t flags = 0;
Error *local_err = NULL;
int ret;
BlockDriverState *qcow_bs;
- /* Read out options */
- while (options && options->name) {
- if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
- total_size = options->value.n / 512;
- } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {
- backing_file = options->value.s;
- } else if (!strcmp(options->name, BLOCK_OPT_ENCRYPT)) {
- flags |= options->value.n ? BLOCK_FLAG_ENCRYPT : 0;
- }
- options++;
+ total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+ if (total_size) {
+ total_size = total_size / 512;
}
+ backing_file = qemu_opt_get(options, BLOCK_OPT_BACKING_FILE);
+ flags |= qemu_opt_get_number(options, BLOCK_OPT_ENCRYPT, 0);
+
ret = bdrv_create_file(filename, options, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
@@ -882,23 +877,27 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
}
-static QEMUOptionParameter qcow_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
- {
- .name = BLOCK_OPT_BACKING_FILE,
- .type = OPT_STRING,
- .help = "File name of a base image"
- },
- {
- .name = BLOCK_OPT_ENCRYPT,
- .type = OPT_FLAG,
- .help = "Encrypt the image"
+static QemuOptsList qcow_create_options = {
+ .name = "qcow_create_options",
+ .head = QTAILQ_HEAD_INITIALIZER(qcow_create_options.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FILE,
+ .type = QEMU_OPT_STRING,
+ .help = "File name of a base image"
+ },
+ {
+ .name = BLOCK_OPT_ENCRYPT,
+ .type = QEMU_OPT_NUMBER,
+ .help = "Encrypt the image"
+ },
+ { NULL }
},
- { NULL }
};
static BlockDriver bdrv_qcow = {
@@ -920,7 +919,7 @@ static BlockDriver bdrv_qcow = {
.bdrv_write_compressed = qcow_write_compressed,
.bdrv_get_info = qcow_get_info,
- .create_options = qcow_create_options,
+ .create_options = &qcow_create_options,
};
static void bdrv_qcow_init(void)
Do the directly migration from QemuOptionParameter to QemuOpts on qcow block driver. Signed-off-by: Leandro Dorileo <l@dorileo.org> --- block/qcow.c | 59 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 30 deletions(-)