diff options
author | Kevin Wolf <kwolf@redhat.com> | 2014-09-18 11:48:34 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-09-25 15:24:14 +0200 |
commit | 5abbf0ee4d87c695deb1c3fca9bb994b93a3e3be (patch) | |
tree | f4c1067304268d1d1d7e823b97e8d8ec0bcb2462 /blockdev.c | |
parent | 247147fbc107f818630c4044931de39b89c99342 (diff) | |
download | qemu-5abbf0ee4d87c695deb1c3fca9bb994b93a3e3be.zip qemu-5abbf0ee4d87c695deb1c3fca9bb994b93a3e3be.tar.gz qemu-5abbf0ee4d87c695deb1c3fca9bb994b93a3e3be.tar.bz2 |
block: Catch simultaneous usage of options and their aliases
While thinking about precedence of conflicting block device options from
different sources, I noticed that you can specify both an option and its
legacy alias at the same time (e.g. readonly=on,read-only=off). Rather
than specifying the order of precedence, we should simply forbid such
combinations.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -538,12 +538,18 @@ err_no_opts: return NULL; } -static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to) +static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to, + Error **errp) { const char *value; value = qemu_opt_get(opts, from); if (value) { + if (qemu_opt_find(opts, to)) { + error_setg(errp, "'%s' and its alias '%s' can't be used at the " + "same time", to, from); + return; + } qemu_opt_set(opts, to, value); qemu_opt_unset(opts, from); } @@ -676,7 +682,13 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) }; for (i = 0; i < ARRAY_SIZE(opt_renames); i++) { - qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to); + qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, + &local_err); + if (local_err) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); + return NULL; + } } value = qemu_opt_get(all_opts, "cache"); |