aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-04-27 17:28:41 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-04-27 17:28:41 +0100
commit0d81cdddaa40a1988b24657aeac19959cfad0fde (patch)
tree2c41f3347b5cfac69d1cf8c5d2ce7f161a4d225e
parente1a5476354d396773e4c555f126d752d4ae58fa9 (diff)
parent2d5a8346a484250934526a15b3a522bdba7e6772 (diff)
Merge remote-tracking branch 'remotes/qmp-unstable/tags/for-upstream' into staging
Four little fixes # gpg: Signature made Fri Apr 24 19:56:51 2015 BST using RSA key ID E24ED5A7 # gpg: Good signature from "Luiz Capitulino <lcapitulino@gmail.com>" * remotes/qmp-unstable/tags/for-upstream: qmp: Give saner messages related to qmp_capabilities misuse qmp-commands: fix incorrect uses of ":O" specifier qapi: Drop dead genlist parameter balloon: improve error msg when adding second device Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--balloon.c1
-rw-r--r--hw/virtio/virtio-balloon.c2
-rw-r--r--monitor.c23
-rw-r--r--qmp-commands.hx4
-rw-r--r--scripts/qapi-visit.py22
5 files changed, 31 insertions, 21 deletions
diff --git a/balloon.c b/balloon.c
index 70c00f5f84..c7033e3dc3 100644
--- a/balloon.c
+++ b/balloon.c
@@ -58,7 +58,6 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
/* We're already registered one balloon handler. How many can
* a guest really have?
*/
- error_report("Another balloon device already registered");
return -1;
}
balloon_event_fn = event_func;
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 95b0643448..484c3c333c 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -383,7 +383,7 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
virtio_balloon_stat, s);
if (ret < 0) {
- error_setg(errp, "Adding balloon handler failed");
+ error_setg(errp, "Only one balloon device is supported");
virtio_cleanup(vdev);
return;
}
diff --git a/monitor.c b/monitor.c
index 68873ec09c..9f37700486 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4783,10 +4783,22 @@ static int monitor_can_read(void *opaque)
return (mon->suspend_cnt == 0) ? 1 : 0;
}
-static int invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
+static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
{
- int is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
- return (qmp_cmd_mode(mon) ? is_cap : !is_cap);
+ bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
+ if (is_cap && qmp_cmd_mode(mon)) {
+ qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
+ "Capabilities negotiation is already complete, command "
+ "'%s' ignored", cmd->name);
+ return true;
+ }
+ if (!is_cap && !qmp_cmd_mode(mon)) {
+ qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
+ "Expecting capabilities negotiation with "
+ "'qmp_capabilities' before command '%s'", cmd->name);
+ return true;
+ }
+ return false;
}
/*
@@ -5080,11 +5092,14 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
cmd_name = qdict_get_str(input, "execute");
trace_handle_qmp_command(mon, cmd_name);
cmd = qmp_find_cmd(cmd_name);
- if (!cmd || invalid_qmp_mode(mon, cmd)) {
+ if (!cmd) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"The command %s has not been found", cmd_name);
goto err_out;
}
+ if (invalid_qmp_mode(mon, cmd)) {
+ goto err_out;
+ }
obj = qdict_get(input, "arguments");
if (!obj) {
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 3a42ad0bff..09f48bada5 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -332,7 +332,7 @@ EQMP
{
.name = "send-key",
- .args_type = "keys:O,hold-time:i?",
+ .args_type = "keys:q,hold-time:i?",
.mhandler.cmd_new = qmp_marshal_input_send_key,
},
@@ -3288,7 +3288,7 @@ EQMP
{
.name = "migrate-set-capabilities",
- .args_type = "capabilities:O",
+ .args_type = "capabilities:q",
.params = "capability:s,state:b",
.mhandler.cmd_new = qmp_marshal_input_migrate_set_capabilities,
},
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 8f845a2b29..1be4d67d8a 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -2,7 +2,7 @@
# QAPI visitor generator
#
# Copyright IBM, Corp. 2011
-# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2014-2015 Red Hat, Inc.
#
# Authors:
# Anthony Liguori <aliguori@us.ibm.com>
@@ -401,34 +401,31 @@ out:
return ret
-def generate_declaration(name, members, genlist=True, builtin_type=False):
+def generate_declaration(name, members, builtin_type=False):
ret = ""
if not builtin_type:
ret += mcgen('''
void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **errp);
''',
- name=name)
+ name=name)
- if genlist:
- ret += mcgen('''
+ ret += mcgen('''
void visit_type_%(name)sList(Visitor *m, %(name)sList **obj, const char *name, Error **errp);
''',
name=name)
return ret
-def generate_enum_declaration(name, members, genlist=True):
- ret = ""
- if genlist:
- ret += mcgen('''
+def generate_enum_declaration(name, members):
+ ret = mcgen('''
void visit_type_%(name)sList(Visitor *m, %(name)sList **obj, const char *name, Error **errp);
''',
- name=name)
+ name=name)
return ret
-def generate_decl_enum(name, members, genlist=True):
+def generate_decl_enum(name, members):
return mcgen('''
void visit_type_%(name)s(Visitor *m, %(name)s *obj, const char *name, Error **errp);
@@ -542,8 +539,7 @@ exprs = parse_schema(input_file)
# for built-in types in our header files and simply guard them
fdecl.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
for typename in builtin_types:
- fdecl.write(generate_declaration(typename, None, genlist=True,
- builtin_type=True))
+ fdecl.write(generate_declaration(typename, None, builtin_type=True))
fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
# ...this doesn't work for cases where we link in multiple objects that