|
|
9ae3a8 |
From 0ba83ccbe597ebcaca69a3363d8bc2a5dd74e0c7 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Date: Sun, 29 Dec 2013 22:06:53 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 2/8] qemu-io: Let "open" pass options to block driver
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1388354817-3013-2-git-send-email-mreitz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56443
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 1/5] qemu-io: Let "open" pass options to block driver
|
|
|
9ae3a8 |
Bugzilla: 1004347
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BZ: 1004347
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Add an option to the open command to specify runtime options for the
|
|
|
9ae3a8 |
block driver used.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit b543c5cdcb818ffed90cfc97aa8e297214650d84)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qemu-io.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts because 797ac58cb2093ab9192d8998a1fef85d87cc8661 has not been
|
|
|
9ae3a8 |
backported, which splits qemu-io-cmds.c from qemu-io.c.
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-io.c | 39 +++++++++++++++++++++++++++++++--------
|
|
|
9ae3a8 |
1 file changed, 31 insertions(+), 8 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-io.c | 39 +++++++++++++++++++++++++++++++--------
|
|
|
9ae3a8 |
1 files changed, 31 insertions(+), 8 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qemu-io.c b/qemu-io.c
|
|
|
9ae3a8 |
index 393c2c8..64b060c 100644
|
|
|
9ae3a8 |
--- a/qemu-io.c
|
|
|
9ae3a8 |
+++ b/qemu-io.c
|
|
|
9ae3a8 |
@@ -16,6 +16,8 @@
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#include "qemu-common.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 |
@@ -1771,7 +1773,7 @@ static const cmdinfo_t close_cmd = {
|
|
|
9ae3a8 |
.oneline = "close the current open file",
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int openfile(char *name, int flags, int growable)
|
|
|
9ae3a8 |
+static int openfile(char *name, int flags, int growable, QDict *opts)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
Error *local_err = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1781,7 +1783,7 @@ static int openfile(char *name, int flags, int growable)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (growable) {
|
|
|
9ae3a8 |
- if (bdrv_file_open(&bs, name, NULL, flags, &local_err)) {
|
|
|
9ae3a8 |
+ if (bdrv_file_open(&bs, name, opts, flags, &local_err)) {
|
|
|
9ae3a8 |
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
|
|
|
9ae3a8 |
error_get_pretty(local_err));
|
|
|
9ae3a8 |
error_free(local_err);
|
|
|
9ae3a8 |
@@ -1790,7 +1792,7 @@ static int openfile(char *name, int flags, int growable)
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
bs = bdrv_new("hda");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (bdrv_open(bs, name, NULL, flags, NULL, &local_err) < 0) {
|
|
|
9ae3a8 |
+ if (bdrv_open(bs, name, opts, flags, NULL, &local_err) < 0) {
|
|
|
9ae3a8 |
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
|
|
|
9ae3a8 |
error_get_pretty(local_err));
|
|
|
9ae3a8 |
error_free(local_err);
|
|
|
9ae3a8 |
@@ -1816,7 +1818,8 @@ static void open_help(void)
|
|
|
9ae3a8 |
" -r, -- open file read-only\n"
|
|
|
9ae3a8 |
" -s, -- use snapshot file\n"
|
|
|
9ae3a8 |
" -n, -- disable host cache\n"
|
|
|
9ae3a8 |
-" -g, -- allow file to grow (only applies to protocols)"
|
|
|
9ae3a8 |
+" -g, -- allow file to grow (only applies to protocols)\n"
|
|
|
9ae3a8 |
+" -o, -- options to be given to the block driver"
|
|
|
9ae3a8 |
"\n");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1829,19 +1832,30 @@ static const cmdinfo_t open_cmd = {
|
|
|
9ae3a8 |
.argmin = 1,
|
|
|
9ae3a8 |
.argmax = -1,
|
|
|
9ae3a8 |
.flags = CMD_NOFILE_OK,
|
|
|
9ae3a8 |
- .args = "[-Crsn] [path]",
|
|
|
9ae3a8 |
+ .args = "[-Crsn] [-o options] [path]",
|
|
|
9ae3a8 |
.oneline = "open the file specified by path",
|
|
|
9ae3a8 |
.help = open_help,
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static QemuOptsList empty_opts = {
|
|
|
9ae3a8 |
+ .name = "drive",
|
|
|
9ae3a8 |
+ .head = QTAILQ_HEAD_INITIALIZER(empty_opts.head),
|
|
|
9ae3a8 |
+ .desc = {
|
|
|
9ae3a8 |
+ /* no elements => accept any params */
|
|
|
9ae3a8 |
+ { /* end of list */ }
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
+};
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static int open_f(int argc, char **argv)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int flags = 0;
|
|
|
9ae3a8 |
int readonly = 0;
|
|
|
9ae3a8 |
int growable = 0;
|
|
|
9ae3a8 |
int c;
|
|
|
9ae3a8 |
+ QemuOpts *qopts;
|
|
|
9ae3a8 |
+ QDict *opts = NULL;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- while ((c = getopt(argc, argv, "snrg")) != EOF) {
|
|
|
9ae3a8 |
+ while ((c = getopt(argc, argv, "snrgo:")) != EOF) {
|
|
|
9ae3a8 |
switch (c) {
|
|
|
9ae3a8 |
case 's':
|
|
|
9ae3a8 |
flags |= BDRV_O_SNAPSHOT;
|
|
|
9ae3a8 |
@@ -1855,6 +1869,15 @@ static int open_f(int argc, char **argv)
|
|
|
9ae3a8 |
case 'g':
|
|
|
9ae3a8 |
growable = 1;
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
+ case 'o':
|
|
|
9ae3a8 |
+ qopts = qemu_opts_parse(&empty_opts, optarg, 0);
|
|
|
9ae3a8 |
+ if (qopts == NULL) {
|
|
|
9ae3a8 |
+ printf("could not parse option list -- %s\n", optarg);
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ opts = qemu_opts_to_qdict(qopts, opts);
|
|
|
9ae3a8 |
+ qemu_opts_del(qopts);
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
default:
|
|
|
9ae3a8 |
return command_usage(&open_cmd);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1868,7 +1891,7 @@ static int open_f(int argc, char **argv)
|
|
|
9ae3a8 |
return command_usage(&open_cmd);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- return openfile(argv[optind], flags, growable);
|
|
|
9ae3a8 |
+ return openfile(argv[optind], flags, growable, opts);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int init_args_command(int index)
|
|
|
9ae3a8 |
@@ -2039,7 +2062,7 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if ((argc - optind) == 1) {
|
|
|
9ae3a8 |
- openfile(argv[optind], flags, growable);
|
|
|
9ae3a8 |
+ openfile(argv[optind], flags, growable, NULL);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
command_loop();
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|