diff options
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c index 7810e9fb68..78b927f045 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)) { |