From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] block: Add support for Secure Shell (ssh) block device.
Date: Tue, 26 Mar 2013 11:16:29 +0100 [thread overview]
Message-ID: <20130326101629.GE24025@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1364255381-16599-2-git-send-email-rjones@redhat.com>
On Mon, Mar 25, 2013 at 11:49:41PM +0000, Richard W.M. Jones wrote:
> From: "Richard W.M. Jones" <rjones@redhat.com>
>
> 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/...).
>
> Current limitations:
>
> - Authentication must be done without passwords or passphrases, using
> ssh-agent. Other authentication methods are not supported. (*)
>
> - Does not check host key. (*)
>
> - New remote files cannot be created. (*)
>
> - Uses a single connection, instead of concurrent AIO with multiple
> SSH connections.
>
> - Blocks during connection and authentication.
This isn't ideal but .bdrv_open() is a blocking function anyway. If you
open a raw image on an NFS export the open(2) call can block too.
Blocking in .bdrv_open() is fine during startup. It's bad when
hotplugging drives since the running VM will experience downtime.
> + /* Start SFTP. */
> + s->sftp = libssh2_sftp_init(s->session);
> + if (!s->sftp) {
> + session_error_report(s, "failed to initialize sftp handle");
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + s->sftp_handle = libssh2_sftp_open(s->sftp, path,
> + LIBSSH2_FXF_READ|LIBSSH2_FXF_WRITE,
Probably worth handling -drive ...,readonly=on. !(flags & BDRV_O_RDWR)
> +static coroutine_fn void set_fd_handler(BDRVSSHState *s)
> +{
> + int r;
> + void (*rd_handler)(void*);
> + void (*wr_handler)(void*);
There's a typedef for this: IOHandler.
> + Coroutine *co = qemu_coroutine_self();
> +
> + rd_handler = wr_handler = NULL;
> +
> + r = libssh2_session_block_directions(s->session);
> +
> + if (r & LIBSSH2_SESSION_BLOCK_INBOUND) {
> + rd_handler = restart_coroutine;
> + }
> + if (r & LIBSSH2_SESSION_BLOCK_OUTBOUND) {
> + wr_handler = restart_coroutine;
> + }
> +
> + DPRINTF("s->sock=%d rd_handler=%p wr_handler=%p", s->sock,
> + rd_handler, wr_handler);
> +
> + qemu_aio_set_fd_handler(s->sock, rd_handler, wr_handler, return_true, co);
> +}
> +
> +/* A non-blocking call returned EAGAIN, so yield, ensuring the
> + * handlers are set up so that we'll be rescheduled when there is an
> + * interesting event on the socket.
> + */
> +static coroutine_fn void co_yield(BDRVSSHState *s)
> +{
> + set_fd_handler(s);
> + qemu_coroutine_yield();
Should we clear the fd handler here? That way the caller doesn't have
to worry about fd handler state.
next prev parent reply other threads:[~2013-03-26 10:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 23:49 [Qemu-devel] [PATCH v2] block: Add support for Secure Shell (ssh) block device Richard W.M. Jones
2013-03-25 23:49 ` Richard W.M. Jones
2013-03-26 10:16 ` Stefan Hajnoczi [this message]
2013-03-26 10:38 ` Richard W.M. Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130326101629.GE24025@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).