[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 1/5] block/ssh: Add ssh_has_filename_options_conf
From: |
Ashijeet Acharya |
Subject: |
[Qemu-devel] [PATCH v3 1/5] block/ssh: Add ssh_has_filename_options_conflict() |
Date: |
Mon, 17 Oct 2016 23:02:11 +0530 |
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>
---
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;
}
--
2.6.2
- [Qemu-devel] [PATCH v3 0/5] Allow blockdev-add for SSH, Ashijeet Acharya, 2016/10/17
- [Qemu-devel] [PATCH v3 2/5] util/qemu-sockets: Make inet_connect_saddr() public, Ashijeet Acharya, 2016/10/17
- [Qemu-devel] [PATCH v3 1/5] block/ssh: Add ssh_has_filename_options_conflict(),
Ashijeet Acharya <=
- [Qemu-devel] [PATCH v3 3/5] block/ssh: Add InetSocketAddress and accept it, Ashijeet Acharya, 2016/10/17
- [Qemu-devel] [PATCH v3 4/5] block/ssh: Use InetSocketAddress options, Ashijeet Acharya, 2016/10/17
- [Qemu-devel] [PATCH v3 5/5] qapi: allow blockdev-add for ssh, Ashijeet Acharya, 2016/10/17
- Re: [Qemu-devel] [PATCH v3 0/5] Allow blockdev-add for SSH, no-reply, 2016/10/17