mirror of https://github.com/xemu-project/xemu.git
gluster: Don't duplicate qapi-util.c's qapi_enum_parse()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
fc29458dee
commit
e152ef7a98
|
@ -12,6 +12,7 @@
|
||||||
#include "block/block_int.h"
|
#include "block/block_int.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
|
#include "qapi/util.h"
|
||||||
#include "qemu/uri.h"
|
#include "qemu/uri.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
@ -472,23 +473,6 @@ out:
|
||||||
return NULL;
|
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.
|
* 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);
|
ptr = qemu_opt_get(opts, GLUSTER_OPT_TYPE);
|
||||||
gsconf = g_new0(GlusterServer, 1);
|
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) {
|
if (!ptr) {
|
||||||
error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE);
|
error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE);
|
||||||
error_append_hint(&local_err, GERR_INDEX_HINT, i);
|
error_append_hint(&local_err, GERR_INDEX_HINT, i);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (gsconf->type == GLUSTER_TRANSPORT__MAX) {
|
if (local_err) {
|
||||||
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE,
|
error_append_hint(&local_err,
|
||||||
GLUSTER_OPT_TYPE, "tcp or unix");
|
"Parameter '%s' may be 'tcp' or 'unix'\n",
|
||||||
|
GLUSTER_OPT_TYPE);
|
||||||
error_append_hint(&local_err, GERR_INDEX_HINT, i);
|
error_append_hint(&local_err, GERR_INDEX_HINT, i);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue