Add support for Secure Shell (ssh) block device.
PATCH v5 1/3 osdep: Add a function to get the current username.
In reply to Richard W.M. JonesFrom: "Richard W.M. Jones" <[email protected]>
--- include/qemu/osdep.h | 2 ++ util/osdep.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-)
include/qemu/osdep.h +2 -0
@@ -182,4 +182,6 @@ const char *qemu_get_version(void);void fips_set_state (bool requested);bool fips_get_state (void ); +char *qemu_current_user (void ); +#endif
util/osdep.c +48 -1
70 lines not on this page · raw message
Signature · 1 line
1.8.1.4
v5 cover Add support for Secure Shell (ssh) block device.
This is version 5 of the patch to add a Secure Shell (ssh) block device to qemu. Most recently this was discussed here:
http://lists.nongnu.org/archive/html/qemu-devel/2013-03/threads.html#04845
Some changes since last time:
- I have addressed almost all of Stefan comments, but see my email to him above.
- ./check -ssh can be used to run io tests. Note the -qcow2 ones won't work.
I haven't done anything about authentication, so this patch still requires ssh-agent to be set up, and the right key to be present in known_hosts.
Rich.
PATCH v5 2/3 block: Add support for Secure Shell (ssh) block device.
From: "Richard W.M. Jones" <[email protected]>
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.
--- block/Makefile.objs | 1 + block/ssh.c | 863 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 48 +++ qemu-doc.texi | 40 +++ qemu-options.hx | 12 + 5 files changed, 964 insertions(+) create mode 100644 block/ssh.c
block/Makefile.objs +1 -0
@@ -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
block/ssh.c new file +863 -0
863 lines not on this page · raw message
configure +48 -0
84 lines not on this page · raw message
qemu-doc.texi +40 -0
@@ -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,45 @@ 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} +@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} +@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. + +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
qemu-options.hx +12 -0
@@ -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
Signature · 1 line
1.8.1.4
PATCH v5 3/3 iotests: Add 'check -ssh' option to test Secure Shell block device.
In reply to Richard W.M. JonesFrom: "Richard W.M. Jones" <[email protected]>
--- tests/qemu-iotests/common | 5 +++++ tests/qemu-iotests/common.rc | 3 +++ 2 files changed, 8 insertions(+)
tests/qemu-iotests/common +5 -0
@@ -137,6 +137,7 @@ check options -rbd test rbd -sheepdog test sheepdog -nbd test nbd + -ssh test ssh -xdiff graphical mode diff -nocache use O_DIRECT on backing file -misalign misalign memory allocations
@@ -206,6 +207,10 @@ testlist options IMGPROTO=nbd xpand=false ;; + -ssh) + IMGPROTO=ssh + xpand=false + ;; -nocache) QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache" xpand=false
tests/qemu-iotests/common.rc +3 -0
@@ -52,6 +52,9 @@ if [ "$IMGPROTO" = "file" ]; then elif [ "$IMGPROTO" = "nbd" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT TEST_IMG="nbd:127.0.0.1:10810" +elif [ "$IMGPROTO" = "ssh" ]; then + TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT + TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE" else TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT fi
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v5 3/3] iotests: Add 'check -ssh' option to test Secure Shell block device.
Quoted 36 lines · Richard W.M. Jones
From: "Richard W.M. Jones" <[email protected]>
Signed-off-by Richard W.M. Jones <[email protected]>--- tests/qemu-iotests/common | 5 +++++ tests/qemu-iotests/common.rc | 3 +++ 2 files changed, 8 insertions(+)tests/qemu-iotests/common +5
-0@@ -137,6 +137,7 @@ check options -rbd test rbd -sheepdog test sheepdog -nbd test nbd + -ssh test ssh -xdiff graphical mode diff -nocache use O_DIRECT on backing file -misalign misalign memory allocations@@ -206,6 +207,10 @@ testlist options IMGPROTO=nbd xpand=false ;; + -ssh) + IMGPROTO=ssh + xpand=false + ;; -nocache) QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache" xpand=falsetests/qemu-iotests/common.rc +0
-0
tests/qemu-iotests/common.rc if [ "$IMGPROTO" = "file" ]; then · line 60
Quoted 9 lines
tests/qemu-iotests/common.rc +3
-0@@ -52,6 +52,9 @@ if [ "$IMGPROTO" = "file" ]; then elif [ "$IMGPROTO" = "nbd" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT TEST_IMG="nbd:127.0.0.1:10810" +elif [ "$IMGPROTO" = "ssh" ]; then + TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT + TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE" else TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT fi
A note about this commit:
It assumes that you (a) have an ssh server running on localhost (rather than trying to start one up), and (b) that you have the key for localhost in your known_hosts file, and (c) that your ssh-agent allows you to log in to localhost without a password (ie. copy .ssh/id_rsa.pub to .ssh/authorized_keys).
Once, before you run the tests, you have to do 'ssh localhost'.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Re: [Qemu-devel] [PATCH v5 1/3] osdep: Add a function to get the current username.
In reply to Richard W.M. JonesQuoted 5 lines · Richard W.M. Jones
+/*
+ * Get the login name of the current user. The string must be freed
+ * up by the caller. If the current user could not be determined,
+ * returns NULL and sets errno.
+ */
Any reason we can't just use g_get_user_name() ?
-- PMM
Re: [Qemu-devel] [PATCH v5 1/3] osdep: Add a function to get the current username.
Quoted 8 lines · Peter Maydell
Quoted 5 lines · Richard W.M. Jones
+/*
+ * Get the login name of the current user. The string must be freed
+ * up by the caller. If the current user could not be determined,
+ * returns NULL and sets errno.
+ */Any reason we can't just use
g_get_user_name()?
None; I'll change the patch accordingly in the next version.
Rich.
Signature · 3 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)