[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/22] blockdev: add a function to parse enum ids fro
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 21/22] blockdev: add a function to parse enum ids from strings |
Date: |
Mon, 19 May 2014 16:22:39 +0200 |
From: Peter Lieven <address@hidden>
this adds a generic function to recover the enum id of a parameter
given as a string.
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index 7810e9f..78b927f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -288,6 +288,25 @@ static int parse_block_error_action(const char *buf, bool
is_read, Error **errp)
}
}
+static inline int parse_enum_option(const char *lookup[], const char *buf,
+ int max, int def, Error **errp)
+{
+ int i;
+
+ if (!buf) {
+ return def;
+ }
+
+ for (i = 0; i < max; i++) {
+ if (!strcmp(buf, lookup[i])) {
+ return i;
+ }
+ }
+
+ error_setg(errp, "invalid parameter value: %s", buf);
+ return def;
+}
+
static bool check_throttle_config(ThrottleConfig *cfg, Error **errp)
{
if (throttle_conflicting(cfg)) {
--
1.8.3.1
- [Qemu-devel] [PULL 14/22] curl: Add usage documentation, (continued)
- [Qemu-devel] [PULL 14/22] curl: Add usage documentation, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 12/22] curl: Remove broken parsing of options from url, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 11/22] curl: Fix build when curl_multi_socket_action isn't available, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 15/22] qcow1: Make padding in the header explicit, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 16/22] qcow1: Check maximum cluster size, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 13/22] curl: Add sslverify option, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 17/22] qcow1: Validate L2 table size (CVE-2014-0222), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 19/22] qcow1: Stricter backing file length check, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 18/22] qcow1: Validate image size (CVE-2014-0223), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 20/22] util: add qemu_iovec_is_zero, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 21/22] blockdev: add a function to parse enum ids from strings,
Kevin Wolf <=
- [Qemu-devel] [PULL 22/22] block: optimize zero writes with bdrv_write_zeroes, Kevin Wolf, 2014/05/19
- Re: [Qemu-devel] [PULL 00/22] Block patches, Peter Maydell, 2014/05/22