diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2014-09-08 13:14:41 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2014-09-08 13:14:41 +0100 |
| commit | 1bc0e405816c9c6bde5695af20b07a1491ce1f9f (patch) | |
| tree | 616f83e0841e34ae48e2312c28d8165f40a23cb9 /qapi/qapi-util.c | |
| parent | 2d6838e86ce942f886401818b48d77e575a5f7de (diff) | |
| parent | 01ce352e62c3f86df6f4ad32c3ab9353e55af799 (diff) | |
| download | focaccia-qemu-1bc0e405816c9c6bde5695af20b07a1491ce1f9f.tar.gz focaccia-qemu-1bc0e405816c9c6bde5695af20b07a1491ce1f9f.zip | |
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request # gpg: Signature made Mon 08 Sep 2014 11:49:31 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: (24 commits) ide: Add resize callback to ide/core IDE: Fill the IDENTIFY request consistently vmdk: fix buf leak in vmdk_parse_extents() vmdk: fix vmdk_parse_extents() extent_file leaks ide: Add wwn support to IDE-ATAPI drive qtest/ide: Uninitialize PC allocator libqos: add a simple first-fit memory allocator MAINTAINERS: update sheepdog maintainer qemu-nbd: fix indentation and coding style qemu-nbd: add option to set detect-zeroes mode rename parse_enum_option to qapi_enum_parse and make it public block/archipelago: Use QEMU atomic builtins qemu-img: fix rebase src_cache option documentation qemu-img: clarify src_cache option documentation libqos: Added EVENT_IDX support libqos: Added MSI-X support libqos: Added test case for configuration changes in virtio-blk test libqos: Added indirect descriptor support to virtio implementation libqos: Added basic virtqueue support to virtio implementation tests: Add virtio device initialization ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qapi/qapi-util.c')
| -rw-r--r-- | qapi/qapi-util.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c new file mode 100644 index 0000000000..1d8fb96eff --- /dev/null +++ b/qapi/qapi-util.c @@ -0,0 +1,34 @@ +/* + * QAPI util functions + * + * Authors: + * Hu Tao <hutao@cn.fujitsu.com> + * Peter Lieven <pl@kamp.de> + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#include "qemu-common.h" +#include "qapi/error.h" +#include "qapi/util.h" + +int qapi_enum_parse(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; +} |