guest agent: add RPC blacklist command-line option

This adds a command-line option, -b/--blacklist, that accepts a
comma-seperated list of RPCs to disable, or prints a list of
available RPCs if passed "?".

In consequence this also adds general blacklisting and RPC listing
facilities to the new QMP dispatch/registry facilities, should the
QMP monitor ever have a need for such a thing.

Ideally, to avoid support/compatability issues in the future,
blacklisting guest agent functionality will be the exceptional
case, but we add the functionality here to handle guest administrators
with specific requirements.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Michael Roth 2011-12-06 22:03:42 -06:00 committed by Anthony Liguori
parent 4cb016587a
commit abd6cf6d8e
6 changed files with 86 additions and 8 deletions

View file

@ -14,7 +14,7 @@
#include "qapi/qmp-core.h"
static QTAILQ_HEAD(, QmpCommand) qmp_commands =
static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
QTAILQ_HEAD_INITIALIZER(qmp_commands);
void qmp_register_command(const char *name, QmpCommandFunc *fn)
@ -24,17 +24,50 @@ void qmp_register_command(const char *name, QmpCommandFunc *fn)
cmd->name = name;
cmd->type = QCT_NORMAL;
cmd->fn = fn;
cmd->enabled = true;
QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node);
}
QmpCommand *qmp_find_command(const char *name)
{
QmpCommand *i;
QmpCommand *cmd;
QTAILQ_FOREACH(i, &qmp_commands, node) {
if (strcmp(i->name, name) == 0) {
return i;
QTAILQ_FOREACH(cmd, &qmp_commands, node) {
if (strcmp(cmd->name, name) == 0) {
return cmd;
}
}
return NULL;
}
void qmp_disable_command(const char *name)
{
QmpCommand *cmd;
QTAILQ_FOREACH(cmd, &qmp_commands, node) {
if (strcmp(cmd->name, name) == 0) {
cmd->enabled = false;
return;
}
}
}
char **qmp_get_command_list(void)
{
QmpCommand *cmd;
int count = 1;
char **list_head, **list;
QTAILQ_FOREACH(cmd, &qmp_commands, node) {
count++;
}
list_head = list = g_malloc0(count * sizeof(char *));
QTAILQ_FOREACH(cmd, &qmp_commands, node) {
*list = strdup(cmd->name);
list++;
}
return list_head;
}