[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 01/29] block/ssh: Add ssh_has_filename_options_confli
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 01/29] block/ssh: Add ssh_has_filename_options_conflict() |
Date: |
Mon, 31 Oct 2016 18:25:30 +0100 |
From: Ashijeet Acharya <address@hidden>
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 <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/ssh.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/block/ssh.c b/block/ssh.c
index 5ce12b6..75cb7bc 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;
}
--
1.8.3.1
- [Qemu-block] [PULL 00/29] Block layer patches, Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 04/29] block/ssh: Use InetSocketAddress options, Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 01/29] block/ssh: Add ssh_has_filename_options_conflict(),
Kevin Wolf <=
- [Qemu-block] [PULL 05/29] qapi: allow blockdev-add for ssh, Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 06/29] block: Add bdrv_drain_all_{begin,end}(), Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 03/29] block/ssh: Add InetSocketAddress and accept it, Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 02/29] util/qemu-sockets: Make inet_connect_saddr() public, Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 08/29] block: Add block_job_add_bdrv(), Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 07/29] block: Pause all jobs during bdrv_reopen_multiple(), Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 09/29] block: Use block_job_add_bdrv() in mirror_start_job(), Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 12/29] block: Block all nodes involved in the block-commit operation, Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 10/29] block: Use block_job_add_bdrv() in backup_start(), Kevin Wolf, 2016/10/31
- [Qemu-block] [PULL 11/29] block: Check blockers in all nodes involved in a block-commit job, Kevin Wolf, 2016/10/31