mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qemu-io: Factor out qemuio_command
It's duplicated code. Move it to qemu-io-cmds.c because it's not dependent on any static data of the qemu-io tool. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
797ac58cb2
commit
dd5832967a
3 changed files with 31 additions and 39 deletions
|
@ -1807,6 +1807,30 @@ static int init_check_command(BlockDriverState *bs, const cmdinfo_t *ct)
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool qemuio_command(const char *cmd)
|
||||
{
|
||||
char *input;
|
||||
const cmdinfo_t *ct;
|
||||
char **v;
|
||||
int c;
|
||||
bool done = false;
|
||||
|
||||
input = g_strdup(cmd);
|
||||
v = breakline(input, &c);
|
||||
if (c) {
|
||||
ct = find_command(v[0]);
|
||||
if (ct) {
|
||||
done = command(ct, c, v);
|
||||
} else {
|
||||
fprintf(stderr, "command \"%s\" not found\n", v[0]);
|
||||
}
|
||||
}
|
||||
g_free(input);
|
||||
g_free(v);
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
static void __attribute((constructor)) init_qemuio_commands(void)
|
||||
{
|
||||
/* initialize commands */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue