From patchwork Wed Jun 5 12:19:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 249021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF2002C00A0 for ; Wed, 5 Jun 2013 22:38:22 +1000 (EST) Received: from localhost ([::1]:36972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkCmW-0004CI-Ph for incoming@patchwork.ozlabs.org; Wed, 05 Jun 2013 08:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkChc-0005DZ-La for qemu-devel@nongnu.org; Wed, 05 Jun 2013 08:20:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkChX-0004ji-Fb for qemu-devel@nongnu.org; Wed, 05 Jun 2013 08:20:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkChX-0004jb-75 for qemu-devel@nongnu.org; Wed, 05 Jun 2013 08:20:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r55CKQtd022747 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Jun 2013 08:20:26 -0400 Received: from dhcp-200-207.str.redhat.com (dhcp-192-246.str.redhat.com [10.33.192.246]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r55CJigA018138; Wed, 5 Jun 2013 08:20:25 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 5 Jun 2013 14:19:39 +0200 Message-Id: <1370434781-28570-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1370434781-28570-1-git-send-email-kwolf@redhat.com> References: <1370434781-28570-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v2 14/16] qemu-io: Interface cleanup 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 Signed-off-by: Kevin Wolf --- cmd.h | 48 ------------------------------------------------ include/qemu-io.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ qemu-io-cmds.c | 14 +++++++------- qemu-io.c | 7 +++---- 4 files changed, 56 insertions(+), 59 deletions(-) delete mode 100644 cmd.h create mode 100644 include/qemu-io.h diff --git a/cmd.h b/cmd.h deleted file mode 100644 index 9907795..0000000 --- a/cmd.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -#ifndef __COMMAND_H__ -#define __COMMAND_H__ - -#include "qemu-common.h" - -#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ - -extern BlockDriverState *qemuio_bs; - -typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv); -typedef void (*helpfunc_t)(void); - -typedef struct cmdinfo { - const char *name; - const char *altname; - cfunc_t cfunc; - int argmin; - int argmax; - int canpush; - int flags; - const char *args; - const char *oneline; - helpfunc_t help; -} cmdinfo_t; - -void qemuio_add_command(const cmdinfo_t *ci); - -int qemuio_command_usage(const cmdinfo_t *ci); - -bool qemuio_command(const char *cmd); - -#endif /* __COMMAND_H__ */ diff --git a/include/qemu-io.h b/include/qemu-io.h new file mode 100644 index 0000000..a418b46 --- /dev/null +++ b/include/qemu-io.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2000-2005 Silicon Graphics, Inc. + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef QEMU_IO_H +#define QEMU_IO_H + +#include "qemu-common.h" + +#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ + +typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv); +typedef void (*helpfunc_t)(void); + +typedef struct cmdinfo { + const char* name; + const char* altname; + cfunc_t cfunc; + int argmin; + int argmax; + int canpush; + int flags; + const char *args; + const char *oneline; + helpfunc_t help; +} cmdinfo_t; + +bool qemuio_command(BlockDriverState *bs, const char *cmd); + +void qemuio_add_command(const cmdinfo_t *ci); +int qemuio_command_usage(const cmdinfo_t *ci); + +#endif /* QEMU_IO_H */ diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 05ce342..ffbcf31 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -8,9 +8,8 @@ * See the COPYING file in the top-level directory. */ -#include "qemu-common.h" +#include "qemu-io.h" #include "block/block_int.h" -#include "cmd.h" #define CMD_NOFILE_OK 0x01 @@ -50,11 +49,12 @@ static int init_check_command(BlockDriverState *bs, const cmdinfo_t *ct) return 1; } -static int command(const cmdinfo_t *ct, int argc, char **argv) +static int command(BlockDriverState *bs, const cmdinfo_t *ct, int argc, + char **argv) { char *cmd = argv[0]; - if (!init_check_command(qemuio_bs, ct)) { + if (!init_check_command(bs, ct)) { return 0; } @@ -75,7 +75,7 @@ static int command(const cmdinfo_t *ct, int argc, char **argv) return 0; } optind = 0; - return ct->cfunc(qemuio_bs, argc, argv); + return ct->cfunc(bs, argc, argv); } static const cmdinfo_t *find_command(const char *cmd) @@ -2068,7 +2068,7 @@ static const cmdinfo_t help_cmd = { .oneline = "help for one or all commands", }; -bool qemuio_command(const char *cmd) +bool qemuio_command(BlockDriverState *bs, const char *cmd) { char *input; const cmdinfo_t *ct; @@ -2081,7 +2081,7 @@ bool qemuio_command(const char *cmd) if (c) { ct = find_command(v[0]); if (ct) { - done = command(ct, c, v); + done = command(bs, ct, c, v); } else { fprintf(stderr, "command \"%s\" not found\n", v[0]); } diff --git a/qemu-io.c b/qemu-io.c index eec8cbc..514edcb 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -14,10 +14,9 @@ #include #include -#include "qemu-common.h" +#include "qemu-io.h" #include "qemu/main-loop.h" #include "block/block_int.h" -#include "cmd.h" #include "trace/control.h" #define VERSION "0.0.1" @@ -273,7 +272,7 @@ static void command_loop(void) char *input; for (i = 0; !done && i < ncmdline; i++) { - done = qemuio_command(cmdline[i]); + done = qemuio_command(qemuio_bs, cmdline[i]); } if (cmdline) { g_free(cmdline); @@ -298,7 +297,7 @@ static void command_loop(void) if (input == NULL) { break; } - done = qemuio_command(input); + done = qemuio_command(qemuio_bs, input); g_free(input); prompted = 0;