[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 21/27] gluster: Don't duplicate qapi-util.c's qapi_en
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 21/27] gluster: Don't duplicate qapi-util.c's qapi_enum_parse() |
Date: |
Tue, 7 Mar 2017 16:40:45 +0100 |
From: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Niels de Vos <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/gluster.c | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
index 7236d59..6fbcf9e 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -12,6 +12,7 @@
#include "block/block_int.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
+#include "qapi/util.h"
#include "qemu/uri.h"
#include "qemu/error-report.h"
#include "qemu/cutils.h"
@@ -472,23 +473,6 @@ out:
return NULL;
}
-static int qapi_enum_parse(const char *opt)
-{
- int i;
-
- if (!opt) {
- return GLUSTER_TRANSPORT__MAX;
- }
-
- for (i = 0; i < GLUSTER_TRANSPORT__MAX; i++) {
- if (!strcmp(opt, GlusterTransport_lookup[i])) {
- return i;
- }
- }
-
- return i;
-}
-
/*
* Convert the json formatted command line into qapi.
*/
@@ -546,16 +530,20 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster
*gconf,
ptr = qemu_opt_get(opts, GLUSTER_OPT_TYPE);
gsconf = g_new0(GlusterServer, 1);
- gsconf->type = qapi_enum_parse(ptr);
+ gsconf->type = qapi_enum_parse(GlusterTransport_lookup, ptr,
+ GLUSTER_TRANSPORT__MAX,
+ GLUSTER_TRANSPORT__MAX,
+ &local_err);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
- if (gsconf->type == GLUSTER_TRANSPORT__MAX) {
- error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE,
- GLUSTER_OPT_TYPE, "tcp or unix");
+ if (local_err) {
+ error_append_hint(&local_err,
+ "Parameter '%s' may be 'tcp' or 'unix'\n",
+ GLUSTER_OPT_TYPE);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
--
1.8.3.1
- [Qemu-block] [PULL 10/27] block: Fix error handling in bdrv_replace_in_backing_chain(), (continued)
- [Qemu-block] [PULL 10/27] block: Fix error handling in bdrv_replace_in_backing_chain(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 13/27] sheepdog: Fix error handling sd_create(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 14/27] sheepdog: Mark sd_snapshot_delete() lossage FIXME, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 12/27] sheepdog: Fix error handling in sd_snapshot_delete(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 15/27] sheepdog: Fix snapshot ID parsing in _open(), _create, _goto(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 16/27] sheepdog: Don't truncate long VDI name in _open(), _create(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 19/27] sheepdog: Implement bdrv_parse_filename(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 17/27] sheepdog: Report errors in pseudo-filename more usefully, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 18/27] sheepdog: Use SocketAddress and socket_connect(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 20/27] gluster: Drop assumptions on SocketTransport names, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 21/27] gluster: Don't duplicate qapi-util.c's qapi_enum_parse(),
Kevin Wolf <=
- [Qemu-block] [PULL 22/27] gluster: Plug memory leaks in qemu_gluster_parse_json(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 25/27] sheepdog: Support blockdev-add, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 24/27] qapi-schema: Rename SocketAddressFlat's variant tcp to inet, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 23/27] qapi-schema: Rename GlusterServer to SocketAddressFlat, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 27/27] commit: Don't use error_abort in commit_start, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 26/27] block: Don't use error_abort in blk_new_open, Kevin Wolf, 2017/03/07
- Re: [Qemu-block] [Qemu-devel] [PULL 00/27] Block layer fixes for 2.9.0-rc0, Peter Maydell, 2017/03/08