aboutsummaryrefslogtreecommitdiff
path: root/qemu-option.c
diff options
context:
space:
mode:
authorDong Xu Wang <wdongxu@linux.vnet.ibm.com>2012-12-06 14:47:23 +0800
committerKevin Wolf <kwolf@redhat.com>2012-12-11 16:37:07 +0100
commitb83c18e225cf82a21535561270b6dfd86b1c9031 (patch)
tree954b3c15598f8db41bcebfa190f290cf558449af /qemu-option.c
parente478b448d7c36046462733ffaeaea0961575790a (diff)
downloadqemu-b83c18e225cf82a21535561270b6dfd86b1c9031.zip
qemu-b83c18e225cf82a21535561270b6dfd86b1c9031.tar.gz
qemu-b83c18e225cf82a21535561270b6dfd86b1c9031.tar.bz2
create new function: qemu_opt_set_number
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-option.c')
-rw-r--r--qemu-option.c22
1 files changed, 22 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)
{