From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH6QZ-0007gL-Vp for qemu-devel@nongnu.org; Thu, 27 Sep 2012 01:14:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TH6QZ-0003aL-3N for qemu-devel@nongnu.org; Thu, 27 Sep 2012 01:14:23 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:53262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH6QY-0003XY-UK for qemu-devel@nongnu.org; Thu, 27 Sep 2012 01:14:23 -0400 Received: by mail-ob0-f173.google.com with SMTP id ta14so1308124obb.4 for ; Wed, 26 Sep 2012 22:14:22 -0700 (PDT) Sender: Dong Xu Wang From: Dong Xu Wang Date: Thu, 27 Sep 2012 13:14:24 +0800 Message-Id: <1348722865-20564-7-git-send-email-wdongxu@linux.vnet.ibm.com> In-Reply-To: <1348722865-20564-1-git-send-email-wdongxu@linux.vnet.ibm.com> References: <1348722865-20564-1-git-send-email-wdongxu@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC v2 6/7] create new function: qemu_opt_set_number List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Dong Xu Wang , armbru@redhat.com, lcapitulino@redhat.com Signed-off-by: Dong Xu Wang --- 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