blob: 3af513004a686bc67f18f9b0be3760c1246a7038 [file] [log] [blame]
aliguorie3aff4f2009-04-05 19:14:04 +00001/*
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 Swirl8167ee82009-07-16 20:47:01 +000015 * along with this program; if not, see <http://www.gnu.org/licenses/>.
aliguorie3aff4f2009-04-05 19:14:04 +000016 */
Kevin Wolf3d219942013-06-05 14:19:39 +020017
18#ifndef QEMU_IO_H
19#define QEMU_IO_H
aliguorie3aff4f2009-04-05 19:14:04 +000020
Kevin Wolf734c3b82013-06-05 14:19:30 +020021
Kevin Wolf3d219942013-06-05 14:19:39 +020022#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
Kevin Wolf734c3b82013-06-05 14:19:30 +020023
Max Reitzb32d7a32018-05-09 21:42:59 +020024/* 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 */
28typedef int (*cfunc_t)(BlockBackend *blk, int argc, char **argv);
29
aliguorie3aff4f2009-04-05 19:14:04 +000030typedef void (*helpfunc_t)(void);
31
32typedef struct cmdinfo {
Kevin Wolf3d219942013-06-05 14:19:39 +020033 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 Wolf887354b2017-02-10 16:24:56 +010043 uint64_t perm;
aliguorie3aff4f2009-04-05 19:14:04 +000044} cmdinfo_t;
45
Stefan Weilf9883882014-03-05 22:23:00 +010046extern bool qemuio_misalign;
47
Max Reitzb32d7a32018-05-09 21:42:59 +020048int qemuio_command(BlockBackend *blk, const char *cmd);
aliguorie3aff4f2009-04-05 19:14:04 +000049
Kevin Wolf3d219942013-06-05 14:19:39 +020050void qemuio_add_command(const cmdinfo_t *ci);
Max Reitzb444d0e2018-05-09 21:42:58 +020051void qemuio_command_usage(const cmdinfo_t *ci);
Stefan Hajnoczi46940202013-11-14 11:54:18 +010052void qemuio_complete_command(const char *input,
53 void (*fn)(const char *cmd, void *opaque),
54 void *opaque);
aliguorie3aff4f2009-04-05 19:14:04 +000055
Kevin Wolf3d219942013-06-05 14:19:39 +020056#endif /* QEMU_IO_H */