qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	"Richard W . M . Jones" <rjones@redhat.com>,
	Jeff Cody <jcody@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] block/ssh: Implement .bdrv_dirname()
Date: Mon,  5 Feb 2018 21:22:32 +0100	[thread overview]
Message-ID: <20180205202232.19254-3-mreitz@redhat.com> (raw)
In-Reply-To: <20180205202232.19254-1-mreitz@redhat.com>

ssh_bdrv_dirname() is basically the generic bdrv_dirname(), except it
takes care not to silently chop off any query string (i.e.,
host_key_check).

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/ssh.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/block/ssh.c b/block/ssh.c
index a5b7e831a4..7dbe55cec1 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -1194,6 +1194,24 @@ static void ssh_refresh_filename(BlockDriverState *bs)
     }
 }
 
+static char *ssh_bdrv_dirname(BlockDriverState *bs, Error **errp)
+{
+    if (qdict_haskey(bs->full_open_options, "host_key_check")) {
+        /* We cannot generate a simple prefix if we would have to
+         * append a query string */
+        error_setg(errp,
+                   "Cannot generate a base directory with host_key_check set");
+        return NULL;
+    }
+
+    if (bs->exact_filename[0] == '\0') {
+        error_setg(errp, "Cannot generate a base directory for this ssh node");
+        return NULL;
+    }
+
+    return path_combine(bs->exact_filename, "");
+}
+
 static const char *const ssh_sgfnt_runtime_opts[] = {
     "host",
     "port",
@@ -1219,6 +1237,7 @@ static BlockDriver bdrv_ssh = {
     .bdrv_getlength               = ssh_getlength,
     .bdrv_co_flush_to_disk        = ssh_co_flush,
     .bdrv_refresh_filename        = ssh_refresh_filename,
+    .bdrv_dirname                 = ssh_bdrv_dirname,
     .create_opts                  = &ssh_create_opts,
     .sgfnt_runtime_opts           = ssh_sgfnt_runtime_opts,
 };
-- 
2.14.3

  parent reply	other threads:[~2018-02-05 20:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 20:22 [Qemu-devel] [PATCH 0/2] block/ssh: Implement .bdrv_refresh_filename() Max Reitz
2018-02-05 20:22 ` [Qemu-devel] [PATCH 1/2] " Max Reitz
2018-02-05 20:22 ` Max Reitz [this message]
2018-02-05 20:45 ` [Qemu-devel] [PATCH 0/2] " Richard W.M. Jones
2018-02-05 20:46 ` Richard W.M. Jones
2018-02-05 20:56   ` Max Reitz
2018-03-06 21:51 ` [Qemu-devel] [Qemu-block] " John Snow
2018-03-07 10:04   ` Kevin Wolf
2018-03-07 17:50     ` John Snow
2018-03-08  2:12       ` Fam Zheng
2018-03-12 15:47         ` John Snow

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=20180205202232.19254-3-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@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).