diff options
author | Max Reitz <mreitz@redhat.com> | 2019-02-25 20:08:28 +0100 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2019-05-07 17:14:21 +0200 |
commit | 21205c7c3bd0910d7b71274ddbede9c7001e1cb4 (patch) | |
tree | 803f719a3a019876a4a45fc8929d4f24427ff26c /block/ssh.c | |
parent | b8c1f90118ee81090ff9093790f88bf335132814 (diff) | |
download | qemu-21205c7c3bd0910d7b71274ddbede9c7001e1cb4.zip qemu-21205c7c3bd0910d7b71274ddbede9c7001e1cb4.tar.gz qemu-21205c7c3bd0910d7b71274ddbede9c7001e1cb4.tar.bz2 |
block/ssh: Implement .bdrv_dirname()
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>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Message-id: 20190225190828.17726-3-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/ssh.c')
-rw-r--r-- | block/ssh.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/block/ssh.c b/block/ssh.c index 2eaeab8..12fd4f3 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1283,6 +1283,26 @@ 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_strong_runtime_opts[] = { "host", "port", @@ -1310,6 +1330,7 @@ static BlockDriver bdrv_ssh = { .bdrv_co_truncate = ssh_co_truncate, .bdrv_co_flush_to_disk = ssh_co_flush, .bdrv_refresh_filename = ssh_refresh_filename, + .bdrv_dirname = ssh_bdrv_dirname, .create_opts = &ssh_create_opts, .strong_runtime_opts = ssh_strong_runtime_opts, }; |