Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/qmp-unstable/tags/for-upstream'…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
pm215 committed Apr 27, 2015
2 parents e1a5476 + 2d5a834 commit 0d81cdd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
1 change: 0 additions & 1 deletion balloon.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion hw/virtio/virtio-balloon.c
Expand Up @@ -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;
}
Expand Down
23 changes: 19 additions & 4 deletions monitor.c
Expand Up @@ -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;
}

/*
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions qmp-commands.hx
Expand Up @@ -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,
},

Expand Down Expand Up @@ -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,
},
Expand Down
22 changes: 9 additions & 13 deletions scripts/qapi-visit.py
Expand Up @@ -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>
Expand Down Expand Up @@ -401,34 +401,31 @@ def generate_visit_union(expr):

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);
Expand Down Expand Up @@ -542,8 +539,7 @@ def maybe_open(really, name, opt):
# 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
Expand Down

0 comments on commit 0d81cdd

Please sign in to comment.