aboutsummaryrefslogtreecommitdiff
path: root/block/quorum.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/quorum.c')
-rw-r--r--block/quorum.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/block/quorum.c b/block/quorum.c
index d04da4f430..272f9a5b77 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -867,30 +867,13 @@ static QemuOptsList quorum_runtime_opts = {
},
};
-static int parse_read_pattern(const char *opt)
-{
- int i;
-
- if (!opt) {
- /* Set quorum as default */
- return QUORUM_READ_PATTERN_QUORUM;
- }
-
- for (i = 0; i < QUORUM_READ_PATTERN__MAX; i++) {
- if (!strcmp(opt, QuorumReadPattern_lookup[i])) {
- return i;
- }
- }
-
- return -EINVAL;
-}
-
static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQuorumState *s = bs->opaque;
Error *local_err = NULL;
QemuOpts *opts = NULL;
+ const char *pattern_str;
bool *opened;
int i;
int ret = 0;
@@ -925,7 +908,13 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
goto exit;
}
- ret = parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN));
+ pattern_str = qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN);
+ if (!pattern_str) {
+ ret = QUORUM_READ_PATTERN_QUORUM;
+ } else {
+ ret = qapi_enum_parse(&QuorumReadPattern_lookup, pattern_str,
+ -EINVAL, NULL);
+ }
if (ret < 0) {
error_setg(&local_err, "Please set read-pattern as fifo or quorum");
goto exit;