]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu-io: Move 'quit' function
authorKevin Wolf <kwolf@redhat.com>
Wed, 5 Jun 2013 12:19:34 +0000 (14:19 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 6 Jun 2013 09:27:04 +0000 (11:27 +0200)
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 <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
cmd.c
cmd.h
qemu-io.c

diff --git a/cmd.c b/cmd.c
index 2941ad35fb7a8e1bfe5c2b40d64efc55ee8d245f..8496e74d64eba7718d045e20b2b8c435eb4a90b3 100644 (file)
--- 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 89e7c6e8b20000e3995615e210985ed395a62f05..5b6f61b9ad2a4aab038a11db107ea4ef9d11ddf5 100644 (file)
--- 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);
index 14eef2cc65196a160ee3ba733718ed87c826a8a9..8f6c57e1b2e8b63bcedaaefede170d5b849acd0e 100644 (file)
--- 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);