From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkacp-0006NZ-6Z for qemu-devel@nongnu.org; Wed, 14 May 2014 10:57:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wkacj-0007UM-D5 for qemu-devel@nongnu.org; Wed, 14 May 2014 10:57:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkacj-0007UH-5o for qemu-devel@nongnu.org; Wed, 14 May 2014 10:57:37 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4EEvZdZ000792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 May 2014 10:57:36 -0400 Date: Wed, 14 May 2014 15:57:34 +0100 From: "Richard W.M. Jones" Message-ID: <20140514145734.GT1302@redhat.com> References: <1399996972-23429-1-git-send-email-armbru@redhat.com> <1399996972-23429-8-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1399996972-23429-8-git-send-email-armbru@redhat.com> Subject: Re: [Qemu-devel] [PATCH 07/18] block/ssh: Propagate errors through authenticate() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Tue, May 13, 2014 at 06:02:41PM +0200, Markus Armbruster wrote: > Cc: "Richard W.M. Jones" > Signed-off-by: Markus Armbruster Reviewed-by: Richard W.M. Jones > 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/