From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btYnk-0005hE-DJ for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:31:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btYni-0003uu-9n for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:31:23 -0400 Date: Mon, 10 Oct 2016 13:31:15 +0200 From: Kevin Wolf Message-ID: <20161010113115.GF6775@noname.redhat.com> References: <1475923446-29428-1-git-send-email-ashijeetacharya@gmail.com> <20161010091552.GC6775@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] qapi: allow blockdev-add for ssh List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ashijeet Acharya Cc: Eric Blake , armbru@redhat.com, QEMU Developers , "Richard W.M. Jones" , qemu-block@nongnu.org Am 10.10.2016 um 12:48 hat Ashijeet Acharya geschrieben: > On Mon, Oct 10, 2016 at 2:45 PM, Kevin Wolf wrote: > > Am 08.10.2016 um 12:44 hat Ashijeet Acharya geschrieben: > >> +{ 'struct': 'BlockdevoptionsSsh', > >> + 'data': { 'server': 'InetSocketAddress', > >> + 'path': 'str', > >> + 'user': 'str', > >> + 'host_key_check': 'str' } } Another thing I just noticed now: I think host_key_check should be marked optional (i.e. '*host_key_check') > > > > Did you test this? The ssh driver currently takes a separate 'host' > > string and 'port' integer, not a 'server' InetSocketAddress, so I think > > the C code needs an update, too. > > Ohh, maybe I misunderstood. I will update the c code too. > One question though, here when we talk about server, we refer to something like > : > right? You (correctly) defined 'server' as an InetSocketAddress. This in turn is defined in qapi-schema.json: { 'struct': 'InetSocketAddress', 'data': { 'host': 'str', 'port': 'str', '*to': 'uint16', '*ipv4': 'bool', '*ipv6': 'bool' } } Your .bdrv_open() callback in ssh gets these options as keys in QDict *options, using the dot syntax. options might look like this (using "key" = "value" for the example): "server.host" = "localhost" "server.port" = "1234" "server.ipv4" = "on" "server.ipv6" = "on" "path" = "/tmp/test.img" "user" = "test" You can manually parse the "server.*" fields with qdict_extract_subqdict() and QemuOpts and then construct an InetSocketAddress object in C similar to what NBD does currently. The other option, and maybe a bit nicer, would be to use a visitor to directly go from the (sub-)QDict to InetSocketAddress. > And similarly, maybe not related to this but when we parse uri > using 'uri_parse(filename)', does the 'uri->server' stores a similar > kind of format I mentioned above? It appears to return a struct URI, which contains 'char *server' and 'int port', but also many other fields. > > As for how to use a SocketAddress in order to establish a connection, > > you can look at block/nbd.c for reference. > > Great! I will use that as a reference. Another thing to have a look at might be the NBD series that Max posted to convert it to blockdev-add. I still haven't done that myself, but I suppose many of the things he does there apply to ssh as well. Kevin