aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
Blue Swirl | 8167ee8 | 2009-07-16 20:47:01 +0000 | [diff] [blame] | 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 16 | */ |
Kevin Wolf | 3d21994 | 2013-06-05 14:19:39 +0200 | [diff] [blame] | 17 | |
| 18 | #ifndef QEMU_IO_H |
| 19 | #define QEMU_IO_H |
aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 20 | |
Kevin Wolf | 734c3b8 | 2013-06-05 14:19:30 +0200 | [diff] [blame] | 21 | |
Kevin Wolf | 3d21994 | 2013-06-05 14:19:39 +0200 | [diff] [blame] | 22 | #define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ |
Kevin Wolf | 734c3b8 | 2013-06-05 14:19:30 +0200 | [diff] [blame] | 23 | |
Max Reitz | b32d7a3 | 2018-05-09 21:42:59 +0200 | [diff] [blame] | 24 | /* Implement a qemu-io command. |
| 25 | * Operate on @blk using @argc/@argv as the command's arguments, and |
| 26 | * return 0 on success or negative errno on failure. |
| 27 | */ |
| 28 | typedef int (*cfunc_t)(BlockBackend *blk, int argc, char **argv); |
| 29 | |
aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 30 | typedef void (*helpfunc_t)(void); |
| 31 | |
| 32 | typedef struct cmdinfo { |
Kevin Wolf | 3d21994 | 2013-06-05 14:19:39 +0200 | [diff] [blame] | 33 | const char* name; |
| 34 | const char* altname; |
| 35 | cfunc_t cfunc; |
| 36 | int argmin; |
| 37 | int argmax; |
| 38 | int canpush; |
| 39 | int flags; |
| 40 | const char *args; |
| 41 | const char *oneline; |
| 42 | helpfunc_t help; |
Kevin Wolf | 887354b | 2017-02-10 16:24:56 +0100 | [diff] [blame] | 43 | uint64_t perm; |
aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 44 | } cmdinfo_t; |
| 45 | |
Stefan Weil | f988388 | 2014-03-05 22:23:00 +0100 | [diff] [blame] | 46 | extern bool qemuio_misalign; |
| 47 | |
Max Reitz | b32d7a3 | 2018-05-09 21:42:59 +0200 | [diff] [blame] | 48 | int qemuio_command(BlockBackend *blk, const char *cmd); |
aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 49 | |
Kevin Wolf | 3d21994 | 2013-06-05 14:19:39 +0200 | [diff] [blame] | 50 | void qemuio_add_command(const cmdinfo_t *ci); |
Max Reitz | b444d0e | 2018-05-09 21:42:58 +0200 | [diff] [blame] | 51 | void qemuio_command_usage(const cmdinfo_t *ci); |
Stefan Hajnoczi | 4694020 | 2013-11-14 11:54:18 +0100 | [diff] [blame] | 52 | void qemuio_complete_command(const char *input, |
| 53 | void (*fn)(const char *cmd, void *opaque), |
| 54 | void *opaque); |
aliguori | e3aff4f | 2009-04-05 19:14:04 +0000 | [diff] [blame] | 55 | |
Kevin Wolf | 3d21994 | 2013-06-05 14:19:39 +0200 | [diff] [blame] | 56 | #endif /* QEMU_IO_H */ |