From: Ashijeet Acharya <ashijeetacharya@gmail.com>
To: kwolf@redhat.com
Cc: rjones@redhat.com, jcody@redhat.com, mreitz@redhat.com,
eblake@redhat.com, berrange@redhat.com, pbonzini@redhat.com,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Ashijeet Acharya <ashijeetacharya@gmail.com>
Subject: [Qemu-devel] [PATCH v3 1/5] block/ssh: Add ssh_has_filename_options_conflict()
Date: Mon, 17 Oct 2016 23:02:11 +0530 [thread overview]
Message-ID: <1476725535-3350-2-git-send-email-ashijeetacharya@gmail.com> (raw)
In-Reply-To: <1476725535-3350-1-git-send-email-ashijeetacharya@gmail.com>
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>
---
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
next prev parent reply other threads:[~2016-10-17 17:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 17:32 [Qemu-devel] [PATCH v3 0/5] Allow blockdev-add for SSH Ashijeet Acharya
2016-10-17 17:32 ` Ashijeet Acharya [this message]
2016-10-25 10:03 ` [Qemu-devel] [PATCH v3 1/5] block/ssh: Add ssh_has_filename_options_conflict() Kevin Wolf
2016-10-17 17:32 ` [Qemu-devel] [PATCH v3 2/5] util/qemu-sockets: Make inet_connect_saddr() public Ashijeet Acharya
2016-10-25 10:03 ` Kevin Wolf
2016-10-17 17:32 ` [Qemu-devel] [PATCH v3 3/5] block/ssh: Add InetSocketAddress and accept it Ashijeet Acharya
2016-10-25 9:55 ` Kevin Wolf
2016-10-17 17:32 ` [Qemu-devel] [PATCH v3 4/5] block/ssh: Use InetSocketAddress options Ashijeet Acharya
2016-10-25 10:04 ` Kevin Wolf
2016-10-17 17:32 ` [Qemu-devel] [PATCH v3 5/5] qapi: allow blockdev-add for ssh Ashijeet Acharya
2016-10-25 10:04 ` Kevin Wolf
2016-10-25 19:52 ` Eric Blake
2016-10-17 18:51 ` [Qemu-devel] [PATCH v3 0/5] Allow blockdev-add for SSH no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476725535-3350-2-git-send-email-ashijeetacharya@gmail.com \
--to=ashijeetacharya@gmail.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).