diff options
author | Ashijeet Acharya <ashijeetacharya@gmail.com> | 2016-10-25 18:33:57 +0530 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-10-31 16:49:13 +0100 |
commit | 89dbe18089127cf90993359096b659ea6f819848 (patch) | |
tree | b865a9afe2feca74625d5521096912b66e54239e /block/ssh.c | |
parent | 0bb1137930f51a89fb1bfeb0c46aa68af0395167 (diff) |
block/ssh: Add ssh_has_filename_options_conflict()
We have 5 options plus ("server") option which is added in the next
patch that conflict with specifying a SSH filename. We need to iterate
over all the options to check whether its key has an "server." prefix.
This iteration will help us adding the new option "server" easily.
Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/ssh.c')
-rw-r--r-- | block/ssh.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/block/ssh.c b/block/ssh.c index 5ce12b633a..75cb7bc02d 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -254,15 +254,30 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) return -EINVAL; } +static bool ssh_has_filename_options_conflict(QDict *options, Error **errp) +{ + const QDictEntry *qe; + + for (qe = qdict_first(options); qe; qe = qdict_next(options, qe)) { + if (!strcmp(qe->key, "host") || + !strcmp(qe->key, "port") || + !strcmp(qe->key, "path") || + !strcmp(qe->key, "user") || + !strcmp(qe->key, "host_key_check")) + { + error_setg(errp, "Option '%s' cannot be used with a file name", + qe->key); + return true; + } + } + + return false; +} + static void ssh_parse_filename(const char *filename, QDict *options, Error **errp) { - if (qdict_haskey(options, "user") || - qdict_haskey(options, "host") || - qdict_haskey(options, "port") || - qdict_haskey(options, "path") || - qdict_haskey(options, "host_key_check")) { - error_setg(errp, "user, host, port, path, host_key_check cannot be used at the same time as a file option"); + if (ssh_has_filename_options_conflict(options, errp)) { return; } |