Received: from eggs.gnu.org ([208.118.235.92]:57941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPY6G-0003Rr-JS for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:56:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPY6F-00067n-9L for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:56:36 -0400 Received: from mail-ea0-x22d.google.com ([2a00:1450:4013:c01::22d]:42091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPY6E-00067e-SU for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:56:35 -0400 Received: by mail-ea0-f173.google.com with SMTP id k11so2759308eaj.4 for ; Tue, 09 Apr 2013 05:56:34 -0700 (PDT) Date: Tue, 9 Apr 2013 14:56:31 +0200 From: Stefan Hajnoczi Message-ID: <20130409125631.GB12782@stefanha-thinkpad.redhat.com> References: <1364399849-5518-1-git-send-email-rjones@redhat.com> <1364399849-5518-2-git-send-email-rjones@redhat.com> <20130328104732.GA15114@stefanha-thinkpad.redhat.com> <20130403221430.GA1464@rhmail.home.annexia.org> <20130408113728.GD12852@stefanha-thinkpad.redhat.com> <20130408130506.GD1461@rhmail.home.annexia.org> <20130409073044.GG1461@rhmail.home.annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130409073044.GG1461@rhmail.home.annexia.org> Subject: Re: [Qemu-devel] [PATCH v4] block: Add support for Secure Shell (ssh) block device. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: qemu-devel On Tue, Apr 09, 2013 at 08:30:44AM +0100, Richard W.M. Jones wrote: > On Mon, Apr 08, 2013 at 10:21:44PM +0200, Stefan Hajnoczi wrote: > > On Mon, Apr 8, 2013 at 4:58 PM, Stefan Hajnoczi wrote: > > > On Mon, Apr 8, 2013 at 3:05 PM, Richard W.M. Jones wrote: > > > From what I can see libssh2 does not support loading .ssh/config. > > > > I was told that sshfs *does* handle .ssh/config. Turns out that sshfs > > spawns "ssh -s sftp" to get a SFTP subsystem channel. Then it > > directly implements the SFTP application protocol. > > > > This way they don't need to link against libssh2. They spawn ssh with > > a socketpair on stdin/stdout. They send/receive SFTP messages > > directly. > > Indeed, as I mentioned in an earlier message, sshfs implements the > complete SFTP stack itself and uses an external ssh process. > > It's up to 5 times as much code to do so: > > sshfs-fuse-2.4$ wc -l *.c > 589 cache.c > 3930 sshfs.c > 18 sshnodelay.c > 4537 total > > qemu/block$ wc -l ssh.c > 914 ssh.c > > I don't think having an entire SFTP stack inside qemu would help. How many SFTP messages do you need? Probably just a handfull (read, write, fsync, open, close). sshfs does way more than just that. It implements the entire FUSE VFS interface and a cache. So I think the lines of code comparison isn't apples to apples. The more practical reason for not spawning an external ssh process would be that QEMU is increasingly being jailed and handed only file descriptors. This works well for a TCP socket but is messier if the management stack has to launch SSH on behalf of QEMU first before handing the socketpair. Anyway, the reason I like the external ssh process approach is that we get all the standard hostkey and configuration file handling. Usability is important, if the integration has too many rough edges, people will not use the block driver. > > I just hit a libssh2 limitation. In my .ssh/config I have: > > NoHostAuthenticationForLocalhost yes > > > > This stops ssh from complaining when I hope to another host through an > > ssh tunnel (the host key wouldn't match localhost). > > I'm using the ssh configuration attached for tunnelling through > another host. It doesn't require toggling > 'NoHostAuthenticationForLocalhost', and so is safer because it still > does host key checking. Cool, thanks for sharing that. > I think a better and simpler way to solve this is simply to allow URLs > like: > > ssh://localhost/path?host_key_check=no > > which is the same as NoHostAuthenticationForLocalhost (ie don't do any > host checking on this connection). > > Even better would be to let people specify the key: > > ssh://localhost/path?host_key_check=aa:bb:cc:dd:ee:ff > > This means that management applications can parse .ssh/config if they > feel like doing that. These are steps in the right direction of making -drive ssh:// easy to use. Stefan