diff options
author | Anthony Liguori | 2013-10-11 18:29:58 +0200 |
---|---|---|
committer | Anthony Liguori | 2013-10-11 18:29:58 +0200 |
commit | 33c6cae44eccea5e627c2dc5cbf31456db90fc38 (patch) | |
tree | 26f994c9f78144b2a6f12da686a2235d0df1dd21 /qemu-io.c | |
parent | Merge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging (diff) | |
parent | qemu-iotests: Add test for inactive L2 overlap (diff) | |
download | qemu-33c6cae44eccea5e627c2dc5cbf31456db90fc38.tar.gz qemu-33c6cae44eccea5e627c2dc5cbf31456db90fc38.tar.xz qemu-33c6cae44eccea5e627c2dc5cbf31456db90fc38.zip |
Merge remote-tracking branch 'kwolf/for-anthony' into staging
# By Max Reitz (30) and others
# Via Kevin Wolf
* kwolf/for-anthony: (61 commits)
qemu-iotests: Add test for inactive L2 overlap
qemu-io: Let "open" pass options to block driver
vmdk: Fix vmdk_parse_extents
blockdev: blockdev_init() error conversion
blockdev: Don't disable COR automatically with blockdev-add
blockdev: Remove 'media' parameter from blockdev_init()
qemu-iotests: Check autodel behaviour for device_del
blockdev: Remove IF_* check for read-only blockdev_init
blockdev: Move virtio-blk device creation to drive_init
blockdev: Move bus/unit/index processing to drive_init
blockdev: Move parsing of 'boot' option to drive_init
blockdev: Moving parsing of geometry options to drive_init
blockdev: Move parsing of 'if' option to drive_init
blockdev: Move parsing of 'media' option to drive_init
blockdev: Pass QDict to blockdev_init()
blockdev: Separate ID generation from DriveInfo creation
blockdev: 'blockdev-add' QMP command
blockdev: Introduce DriveInfo.enable_auto_del
qapi-types/visit.py: Inheritance for structs
qapi-types/visit.py: Pass whole expr dict for structs
...
Message-id: 1381503951-27985-1-git-send-email-kwolf@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Diffstat (limited to 'qemu-io.c')
-rw-r--r-- | qemu-io.c | 39 |
1 files changed, 31 insertions, 8 deletions
@@ -16,6 +16,8 @@ #include "qemu-io.h" #include "qemu/main-loop.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "block/block_int.h" #include "trace/control.h" @@ -44,7 +46,7 @@ static const cmdinfo_t close_cmd = { .oneline = "close the current open file", }; -static int openfile(char *name, int flags, int growable) +static int openfile(char *name, int flags, int growable, QDict *opts) { Error *local_err = NULL; @@ -54,7 +56,7 @@ static int openfile(char *name, int flags, int growable) } if (growable) { - if (bdrv_file_open(&qemuio_bs, name, NULL, flags, &local_err)) { + if (bdrv_file_open(&qemuio_bs, name, opts, flags, &local_err)) { fprintf(stderr, "%s: can't open device %s: %s\n", progname, name, error_get_pretty(local_err)); error_free(local_err); @@ -63,7 +65,7 @@ static int openfile(char *name, int flags, int growable) } else { qemuio_bs = bdrv_new("hda"); - if (bdrv_open(qemuio_bs, name, NULL, flags, NULL, &local_err) < 0) { + if (bdrv_open(qemuio_bs, name, opts, flags, NULL, &local_err) < 0) { fprintf(stderr, "%s: can't open device %s: %s\n", progname, name, error_get_pretty(local_err)); error_free(local_err); @@ -89,7 +91,8 @@ static void open_help(void) " -r, -- open file read-only\n" " -s, -- use snapshot file\n" " -n, -- disable host cache\n" -" -g, -- allow file to grow (only applies to protocols)" +" -g, -- allow file to grow (only applies to protocols)\n" +" -o, -- options to be given to the block driver" "\n"); } @@ -102,19 +105,30 @@ static const cmdinfo_t open_cmd = { .argmin = 1, .argmax = -1, .flags = CMD_NOFILE_OK, - .args = "[-Crsn] [path]", + .args = "[-Crsn] [-o options] [path]", .oneline = "open the file specified by path", .help = open_help, }; +static QemuOptsList empty_opts = { + .name = "drive", + .head = QTAILQ_HEAD_INITIALIZER(empty_opts.head), + .desc = { + /* no elements => accept any params */ + { /* end of list */ } + }, +}; + static int open_f(BlockDriverState *bs, int argc, char **argv) { int flags = 0; int readonly = 0; int growable = 0; int c; + QemuOpts *qopts; + QDict *opts = NULL; - while ((c = getopt(argc, argv, "snrg")) != EOF) { + while ((c = getopt(argc, argv, "snrgo:")) != EOF) { switch (c) { case 's': flags |= BDRV_O_SNAPSHOT; @@ -128,6 +142,15 @@ static int open_f(BlockDriverState *bs, int argc, char **argv) case 'g': growable = 1; break; + case 'o': + qopts = qemu_opts_parse(&empty_opts, optarg, 0); + if (qopts == NULL) { + printf("could not parse option list -- %s\n", optarg); + return 0; + } + opts = qemu_opts_to_qdict(qopts, opts); + qemu_opts_del(qopts); + break; default: return qemuio_command_usage(&open_cmd); } @@ -141,7 +164,7 @@ static int open_f(BlockDriverState *bs, int argc, char **argv) return qemuio_command_usage(&open_cmd); } - return openfile(argv[optind], flags, growable); + return openfile(argv[optind], flags, growable, opts); } static int quit_f(BlockDriverState *bs, int argc, char **argv) @@ -418,7 +441,7 @@ int main(int argc, char **argv) } if ((argc - optind) == 1) { - openfile(argv[optind], flags, growable); + openfile(argv[optind], flags, growable, NULL); } command_loop(); |