From patchwork Wed Jun 1 17:24:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 98306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D0DC9B6EE9 for ; Thu, 2 Jun 2011 10:43:05 +1000 (EST) Received: from localhost ([::1]:49588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRw06-0007C7-1q for incoming@patchwork.ozlabs.org; Wed, 01 Jun 2011 20:43:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRvpH-0005FU-Aa for qemu-devel@nongnu.org; Wed, 01 Jun 2011 20:31:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRvpA-00068U-QQ for qemu-devel@nongnu.org; Wed, 01 Jun 2011 20:31:51 -0400 Received: from mout.perfora.net ([74.208.4.194]:54360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRpEP-0000w8-1B for qemu-devel@nongnu.org; Wed, 01 Jun 2011 13:29:21 -0400 Received: from localhost.localdomain ([32.97.110.59]) by mrelay.perfora.net (node=mrus3) with ESMTP (Nemesis) id 0Ld0TQ-1Pjvks21JI-00i8FC; Wed, 01 Jun 2011 13:29:18 -0400 From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 1 Jun 2011 12:24:41 -0500 Message-Id: <1306949089-15597-14-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1306949089-15597-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1306949089-15597-1-git-send-email-mdroth@linux.vnet.ibm.com> X-Provags-ID: V02:K0:XRF5dtACRWI+D+NLNP0Tf/6G/JB6ehR000830gJyvk2 qMq/yohIVT0EuTdtPPlIB+PstkJX/XeBsGUOGHIRv3Hc7z9oiM aLLMbf5hiX3iorBpX54I2VjsyjmgNtTaGxko/R0/GQCo6cpL2G QBpIiSj126OhPkSwA71R214+D2ER3a0JbP68q/THg/cBaWOQtF EjsfRcuAPi6XkJIj/FjLCZK/A5RUBq3epcow2+SVY8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.194 Cc: aliguori@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v1][ 13/21] qapi: add command registration/lookup functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Registration/lookup functions for that provide a lookup table for dispatching QMP commands. Signed-off-by: Michael Roth --- qapi/qmp-registry.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 qapi/qmp-registry.c diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c new file mode 100644 index 0000000..f870244 --- /dev/null +++ b/qapi/qmp-registry.c @@ -0,0 +1,27 @@ +#include "qapi/qmp-core.h" + +static QTAILQ_HEAD(, QmpCommand) qmp_commands = + QTAILQ_HEAD_INITIALIZER(qmp_commands); + +void qmp_register_command(const char *name, QmpCommandFunc *fn) +{ + QmpCommand *cmd = qemu_mallocz(sizeof(*cmd)); + + cmd->name = name; + cmd->type = QCT_NORMAL; + cmd->fn = fn; + QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node); +} + +QmpCommand *qmp_find_command(const char *name) +{ + QmpCommand *i; + + QTAILQ_FOREACH(i, &qmp_commands, node) { + if (strcmp(i->name, name) == 0) { + return i; + } + } + return NULL; +} +