qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
b0869a46b2
commit
20caf0f766
28
qemu-img.c
28
qemu-img.c
@ -1567,14 +1567,19 @@ static int img_resize(int argc, char **argv)
|
|||||||
const char *filename, *fmt, *size;
|
const char *filename, *fmt, *size;
|
||||||
int64_t n, total_size;
|
int64_t n, total_size;
|
||||||
BlockDriverState *bs = NULL;
|
BlockDriverState *bs = NULL;
|
||||||
QEMUOptionParameter *param;
|
QemuOpts *param;
|
||||||
QEMUOptionParameter resize_options[] = {
|
static QemuOptsList resize_options = {
|
||||||
{
|
.name = "resize_options",
|
||||||
.name = BLOCK_OPT_SIZE,
|
.head = QTAILQ_HEAD_INITIALIZER(resize_options.head),
|
||||||
.type = OPT_SIZE,
|
.desc = {
|
||||||
.help = "Virtual disk size"
|
{
|
||||||
|
.name = BLOCK_OPT_SIZE,
|
||||||
|
.type = QEMU_OPT_SIZE,
|
||||||
|
.help = "Virtual disk size"
|
||||||
|
}, {
|
||||||
|
/* end of list */
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Remove size from argv manually so that negative numbers are not treated
|
/* Remove size from argv manually so that negative numbers are not treated
|
||||||
@ -1624,14 +1629,15 @@ static int img_resize(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse size */
|
/* Parse size */
|
||||||
param = parse_option_parameters("", resize_options, NULL);
|
param = qemu_opts_create(&resize_options, NULL, 0, NULL);
|
||||||
if (set_option_parameter(param, BLOCK_OPT_SIZE, size)) {
|
if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) {
|
||||||
/* Error message already printed when size parsing fails */
|
/* Error message already printed when size parsing fails */
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
qemu_opts_del(param);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
n = get_option_parameter(param, BLOCK_OPT_SIZE)->value.n;
|
n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
|
||||||
free_option_parameters(param);
|
qemu_opts_del(param);
|
||||||
|
|
||||||
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
|
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
|
||||||
if (!bs) {
|
if (!bs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user