Loading cmd.h→include/qemu-io.h +17 −19 Original line number Diff line number Diff line Loading @@ -14,15 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef __COMMAND_H__ #define __COMMAND_H__ #ifndef QEMU_IO_H #define QEMU_IO_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); Loading @@ -39,10 +38,9 @@ typedef struct cmdinfo { helpfunc_t help; } cmdinfo_t; void qemuio_add_command(const cmdinfo_t *ci); bool qemuio_command(BlockDriverState *bs, const char *cmd); 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__ */ #endif /* QEMU_IO_H */ qemu-io-cmds.c +7 −7 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; } Loading @@ -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) Loading Loading @@ -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; Loading @@ -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]); } Loading qemu-io.c +3 −4 Original line number Diff line number Diff line Loading @@ -14,10 +14,9 @@ #include <getopt.h> #include <libgen.h> #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" Loading Loading @@ -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); Loading @@ -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; Loading Loading
cmd.h→include/qemu-io.h +17 −19 Original line number Diff line number Diff line Loading @@ -14,15 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef __COMMAND_H__ #define __COMMAND_H__ #ifndef QEMU_IO_H #define QEMU_IO_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); Loading @@ -39,10 +38,9 @@ typedef struct cmdinfo { helpfunc_t help; } cmdinfo_t; void qemuio_add_command(const cmdinfo_t *ci); bool qemuio_command(BlockDriverState *bs, const char *cmd); 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__ */ #endif /* QEMU_IO_H */
qemu-io-cmds.c +7 −7 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; } Loading @@ -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) Loading Loading @@ -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; Loading @@ -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]); } Loading
qemu-io.c +3 −4 Original line number Diff line number Diff line Loading @@ -14,10 +14,9 @@ #include <getopt.h> #include <libgen.h> #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" Loading Loading @@ -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); Loading @@ -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; Loading