mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
block: Add support for Secure Shell (ssh) block device.
qemu-system-x86_64 -drive file=ssh://hostname/some/image QEMU will ssh into 'hostname' and open '/some/image' which is made available as a standard block device. You can specify a username (ssh://user@host/...) and/or a port number (ssh://host:port/...). You can also use an alternate syntax using properties (file.user, file.host, file.port, file.path). Current limitations: - Authentication must be done without passwords or passphrases, using ssh-agent. Other authentication methods are not supported. - Uses a single connection, instead of concurrent AIO with multiple SSH connections. This is implemented using libssh2 on the client side. The server just requires a regular ssh daemon with sftp-server support. Most ssh daemons on Unix/Linux systems will work out of the box. Signed-off-by: Richard W.M. Jones <rjones@redhat.com> Cc: Stefan Hajnoczi <stefanha@gmail.com> Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
committed by
Stefan Hajnoczi
parent
aad64f3193
commit
0a12ec87a5
@@ -13,6 +13,7 @@ block-obj-$(CONFIG_LIBISCSI) += iscsi.o
|
||||
block-obj-$(CONFIG_CURL) += curl.o
|
||||
block-obj-$(CONFIG_RBD) += rbd.o
|
||||
block-obj-$(CONFIG_GLUSTERFS) += gluster.o
|
||||
block-obj-$(CONFIG_LIBSSH2) += ssh.o
|
||||
endif
|
||||
|
||||
common-obj-y += stream.o
|
||||
|
||||
+995
File diff suppressed because it is too large
Load Diff
@@ -239,6 +239,7 @@ virtio_blk_data_plane=""
|
||||
gtk=""
|
||||
gtkabi="2.0"
|
||||
tpm="no"
|
||||
libssh2=""
|
||||
|
||||
# parse CC options first
|
||||
for opt do
|
||||
@@ -922,6 +923,10 @@ for opt do
|
||||
;;
|
||||
--enable-tpm) tpm="yes"
|
||||
;;
|
||||
--disable-libssh2) libssh2="no"
|
||||
;;
|
||||
--enable-libssh2) libssh2="yes"
|
||||
;;
|
||||
*) echo "ERROR: unknown option $opt"; show_help="yes"
|
||||
;;
|
||||
esac
|
||||
@@ -1182,6 +1187,8 @@ echo " --disable-glusterfs disable GlusterFS backend"
|
||||
echo " --enable-gcov enable test coverage analysis with gcov"
|
||||
echo " --gcov=GCOV use specified gcov [$gcov_tool]"
|
||||
echo " --enable-tpm enable TPM support"
|
||||
echo " --disable-libssh2 disable ssh block device support"
|
||||
echo " --enable-libssh2 enable ssh block device support"
|
||||
echo ""
|
||||
echo "NOTE: The object files are built at the place where configure is launched"
|
||||
exit 1
|
||||
@@ -2313,6 +2320,42 @@ EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# libssh2 probe
|
||||
if test "$libssh2" != "no" ; then
|
||||
cat > $TMPC <<EOF
|
||||
#include <stdio.h>
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
int main(void) {
|
||||
LIBSSH2_SESSION *session;
|
||||
session = libssh2_session_init ();
|
||||
(void) libssh2_sftp_init (session);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
if $pkg_config libssh2 --modversion >/dev/null 2>&1; then
|
||||
libssh2_cflags=`$pkg_config libssh2 --cflags`
|
||||
libssh2_libs=`$pkg_config libssh2 --libs`
|
||||
else
|
||||
libssh2_cflags=
|
||||
libssh2_libs="-lssh2"
|
||||
fi
|
||||
|
||||
if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
|
||||
libssh2=yes
|
||||
libs_tools="$libssh2_libs $libs_tools"
|
||||
libs_softmmu="$libssh2_libs $libs_softmmu"
|
||||
QEMU_CFLAGS="$QEMU_CFLAGS $libssh2_cflags"
|
||||
else
|
||||
if test "$libssh2" = "yes" ; then
|
||||
feature_not_found "libssh2"
|
||||
fi
|
||||
libssh2=no
|
||||
fi
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# linux-aio probe
|
||||
|
||||
@@ -3435,6 +3478,7 @@ echo "virtio-blk-data-plane $virtio_blk_data_plane"
|
||||
echo "gcov $gcov_tool"
|
||||
echo "gcov enabled $gcov"
|
||||
echo "TPM support $tpm"
|
||||
echo "libssh2 support $libssh2"
|
||||
|
||||
if test "$sdl_too_old" = "yes"; then
|
||||
echo "-> Your SDL version is too old - please upgrade to have SDL support"
|
||||
@@ -3793,6 +3837,10 @@ if test "$glusterfs" = "yes" ; then
|
||||
echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$libssh2" = "yes" ; then
|
||||
echo "CONFIG_LIBSSH2=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$virtio_blk_data_plane" = "yes" ; then
|
||||
echo 'CONFIG_VIRTIO_BLK_DATA_PLANE=$(CONFIG_VIRTIO)' >> $config_host_mak
|
||||
fi
|
||||
|
||||
@@ -423,6 +423,7 @@ snapshots.
|
||||
* disk_images_sheepdog:: Sheepdog disk images
|
||||
* disk_images_iscsi:: iSCSI LUNs
|
||||
* disk_images_gluster:: GlusterFS disk images
|
||||
* disk_images_ssh:: Secure Shell (ssh) disk images
|
||||
@end menu
|
||||
|
||||
@node disk_images_quickstart
|
||||
@@ -1038,6 +1039,54 @@ qemu-system-x86_64 -drive file=gluster+unix:///testvol/dir/a.img?socket=/tmp/glu
|
||||
qemu-system-x86_64 -drive file=gluster+rdma://1.2.3.4:24007/testvol/a.img
|
||||
@end example
|
||||
|
||||
@node disk_images_ssh
|
||||
@subsection Secure Shell (ssh) disk images
|
||||
|
||||
You can access disk images located on a remote ssh server
|
||||
by using the ssh protocol:
|
||||
|
||||
@example
|
||||
qemu-system-x86_64 -drive file=ssh://[@var{user}@@]@var{server}[:@var{port}]/@var{path}[?host_key_check=@var{host_key_check}]
|
||||
@end example
|
||||
|
||||
Alternative syntax using properties:
|
||||
|
||||
@example
|
||||
qemu-system-x86_64 -drive file.driver=ssh[,file.user=@var{user}],file.host=@var{server}[,file.port=@var{port}],file.path=@var{path}[,file.host_key_check=@var{host_key_check}]
|
||||
@end example
|
||||
|
||||
@var{ssh} is the protocol.
|
||||
|
||||
@var{user} is the remote user. If not specified, then the local
|
||||
username is tried.
|
||||
|
||||
@var{server} specifies the remote ssh server. Any ssh server can be
|
||||
used, but it must implement the sftp-server protocol. Most Unix/Linux
|
||||
systems should work without requiring any extra configuration.
|
||||
|
||||
@var{port} is the port number on which sshd is listening. By default
|
||||
the standard ssh port (22) is used.
|
||||
|
||||
@var{path} is the path to the disk image.
|
||||
|
||||
The optional @var{host_key_check} parameter controls how the remote
|
||||
host's key is checked. The default is @code{yes} which means to use
|
||||
the local @file{.ssh/known_hosts} file. Setting this to @code{no}
|
||||
turns off known-hosts checking. Or you can check that the host key
|
||||
matches a specific fingerprint:
|
||||
@code{host_key_check=md5:78:45:8e:14:57:4f:d5:45:83:0a:0e:f3:49:82:c9:c8}
|
||||
(@code{sha1:} can also be used as a prefix, but note that OpenSSH
|
||||
tools only use MD5 to print fingerprints).
|
||||
|
||||
Currently authentication must be done using ssh-agent. Other
|
||||
authentication methods may be supported in future.
|
||||
|
||||
Note: The ssh driver does not obey disk flush requests (ie. to commit
|
||||
data to the backing disk when the guest requests it). This is because
|
||||
the underlying protocol (SFTP) does not support this. Thus there is a
|
||||
risk of guest disk corruption if the remote server or network goes
|
||||
down during writes.
|
||||
|
||||
@node pcsys_network
|
||||
@section Network emulation
|
||||
|
||||
|
||||
@@ -2107,6 +2107,18 @@ Example for Unix Domain Sockets
|
||||
qemu-system-i386 --drive file=nbd:unix:/tmp/nbd-socket
|
||||
@end example
|
||||
|
||||
@item SSH
|
||||
QEMU supports SSH (Secure Shell) access to remote disks.
|
||||
|
||||
Examples:
|
||||
@example
|
||||
qemu-system-i386 -drive file=ssh://user@@host/path/to/disk.img
|
||||
qemu-system-i386 -drive file.driver=ssh,file.user=user,file.host=host,file.port=22,file.path=/path/to/disk.img
|
||||
@end example
|
||||
|
||||
Currently authentication must be done using ssh-agent. Other
|
||||
authentication methods may be supported in future.
|
||||
|
||||
@item Sheepdog
|
||||
Sheepdog is a distributed storage system for QEMU.
|
||||
QEMU supports using either local sheepdog devices or remote networked
|
||||
|
||||
Reference in New Issue
Block a user