From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:38429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyLcJ-00030c-9c for qemu-devel@nongnu.org; Mon, 25 Feb 2019 14:08:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyLcI-0001eu-KU for qemu-devel@nongnu.org; Mon, 25 Feb 2019 14:08:43 -0500 From: Max Reitz Date: Mon, 25 Feb 2019 20:08:28 +0100 Message-Id: <20190225190828.17726-3-mreitz@redhat.com> In-Reply-To: <20190225190828.17726-1-mreitz@redhat.com> References: <20190225190828.17726-1-mreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v3 2/2] block/ssh: Implement .bdrv_dirname() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Max Reitz , "Richard W . M . Jones" , Kevin Wolf 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 Tested-by: Richard W.M. Jones --- block/ssh.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/block/ssh.c b/block/ssh.c index 88401bbd31..b519c00869 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1295,6 +1295,26 @@ static void ssh_refresh_filename(BlockDriverState = *bs) } } =20 +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] =3D=3D '\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_strong_runtime_opts[] =3D { "host", "port", @@ -1322,6 +1342,7 @@ static BlockDriver bdrv_ssh =3D { .bdrv_co_truncate =3D ssh_co_truncate, .bdrv_co_flush_to_disk =3D ssh_co_flush, .bdrv_refresh_filename =3D ssh_refresh_filename, + .bdrv_dirname =3D ssh_bdrv_dirname, .create_opts =3D &ssh_create_opts, .strong_runtime_opts =3D ssh_strong_runtime_opts, }; --=20 2.20.1