[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/26] qemu-io: Move 'quit' function
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 10/26] qemu-io: Move 'quit' function |
Date: |
Fri, 7 Jun 2013 13:58:29 +0200 |
From: Kevin Wolf <address@hidden>
This one only makes sense in the context of the qemu-io tool, so move it
to qemu-io.c. Adapt coding style and register it like other commands.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
cmd.c | 29 -----------------------------
cmd.h | 2 --
qemu-io.c | 17 ++++++++++++++++-
3 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/cmd.c b/cmd.c
index 2941ad3..8496e74 100644
--- a/cmd.c
+++ b/cmd.c
@@ -410,32 +410,3 @@ timestr(
snprintf(ts, size, "0.%04u sec", (unsigned int) (usec * 10000));
}
}
-
-
-/* from libxcmd/quit.c */
-
-static cmdinfo_t quit_cmd;
-
-/* ARGSUSED */
-static int
-quit_f(
- BlockDriverState *bs,
- int argc,
- char **argv)
-{
- return 1;
-}
-
-void
-quit_init(void)
-{
- quit_cmd.name = _("quit");
- quit_cmd.altname = _("q");
- quit_cmd.cfunc = quit_f;
- quit_cmd.argmin = -1;
- quit_cmd.argmax = -1;
- quit_cmd.flags = CMD_FLAG_GLOBAL;
- quit_cmd.oneline = _("exit the program");
-
- add_command(&quit_cmd);
-}
diff --git a/cmd.h b/cmd.h
index 89e7c6e..5b6f61b 100644
--- a/cmd.h
+++ b/cmd.h
@@ -42,8 +42,6 @@ typedef struct cmdinfo {
extern cmdinfo_t *cmdtab;
extern int ncmds;
-void quit_init(void);
-
typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
void add_command(const cmdinfo_t *ci);
diff --git a/qemu-io.c b/qemu-io.c
index 14eef2c..8f6c57e 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -137,6 +137,21 @@ static int open_f(BlockDriverState *bs, int argc, char
**argv)
return openfile(argv[optind], flags, growable);
}
+static int quit_f(BlockDriverState *bs, int argc, char **argv)
+{
+ return 1;
+}
+
+static const cmdinfo_t quit_cmd = {
+ .name = "quit",
+ .altname = "q",
+ .cfunc = quit_f,
+ .argmin = -1,
+ .argmax = -1,
+ .flags = CMD_FLAG_GLOBAL,
+ .oneline = "exit the program",
+};
+
static void usage(const char *name)
{
printf(
@@ -247,7 +262,7 @@ int main(int argc, char **argv)
bdrv_init();
/* initialize commands */
- quit_init();
+ add_command(&quit_cmd);
add_command(&open_cmd);
add_command(&close_cmd);
--
1.8.1.4
- [Qemu-devel] [PULL 00/26] Block patches, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 01/26] blockdev: reset werror/rerror on drive_del, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 02/26] qemu-io: Remove unused args_command, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 03/26] cutils: Support 'P' and 'E' suffixes in strtosz(), Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 04/26] qemu-io: Make cvtnum() a wrapper around strtosz_suffix(), Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 05/26] qemu-io: Handle cvtnum() errors in 'alloc', Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 06/26] qemu-io: Don't use global bs in command implementations, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 08/26] qemu-io: Factor out qemuio_command, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 09/26] qemu-io: Move 'help' function, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 11/26] qemu-io: Move qemu_strsep() to cutils.c, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 10/26] qemu-io: Move 'quit' function,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 07/26] qemu-io: Split off commands to qemu-io-cmds.c, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 12/26] qemu-io: Move functions for registering and running commands, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 13/26] qemu-io: Move command_loop() and friends, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 14/26] qemu-io: Move remaining helpers from cmd.c, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 15/26] qemu-io: Interface cleanup, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 16/26] qemu-io: Use the qemu version for -V, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 17/26] Make qemu-io commands available in HMP, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 18/26] blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK events, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 19/26] ide-test: Add enum value for DEV, Stefan Hajnoczi, 2013/06/07
- [Qemu-devel] [PULL 21/26] ide-test: Add FLUSH CACHE test case, Stefan Hajnoczi, 2013/06/07