From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH 05/16] hmp: Use qapi_enum_parse() in hmp_migrate_set_capability()
Date: Thu, 24 Aug 2017 10:46:00 +0200 [thread overview]
Message-ID: <1503564371-26090-6-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1503564371-26090-1-git-send-email-armbru@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The error message on invalid capability name changes from
Invalid parameter "NAME"
to
invalid parameter value: NAME
No worse than before.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-9-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, commit message rewritten]
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hmp.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/hmp.c b/hmp.c
index 03c1a78..7e0bd3d 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1527,23 +1527,20 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
bool state = qdict_get_bool(qdict, "state");
Error *err = NULL;
MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps));
- int i;
+ int val;
- for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
- if (strcmp(cap, MigrationCapability_lookup[i]) == 0) {
- caps->value = g_malloc0(sizeof(*caps->value));
- caps->value->capability = i;
- caps->value->state = state;
- caps->next = NULL;
- qmp_migrate_set_capabilities(caps, &err);
- break;
- }
+ val = qapi_enum_parse(MigrationCapability_lookup, cap, -1, &err);
+ if (val < 0) {
+ goto end;
}
- if (i == MIGRATION_CAPABILITY__MAX) {
- error_setg(&err, QERR_INVALID_PARAMETER, cap);
- }
+ caps->value = g_malloc0(sizeof(*caps->value));
+ caps->value->capability = val;
+ caps->value->state = state;
+ caps->next = NULL;
+ qmp_migrate_set_capabilities(caps, &err);
+end:
qapi_free_MigrationCapabilityStatusList(caps);
if (err) {
--
2.7.5
next prev parent reply other threads:[~2017-08-24 8:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 8:45 [Qemu-devel] [PATCH 00/16] qapi: Rework mapping of enum value to string Markus Armbruster
2017-08-24 8:45 ` [Qemu-devel] [PATCH 01/16] qapi: Update qapi-code-gen.txt examples to match current code Markus Armbruster
2017-08-24 10:43 ` Marc-André Lureau
2017-08-24 16:32 ` Eric Blake
2017-08-24 18:29 ` Markus Armbruster
2017-08-24 8:45 ` [Qemu-devel] [PATCH 02/16] qapi: Drop superfluous qapi_enum_parse() parameter max Markus Armbruster
2017-08-24 10:45 ` Marc-André Lureau
2017-08-24 16:38 ` Eric Blake
2017-08-24 18:35 ` Markus Armbruster
2017-08-24 18:56 ` Eric Blake
2017-08-24 19:24 ` Markus Armbruster
2017-08-24 8:45 ` [Qemu-devel] [PATCH 03/16] tpm: Clean up driver registration & lookup Markus Armbruster
2017-08-24 8:45 ` [Qemu-devel] [PATCH 04/16] tpm: Clean up model " Markus Armbruster
2017-08-24 10:50 ` Marc-André Lureau
2017-08-24 18:35 ` Markus Armbruster
2017-08-24 8:46 ` Markus Armbruster [this message]
2017-08-24 8:46 ` [Qemu-devel] [PATCH 06/16] hmp: Use qapi_enum_parse() in hmp_migrate_set_parameter() Markus Armbruster
2017-08-24 8:46 ` [Qemu-devel] [PATCH 07/16] block: Use qemu_enum_parse() in blkdebug_debug_breakpoint() Markus Armbruster
2017-08-24 8:46 ` [Qemu-devel] [PATCH 08/16] quorum: Use qapi_enum_parse() in quorum_open() Markus Armbruster
2017-08-24 8:46 ` [Qemu-devel] [PATCH 09/16] crypto: Use qapi_enum_parse() in qcrypto_block_luks_name_lookup() Markus Armbruster
2017-08-24 10:53 ` Marc-André Lureau
2017-08-29 11:10 ` Daniel P. Berrange
2017-08-24 8:46 ` [Qemu-devel] [PATCH 10/16] qapi: Use qapi_enum_parse() in input_type_enum() Markus Armbruster
2017-08-24 11:30 ` Marc-André Lureau
2017-08-24 8:46 ` [Qemu-devel] [PATCH 11/16] qapi: Avoid unnecessary use of enum lookup table's sentinel Markus Armbruster
2017-08-24 11:34 ` Marc-André Lureau
2017-08-24 8:46 ` [Qemu-devel] [PATCH 12/16] qapi: Generate FOO_str() macro for QAPI enum FOO Markus Armbruster
2017-08-30 13:42 ` Marc-André Lureau
2017-08-24 8:46 ` [Qemu-devel] [PATCH 13/16] qapi: Mechanically convert FOO_lookup[...] to FOO_str(...) Markus Armbruster
2017-08-24 11:52 ` Marc-André Lureau
2017-08-24 8:46 ` [Qemu-devel] [PATCH 14/16] qapi: Convert indirect uses of FOO_lookup[...] to qapi_enum_lookup() Markus Armbruster
2017-08-24 12:02 ` Marc-André Lureau
2017-08-24 8:46 ` [Qemu-devel] [PATCH 15/16] qapi: Change data type of the FOO_lookup generated for enum FOO Markus Armbruster
2017-08-24 9:55 ` Markus Armbruster
2017-08-24 8:46 ` [Qemu-devel] [PATCH 16/16] qapi: drop the sentinel in enum array Markus Armbruster
2017-08-24 9:22 ` [Qemu-devel] [PATCH 00/16] qapi: Rework mapping of enum value to string no-reply
2017-09-01 12:43 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1503564371-26090-6-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).