[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 28/43] create new function: qemu_opt_set_number
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 28/43] create new function: qemu_opt_set_number |
Date: |
Thu, 13 Dec 2012 16:10:35 +0100 |
From: Dong Xu Wang <address@hidden>
Signed-off-by: Dong Xu Wang <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-option.c | 22 ++++++++++++++++++++++
qemu-option.h | 1 +
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/qemu-option.c b/qemu-option.c
index 1303188..94557cf 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -695,6 +695,28 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name,
bool val)
return 0;
}
+int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val)
+{
+ QemuOpt *opt;
+ const QemuOptDesc *desc = opts->list->desc;
+
+ opt = g_malloc0(sizeof(*opt));
+ opt->desc = find_desc_by_name(desc, name);
+ if (!opt->desc && !opts_accepts_any(opts)) {
+ qerror_report(QERR_INVALID_PARAMETER, name);
+ g_free(opt);
+ return -1;
+ }
+
+ opt->name = g_strdup(name);
+ opt->opts = opts;
+ opt->value.uint = val;
+ opt->str = g_strdup_printf("%" PRId64, val);
+ QTAILQ_INSERT_TAIL(&opts->head, opt, next);
+
+ return 0;
+}
+
int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
int abort_on_failure)
{
diff --git a/qemu-option.h b/qemu-option.h
index b0f8d1e..002dd07 100644
--- a/qemu-option.h
+++ b/qemu-option.h
@@ -126,6 +126,7 @@ int qemu_opt_set(QemuOpts *opts, const char *name, const
char *value);
void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value,
Error **errp);
int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val);
+int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val);
typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void
*opaque);
int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
int abort_on_failure);
--
1.7.6.5
- [Qemu-devel] [PATCH 24/43] qemu-option: qemu_opts_validate(): fix duplicated code, (continued)
- [Qemu-devel] [PATCH 24/43] qemu-option: qemu_opts_validate(): fix duplicated code, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 42/43] qcow2: Execute run_dependent_requests() without lock, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 38/43] qcow2: Allocate l2meta dynamically, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 40/43] qcow2: Allocate l2meta only for cluster allocations, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 36/43] qcow2: Round QCowL2Meta.offset down to cluster boundary, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 34/43] qemu-iotests: Test concurrent cluster allocations, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 37/43] qcow2: Introduce Qcow2COWRegion, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 25/43] qemu-option: qemu_opt_set_bool(): fix code duplication, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 18/43] block: bdrv_img_create(): drop unused error handling code, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 32/43] qemu-io: Add AIO debugging commands, Kevin Wolf, 2012/12/13
- [Qemu-devel] [PATCH 28/43] create new function: qemu_opt_set_number,
Kevin Wolf <=
- [Qemu-devel] [PATCH 23/43] qemu-option: opt_set(): split it up into more functions, Kevin Wolf, 2012/12/13