[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_vi
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor |
Date: |
Thu, 21 Nov 2013 03:38:26 +0100 |
Signed-off-by: Igor Mammedov <address@hidden>
---
qapi/string-input-visitor.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 8f1bc41..a152f5d 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -97,6 +97,23 @@ static void parse_type_number(Visitor *v, double *obj, const
char *name,
*obj = val;
}
+static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
+ Error **errp)
+{
+ StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
+ int64_t val;
+ char *endp;
+
+ val = strtosz_suffix(siv->string ? siv->string : "", &endp,
+ STRTOSZ_DEFSUFFIX_B);
+ if (val < 0 || *endp != '\0') {
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
+ "a size value representible as a non-negative int64");
+ return;
+ }
+ *obj = val;
+}
+
static void parse_start_optional(Visitor *v, bool *present,
const char *name, Error **errp)
{
@@ -131,6 +148,7 @@ StringInputVisitor *string_input_visitor_new(const char
*str)
v->visitor.type_bool = parse_type_bool;
v->visitor.type_str = parse_type_str;
v->visitor.type_number = parse_type_number;
+ v->visitor.type_size = parse_type_size;
v->visitor.start_optional = parse_start_optional;
v->string = str;
--
1.7.1
Re: [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse(), Paolo Bonzini, 2013/11/25
[Qemu-devel] [PATCH 02/27] rename pci_hotplug_fn to hotplug_fn and make it available for other devices, Igor Mammedov, 2013/11/20
[Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor,
Igor Mammedov <=
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Markus Armbruster, 2013/11/21
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Igor Mammedov, 2013/11/25
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Michael S. Tsirkin, 2013/11/25
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Paolo Bonzini, 2013/11/25
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Eric Blake, 2013/11/25
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Paolo Bonzini, 2013/11/25
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Markus Armbruster, 2013/11/27
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Paolo Bonzini, 2013/11/27
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Markus Armbruster, 2013/11/27
- Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor, Paolo Bonzini, 2013/11/27