|
|
9ae3a8 |
From 0dfb1b6f831f5b2a1fdf5e77330db3c95db2e464 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 23 Nov 2015 17:38:33 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 14/27] qemu-io: Interface cleanup
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1448300320-7772-15-git-send-email-jsnow@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 68444
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 14/21] qemu-io: Interface cleanup
|
|
|
9ae3a8 |
Bugzilla: 1272523
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 3d21994f9c511cb63220fef5abea164b83fbb997)
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qemu-io-cmds.c: include block/qapi.h context
|
|
|
9ae3a8 |
qemu-io.c include block/qapi.h context
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
cmd.h | 48 ------------------------------------------------
|
|
|
9ae3a8 |
include/qemu-io.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9ae3a8 |
qemu-io-cmds.c | 14 +++++++-------
|
|
|
9ae3a8 |
qemu-io.c | 7 +++----
|
|
|
9ae3a8 |
4 files changed, 56 insertions(+), 59 deletions(-)
|
|
|
9ae3a8 |
delete mode 100644 cmd.h
|
|
|
9ae3a8 |
create mode 100644 include/qemu-io.h
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/cmd.h b/cmd.h
|
|
|
9ae3a8 |
deleted file mode 100644
|
|
|
9ae3a8 |
index 9907795..0000000
|
|
|
9ae3a8 |
--- a/cmd.h
|
|
|
9ae3a8 |
+++ /dev/null
|
|
|
9ae3a8 |
@@ -1,48 +0,0 @@
|
|
|
9ae3a8 |
-/*
|
|
|
9ae3a8 |
- * Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
9ae3a8 |
- * All Rights Reserved.
|
|
|
9ae3a8 |
- *
|
|
|
9ae3a8 |
- * This program is free software; you can redistribute it and/or
|
|
|
9ae3a8 |
- * modify it under the terms of the GNU General Public License as
|
|
|
9ae3a8 |
- * published by the Free Software Foundation.
|
|
|
9ae3a8 |
- *
|
|
|
9ae3a8 |
- * This program is distributed in the hope that it would be useful,
|
|
|
9ae3a8 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9ae3a8 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
9ae3a8 |
- * GNU General Public License for more details.
|
|
|
9ae3a8 |
- *
|
|
|
9ae3a8 |
- * You should have received a copy of the GNU General Public License
|
|
|
9ae3a8 |
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
9ae3a8 |
- */
|
|
|
9ae3a8 |
-#ifndef __COMMAND_H__
|
|
|
9ae3a8 |
-#define __COMMAND_H__
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-#include "qemu-common.h"
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-extern BlockDriverState *qemuio_bs;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
|
|
|
9ae3a8 |
-typedef void (*helpfunc_t)(void);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-typedef struct cmdinfo {
|
|
|
9ae3a8 |
- const char *name;
|
|
|
9ae3a8 |
- const char *altname;
|
|
|
9ae3a8 |
- cfunc_t cfunc;
|
|
|
9ae3a8 |
- int argmin;
|
|
|
9ae3a8 |
- int argmax;
|
|
|
9ae3a8 |
- int canpush;
|
|
|
9ae3a8 |
- int flags;
|
|
|
9ae3a8 |
- const char *args;
|
|
|
9ae3a8 |
- const char *oneline;
|
|
|
9ae3a8 |
- helpfunc_t help;
|
|
|
9ae3a8 |
-} cmdinfo_t;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-void qemuio_add_command(const cmdinfo_t *ci);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-int qemuio_command_usage(const cmdinfo_t *ci);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-bool qemuio_command(const char *cmd);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-#endif /* __COMMAND_H__ */
|
|
|
9ae3a8 |
diff --git a/include/qemu-io.h b/include/qemu-io.h
|
|
|
9ae3a8 |
new file mode 100644
|
|
|
9ae3a8 |
index 0000000..a418b46
|
|
|
9ae3a8 |
--- /dev/null
|
|
|
9ae3a8 |
+++ b/include/qemu-io.h
|
|
|
9ae3a8 |
@@ -0,0 +1,46 @@
|
|
|
9ae3a8 |
+/*
|
|
|
9ae3a8 |
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
9ae3a8 |
+ * All Rights Reserved.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * This program is free software; you can redistribute it and/or
|
|
|
9ae3a8 |
+ * modify it under the terms of the GNU General Public License as
|
|
|
9ae3a8 |
+ * published by the Free Software Foundation.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * This program is distributed in the hope that it would be useful,
|
|
|
9ae3a8 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9ae3a8 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
9ae3a8 |
+ * GNU General Public License for more details.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * You should have received a copy of the GNU General Public License
|
|
|
9ae3a8 |
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+#ifndef QEMU_IO_H
|
|
|
9ae3a8 |
+#define QEMU_IO_H
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+#include "qemu-common.h"
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
|
|
|
9ae3a8 |
+typedef void (*helpfunc_t)(void);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+typedef struct cmdinfo {
|
|
|
9ae3a8 |
+ const char* name;
|
|
|
9ae3a8 |
+ const char* altname;
|
|
|
9ae3a8 |
+ cfunc_t cfunc;
|
|
|
9ae3a8 |
+ int argmin;
|
|
|
9ae3a8 |
+ int argmax;
|
|
|
9ae3a8 |
+ int canpush;
|
|
|
9ae3a8 |
+ int flags;
|
|
|
9ae3a8 |
+ const char *args;
|
|
|
9ae3a8 |
+ const char *oneline;
|
|
|
9ae3a8 |
+ helpfunc_t help;
|
|
|
9ae3a8 |
+} cmdinfo_t;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+bool qemuio_command(BlockDriverState *bs, const char *cmd);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+void qemuio_add_command(const cmdinfo_t *ci);
|
|
|
9ae3a8 |
+int qemuio_command_usage(const cmdinfo_t *ci);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+#endif /* QEMU_IO_H */
|
|
|
9ae3a8 |
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
|
|
|
9ae3a8 |
index 1db7fb9..1f21ce9 100644
|
|
|
9ae3a8 |
--- a/qemu-io-cmds.c
|
|
|
9ae3a8 |
+++ b/qemu-io-cmds.c
|
|
|
9ae3a8 |
@@ -8,10 +8,9 @@
|
|
|
9ae3a8 |
* See the COPYING file in the top-level directory.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#include "qemu-common.h"
|
|
|
9ae3a8 |
+#include "qemu-io.h"
|
|
|
9ae3a8 |
#include "block/block_int.h"
|
|
|
9ae3a8 |
#include "block/qapi.h"
|
|
|
9ae3a8 |
-#include "cmd.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define CMD_NOFILE_OK 0x01
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -51,11 +50,12 @@ static int init_check_command(BlockDriverState *bs, const cmdinfo_t *ct)
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int command(const cmdinfo_t *ct, int argc, char **argv)
|
|
|
9ae3a8 |
+static int command(BlockDriverState *bs, const cmdinfo_t *ct, int argc,
|
|
|
9ae3a8 |
+ char **argv)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
char *cmd = argv[0];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (!init_check_command(qemuio_bs, ct)) {
|
|
|
9ae3a8 |
+ if (!init_check_command(bs, ct)) {
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -76,7 +76,7 @@ static int command(const cmdinfo_t *ct, int argc, char **argv)
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
optind = 0;
|
|
|
9ae3a8 |
- return ct->cfunc(qemuio_bs, argc, argv);
|
|
|
9ae3a8 |
+ return ct->cfunc(bs, argc, argv);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static const cmdinfo_t *find_command(const char *cmd)
|
|
|
9ae3a8 |
@@ -2084,7 +2084,7 @@ static const cmdinfo_t help_cmd = {
|
|
|
9ae3a8 |
.oneline = "help for one or all commands",
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-bool qemuio_command(const char *cmd)
|
|
|
9ae3a8 |
+bool qemuio_command(BlockDriverState *bs, const char *cmd)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
char *input;
|
|
|
9ae3a8 |
const cmdinfo_t *ct;
|
|
|
9ae3a8 |
@@ -2097,7 +2097,7 @@ bool qemuio_command(const char *cmd)
|
|
|
9ae3a8 |
if (c) {
|
|
|
9ae3a8 |
ct = find_command(v[0]);
|
|
|
9ae3a8 |
if (ct) {
|
|
|
9ae3a8 |
- done = command(ct, c, v);
|
|
|
9ae3a8 |
+ done = command(bs, ct, c, v);
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
fprintf(stderr, "command \"%s\" not found\n", v[0]);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/qemu-io.c b/qemu-io.c
|
|
|
9ae3a8 |
index da9944e..e685808 100644
|
|
|
9ae3a8 |
--- a/qemu-io.c
|
|
|
9ae3a8 |
+++ b/qemu-io.c
|
|
|
9ae3a8 |
@@ -14,13 +14,12 @@
|
|
|
9ae3a8 |
#include <getopt.h>
|
|
|
9ae3a8 |
#include <libgen.h>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#include "qemu-common.h"
|
|
|
9ae3a8 |
+#include "qemu-io.h"
|
|
|
9ae3a8 |
#include "qemu/main-loop.h"
|
|
|
9ae3a8 |
#include "qemu/option.h"
|
|
|
9ae3a8 |
#include "qemu/config-file.h"
|
|
|
9ae3a8 |
#include "block/block_int.h"
|
|
|
9ae3a8 |
#include "block/qapi.h"
|
|
|
9ae3a8 |
-#include "cmd.h"
|
|
|
9ae3a8 |
#include "trace/control.h"
|
|
|
9ae3a8 |
#include "qemu/timer.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -306,7 +305,7 @@ static void command_loop(void)
|
|
|
9ae3a8 |
char *input;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
for (i = 0; !done && i < ncmdline; i++) {
|
|
|
9ae3a8 |
- done = qemuio_command(cmdline[i]);
|
|
|
9ae3a8 |
+ done = qemuio_command(qemuio_bs, cmdline[i]);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (cmdline) {
|
|
|
9ae3a8 |
g_free(cmdline);
|
|
|
9ae3a8 |
@@ -331,7 +330,7 @@ static void command_loop(void)
|
|
|
9ae3a8 |
if (input == NULL) {
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- done = qemuio_command(input);
|
|
|
9ae3a8 |
+ done = qemuio_command(qemuio_bs, input);
|
|
|
9ae3a8 |
g_free(input);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
prompted = 0;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|