[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 11/15] gluster: Don't duplicate qapi-util.c's qap
From: |
Markus Armbruster |
Subject: |
[Qemu-block] [PATCH v2 11/15] gluster: Don't duplicate qapi-util.c's qapi_enum_parse() |
Date: |
Mon, 6 Mar 2017 20:00:45 +0100 |
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Niels de Vos <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;
}
--
2.7.4
- [Qemu-block] [PATCH v2 01/15] sheepdog: Defuse time bomb in sd_open() error handling, (continued)
- [Qemu-block] [PATCH v2 01/15] sheepdog: Defuse time bomb in sd_open() error handling, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 08/15] sheepdog: Use SocketAddress and socket_connect(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 10/15] gluster: Drop assumptions on SocketTransport names, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 06/15] sheepdog: Don't truncate long VDI name in _open(), _create(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 05/15] sheepdog: Fix snapshot ID parsing in _open(), _create, _goto(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 12/15] gluster: Plug memory leaks in qemu_gluster_parse_json(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 07/15] sheepdog: Report errors in pseudo-filename more usefully, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 13/15] qapi-schema: Rename GlusterServer to SocketAddressFlat, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 09/15] sheepdog: Implement bdrv_parse_filename(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 11/15] gluster: Don't duplicate qapi-util.c's qapi_enum_parse(),
Markus Armbruster <=
- [Qemu-block] [PATCH v2 15/15] sheepdog: Support blockdev-add, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 14/15] qapi-schema: Rename SocketAddressFlat's variant tcp to inet, Markus Armbruster, 2017/03/06
- Re: [Qemu-block] [PATCH v2 00/15] block: A bunch of fixes for Sheepdog and Gluster, Kevin Wolf, 2017/03/07