From: "Richard W.M. Jones" <rjones@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 07/18] block/ssh: Propagate errors through authenticate()
Date: Wed, 14 May 2014 15:57:34 +0100 [thread overview]
Message-ID: <20140514145734.GT1302@redhat.com> (raw)
In-Reply-To: <1399996972-23429-8-git-send-email-armbru@redhat.com>
On Tue, May 13, 2014 at 06:02:41PM +0200, Markus Armbruster wrote:
> Cc: "Richard W.M. Jones" <rjones@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
> block/ssh.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/block/ssh.c b/block/ssh.c
> index 1df1946..18186ba 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -434,7 +434,7 @@ static int check_host_key(BDRVSSHState *s, const char *host, int port,
> return -EINVAL;
> }
>
> -static int authenticate(BDRVSSHState *s, const char *user)
> +static int authenticate(BDRVSSHState *s, const char *user, Error **errp)
> {
> int r, ret;
> const char *userauthlist;
> @@ -445,7 +445,8 @@ static int authenticate(BDRVSSHState *s, const char *user)
> userauthlist = libssh2_userauth_list(s->session, user, strlen(user));
> if (strstr(userauthlist, "publickey") == NULL) {
> ret = -EPERM;
> - error_report("remote server does not support \"publickey\" authentication");
> + error_setg(errp,
> + "remote server does not support \"publickey\" authentication");
> goto out;
> }
>
> @@ -453,17 +454,18 @@ static int authenticate(BDRVSSHState *s, const char *user)
> agent = libssh2_agent_init(s->session);
> if (!agent) {
> ret = -EINVAL;
> - session_error_report(s, "failed to initialize ssh-agent support");
> + session_error_setg(errp, s, "failed to initialize ssh-agent support");
> goto out;
> }
> if (libssh2_agent_connect(agent)) {
> ret = -ECONNREFUSED;
> - session_error_report(s, "failed to connect to ssh-agent");
> + session_error_setg(errp, s, "failed to connect to ssh-agent");
> goto out;
> }
> if (libssh2_agent_list_identities(agent)) {
> ret = -EINVAL;
> - session_error_report(s, "failed requesting identities from ssh-agent");
> + session_error_setg(errp, s,
> + "failed requesting identities from ssh-agent");
> goto out;
> }
>
> @@ -474,7 +476,8 @@ static int authenticate(BDRVSSHState *s, const char *user)
> }
> if (r < 0) {
> ret = -EINVAL;
> - session_error_report(s, "failed to obtain identity from ssh-agent");
> + session_error_setg(errp, s,
> + "failed to obtain identity from ssh-agent");
> goto out;
> }
> r = libssh2_agent_userauth(agent, user, identity);
> @@ -488,8 +491,8 @@ static int authenticate(BDRVSSHState *s, const char *user)
> }
>
> ret = -EPERM;
> - error_report("failed to authenticate using publickey authentication "
> - "and the identities held by your ssh-agent");
> + error_setg(errp, "failed to authenticate using publickey authentication "
> + "and the identities held by your ssh-agent");
>
> out:
> if (agent != NULL) {
> @@ -577,8 +580,10 @@ static int connect_to_ssh(BDRVSSHState *s, QDict *options,
> }
>
> /* Authenticate. */
> - ret = authenticate(s, user);
> + ret = authenticate(s, user, &err);
> if (ret < 0) {
> + qerror_report_err(err);
> + error_free(err);
> goto err;
> }
>
> --
> 1.8.1.4
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
next prev parent reply other threads:[~2014-05-14 14:57 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 16:02 [Qemu-devel] [PATCH 00/18] [PATCH 00/18] block: Purge qerror_report() Markus Armbruster
2014-05-13 16:02 ` [Qemu-devel] [PATCH 01/18] blockdev: Don't use qerror_report_err() in drive_init() Markus Armbruster
2014-05-13 17:04 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 02/18] blockdev: Don't use qerror_report() in do_drive_del() Markus Armbruster
2014-05-13 19:38 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 03/18] qemu-nbd: Don't use qerror_report() Markus Armbruster
2014-05-13 19:39 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 04/18] block/rbd: Propagate errors to open and create methods Markus Armbruster
2014-05-13 19:51 ` Eric Blake
2014-05-14 5:41 ` Markus Armbruster
2014-05-13 16:02 ` [Qemu-devel] [PATCH 05/18] block/ssh: Drop superfluous libssh2_session_last_errno() calls Markus Armbruster
2014-05-14 9:11 ` Richard W.M. Jones
2014-05-14 11:06 ` Markus Armbruster
2014-05-14 12:01 ` Richard W.M. Jones
2014-05-14 14:48 ` Markus Armbruster
2014-05-14 14:57 ` Richard W.M. Jones
2014-05-13 16:02 ` [Qemu-devel] [PATCH 06/18] block/ssh: Propagate errors through check_host_key() Markus Armbruster
2014-05-14 14:57 ` Richard W.M. Jones
2014-05-13 16:02 ` [Qemu-devel] [PATCH 07/18] block/ssh: Propagate errors through authenticate() Markus Armbruster
2014-05-14 14:57 ` Richard W.M. Jones [this message]
2014-05-13 16:02 ` [Qemu-devel] [PATCH 08/18] block/ssh: Propagate errors through connect_to_ssh() Markus Armbruster
2014-05-14 14:57 ` Richard W.M. Jones
2014-05-13 16:02 ` [Qemu-devel] [PATCH 09/18] block/ssh: Propagate errors to open and create methods Markus Armbruster
2014-05-14 9:13 ` Richard W.M. Jones
2014-05-14 14:58 ` Richard W.M. Jones
2014-05-13 16:02 ` [Qemu-devel] [PATCH 10/18] block/vvfat: Propagate errors through enable_write_target() Markus Armbruster
2014-05-14 16:57 ` Eric Blake
2014-05-14 17:36 ` Markus Armbruster
2014-05-13 16:02 ` [Qemu-devel] [PATCH 11/18] block/vvfat: Propagate errors through init_directories() Markus Armbruster
2014-05-14 17:45 ` Eric Blake
2014-05-14 19:48 ` Markus Armbruster
2014-05-13 16:02 ` [Qemu-devel] [PATCH 12/18] block/sheepdog: Propagate errors through connect_to_sdog() Markus Armbruster
2014-05-14 18:19 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 13/18] block/sheepdog: Propagate errors through get_sheep_fd() Markus Armbruster
2014-05-15 18:54 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 14/18] block/sheepdog: Propagate errors through sd_prealloc() Markus Armbruster
2014-05-15 18:59 ` Eric Blake
2014-05-15 19:45 ` Markus Armbruster
2014-05-16 8:54 ` Markus Armbruster
2014-05-13 16:02 ` [Qemu-devel] [PATCH 15/18] block/sheepdog: Propagate errors through do_sd_create() Markus Armbruster
2014-05-15 19:02 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 16/18] block/sheepdog: Propagate errors through find_vdi_name() Markus Armbruster
2014-05-15 19:06 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 17/18] block/sheepdog: Propagate errors to open and create methods Markus Armbruster
2014-05-15 19:07 ` Eric Blake
2014-05-13 16:02 ` [Qemu-devel] [PATCH 18/18] block/sheepdog: Don't use qerror_report() Markus Armbruster
2014-05-15 19:08 ` Eric Blake
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=20140514145734.GT1302@redhat.com \
--to=rjones@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.