[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 6/7] create new function: qemu_opt_set_number
From: |
Dong Xu Wang |
Subject: |
[Qemu-devel] [RFC v2 6/7] create new function: qemu_opt_set_number |
Date: |
Thu, 27 Sep 2012 13:14:24 +0800 |
Signed-off-by: Dong Xu Wang <address@hidden>
---
qemu-option.c | 8 ++++++++
qemu-option.h | 1 +
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/qemu-option.c b/qemu-option.c
index 818408b..2b52576 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -678,6 +678,14 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name,
bool val)
return qemu_opt_set(opts, name, val ? "on" : "off");
}
+int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val)
+{
+ char buffer[1024];
+ snprintf(buffer, sizeof(buffer), "%" PRId64, val);
+ return qemu_opt_set(opts, name, buffer);
+}
+
+
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.1
- [Qemu-devel] [RFC v2 0/7] replace QEMUOptionParameter with QemuOpts parser, Dong Xu Wang, 2012/09/27
- [Qemu-devel] [RFC v2 1/7] qemu-option: qemu_opt_set_bool(): fix code duplication, Dong Xu Wang, 2012/09/27
- [Qemu-devel] [RFC v2 2/7] qemu-option: opt_set(): split it up into more functions, Dong Xu Wang, 2012/09/27
- [Qemu-devel] [RFC v2 3/7] qemu-option: qemu_opts_validate(): fix duplicated code, Dong Xu Wang, 2012/09/27
- [Qemu-devel] [RFC v2 4/7] introduce qemu_opts_create_nofail function, Dong Xu Wang, 2012/09/27
- [Qemu-devel] [RFC v2 5/7] use qemu_opts_create_nofail, Dong Xu Wang, 2012/09/27
- [Qemu-devel] [RFC v2 6/7] create new function: qemu_opt_set_number,
Dong Xu Wang <=
- [Qemu-devel] [RFC v2 7/7] remove QEMUOptionParameter, Dong Xu Wang, 2012/09/27