[{"id":1760434,"web_url":"http://patchwork.ozlabs.org/comment/1760434/","msgid":"<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>","list_archive_url":null,"date":"2017-08-30T19:40:16","subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 08/30/2017 11:56 AM, Jeff Cody wrote:\n> We don't need libssh2 failure to be fatal (we could just opt to not\n> register the driver on failure). But, it is probably a good idea to\n> avoid external library calls during the block_init(), and call the\n> libssh2 global init function on the first usage, returning any errors.\n> \n> Signed-off-by: Jeff Cody <jcody@redhat.com>\n> ---\n>  block/ssh.c | 40 +++++++++++++++++++++++++++++-----------\n>  1 file changed, 29 insertions(+), 11 deletions(-)\n> \n\n> +static int ssh_state_init(BDRVSSHState *s, Error **errp)\n>  {\n> +    int ret;\n> +\n> +    if (!ssh_libinit_called) {\n> +        ret = libssh2_init(0);\n> +        if (ret) {\n> +            error_setg(errp, \"libssh2 initialization failed with %d\", ret);\n> +            return ret;\n\nDo we know if this number is always positive or negative?\n\n> @@ -772,8 +788,13 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,\n>      BDRVSSHState *s = bs->opaque;\n>      int ret;\n>      int ssh_flags;\n> +    Error *local_err = NULL;\n>  \n> -    ssh_state_init(s);\n> +    ret = ssh_state_init(s, &local_err);\n> +    if (local_err) {\n> +        error_propagate(errp, local_err);\n> +        return ret;\n\nIs returning 'ret' from libssh2_init() wise?\n\nIf 'ret' is not important, you could simplify this:\n\nif (ssh_state_init(s, errp)) {\n    return -1;\n}","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjG8Q2cPKz9sP5\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 05:40:56 +1000 (AEST)","from localhost ([::1]:52393 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dn8r7-0004P3-H3\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 15:40:53 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:45782)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dn8qf-0004NZ-OK\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 15:40:26 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dn8qe-0007Tq-RS\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 15:40:25 -0400","from mx1.redhat.com ([209.132.183.28]:22192)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dn8qa-0007Ss-6m; Wed, 30 Aug 2017 15:40:20 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id B84D77F6A5;\n\tWed, 30 Aug 2017 19:40:18 +0000 (UTC)","from [10.10.122.186] (ovpn-122-186.rdu2.redhat.com [10.10.122.186])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 46CAF5C7BE;\n\tWed, 30 Aug 2017 19:40:17 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com B84D77F6A5","To":"Jeff Cody <jcody@redhat.com>, qemu-devel@nongnu.org","References":"<cover.1504112061.git.jcody@redhat.com>\n\t<af4268153bce149a9599e4079a0f8908e32fdef8.1504112061.git.jcody@redhat.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>","Date":"Wed, 30 Aug 2017 14:40:16 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<af4268153bce149a9599e4079a0f8908e32fdef8.1504112061.git.jcody@redhat.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"3NAxNq8j9SubV9Mguhf5N9HthrlRDhWXU\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tWed, 30 Aug 2017 19:40:19 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"mitake.hitoshi@lab.ntt.co.jp, namei.unix@gmail.com, qemu-block@nongnu.org,\n\trjones@redhat.com, kwolf@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1760453,"web_url":"http://patchwork.ozlabs.org/comment/1760453/","msgid":"<20170830201107.GL4770@localhost.localdomain>","list_archive_url":null,"date":"2017-08-30T20:11:07","subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","submitter":{"id":12159,"url":"http://patchwork.ozlabs.org/api/people/12159/","name":"Jeff Cody","email":"jcody@redhat.com"},"content":"On Wed, Aug 30, 2017 at 02:40:16PM -0500, Eric Blake wrote:\n> On 08/30/2017 11:56 AM, Jeff Cody wrote:\n> > We don't need libssh2 failure to be fatal (we could just opt to not\n> > register the driver on failure). But, it is probably a good idea to\n> > avoid external library calls during the block_init(), and call the\n> > libssh2 global init function on the first usage, returning any errors.\n> > \n> > Signed-off-by: Jeff Cody <jcody@redhat.com>\n> > ---\n> >  block/ssh.c | 40 +++++++++++++++++++++++++++++-----------\n> >  1 file changed, 29 insertions(+), 11 deletions(-)\n> > \n> \n> > +static int ssh_state_init(BDRVSSHState *s, Error **errp)\n> >  {\n> > +    int ret;\n> > +\n> > +    if (!ssh_libinit_called) {\n> > +        ret = libssh2_init(0);\n> > +        if (ret) {\n> > +            error_setg(errp, \"libssh2 initialization failed with %d\", ret);\n> > +            return ret;\n> \n> Do we know if this number is always positive or negative?\n> \n\nFrom the documentation [1], it returns 0 on success, or a negative value\nfor error.  (I guess presumably that means a positive value is by definition\nan error, as well).\n\n[1] https://www.libssh2.org/libssh2_init.html\n\n> > @@ -772,8 +788,13 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,\n> >      BDRVSSHState *s = bs->opaque;\n> >      int ret;\n> >      int ssh_flags;\n> > +    Error *local_err = NULL;\n> >  \n> > -    ssh_state_init(s);\n> > +    ret = ssh_state_init(s, &local_err);\n> > +    if (local_err) {\n> > +        error_propagate(errp, local_err);\n> > +        return ret;\n> \n> Is returning 'ret' from libssh2_init() wise?\n> \n> If 'ret' is not important, you could simplify this:\n> \n> if (ssh_state_init(s, errp)) {\n>     return -1;\n> }\n\nGood point, not sure if a non-zero ret from libssh2_init() provides meaning\nbeyond 'error' for us.  Maybe return -EIO instead of -1, though?","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jcody@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjGqr6Vz1z9sN7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 06:11:49 +1000 (AEST)","from localhost ([::1]:52488 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dn9Kz-0002Yh-2O\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 16:11:45 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:52737)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <jcody@redhat.com>) id 1dn9KX-0002U1-IZ\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 16:11:18 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <jcody@redhat.com>) id 1dn9KW-0002ab-9G\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 16:11:17 -0400","from mx1.redhat.com ([209.132.183.28]:54702)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <jcody@redhat.com>)\n\tid 1dn9KP-0002XH-T4; Wed, 30 Aug 2017 16:11:10 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 9386EC04B938;\n\tWed, 30 Aug 2017 20:11:08 +0000 (UTC)","from localhost (ovpn-116-70.phx2.redhat.com [10.3.116.70])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 2EA5E5D754;\n\tWed, 30 Aug 2017 20:11:08 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 9386EC04B938","Date":"Wed, 30 Aug 2017 16:11:07 -0400","From":"Jeff Cody <jcody@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20170830201107.GL4770@localhost.localdomain>","References":"<cover.1504112061.git.jcody@redhat.com>\n\t<af4268153bce149a9599e4079a0f8908e32fdef8.1504112061.git.jcody@redhat.com>\n\t<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>","User-Agent":"Mutt/1.5.24 (2015-08-30)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tWed, 30 Aug 2017 20:11:08 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, qemu-block@nongnu.org, mitake.hitoshi@lab.ntt.co.jp,\n\tqemu-devel@nongnu.org, rjones@redhat.com, namei.unix@gmail.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1760458,"web_url":"http://patchwork.ozlabs.org/comment/1760458/","msgid":"<aa69cb6b-3463-8811-966f-4218aba98e02@redhat.com>","list_archive_url":null,"date":"2017-08-30T20:12:44","subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 08/30/2017 03:11 PM, Jeff Cody wrote:\n> On Wed, Aug 30, 2017 at 02:40:16PM -0500, Eric Blake wrote:\n>> On 08/30/2017 11:56 AM, Jeff Cody wrote:\n>>> We don't need libssh2 failure to be fatal (we could just opt to not\n>>> register the driver on failure). But, it is probably a good idea to\n>>> avoid external library calls during the block_init(), and call the\n>>> libssh2 global init function on the first usage, returning any errors.\n>>>\n\n>>\n>> Is returning 'ret' from libssh2_init() wise?\n>>\n>> If 'ret' is not important, you could simplify this:\n>>\n>> if (ssh_state_init(s, errp)) {\n>>     return -1;\n>> }\n> \n> Good point, not sure if a non-zero ret from libssh2_init() provides meaning\n> beyond 'error' for us.  Maybe return -EIO instead of -1, though?\n\nYou used -EIO for 5/7, so that does sound a bit better.","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjGsT3T0cz9sN7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 06:13:17 +1000 (AEST)","from localhost ([::1]:52493 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dn9MR-0003A0-Kz\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 16:13:15 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:53113)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dn9M6-000382-7j\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 16:12:55 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dn9M5-0002xe-3n\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 16:12:54 -0400","from mx1.redhat.com ([209.132.183.28]:43036)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dn9Lz-0002v6-22; Wed, 30 Aug 2017 16:12:47 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id EF7B05F739;\n\tWed, 30 Aug 2017 20:12:45 +0000 (UTC)","from [10.10.122.186] (ovpn-122-186.rdu2.redhat.com [10.10.122.186])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id CBFA85C7DF;\n\tWed, 30 Aug 2017 20:12:44 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com EF7B05F739","To":"Jeff Cody <jcody@redhat.com>","References":"<cover.1504112061.git.jcody@redhat.com>\n\t<af4268153bce149a9599e4079a0f8908e32fdef8.1504112061.git.jcody@redhat.com>\n\t<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>\n\t<20170830201107.GL4770@localhost.localdomain>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<aa69cb6b-3463-8811-966f-4218aba98e02@redhat.com>","Date":"Wed, 30 Aug 2017 15:12:44 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170830201107.GL4770@localhost.localdomain>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"losKi7du4COasRFFtkUuEF06scKxaUd02\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tWed, 30 Aug 2017 20:12:46 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, qemu-block@nongnu.org, mitake.hitoshi@lab.ntt.co.jp,\n\tqemu-devel@nongnu.org, rjones@redhat.com, namei.unix@gmail.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1760720,"web_url":"http://patchwork.ozlabs.org/comment/1760720/","msgid":"<20170831074620.GR20914@redhat.com>","list_archive_url":null,"date":"2017-08-31T07:46:20","subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","submitter":{"id":3044,"url":"http://patchwork.ozlabs.org/api/people/3044/","name":"Richard W.M. Jones","email":"rjones@redhat.com"},"content":"On Wed, Aug 30, 2017 at 02:40:16PM -0500, Eric Blake wrote:\n> On 08/30/2017 11:56 AM, Jeff Cody wrote:\n> > We don't need libssh2 failure to be fatal (we could just opt to not\n> > register the driver on failure). But, it is probably a good idea to\n> > avoid external library calls during the block_init(), and call the\n> > libssh2 global init function on the first usage, returning any errors.\n> > \n> > Signed-off-by: Jeff Cody <jcody@redhat.com>\n> > ---\n> >  block/ssh.c | 40 +++++++++++++++++++++++++++++-----------\n> >  1 file changed, 29 insertions(+), 11 deletions(-)\n> > \n> \n> > +static int ssh_state_init(BDRVSSHState *s, Error **errp)\n> >  {\n> > +    int ret;\n> > +\n> > +    if (!ssh_libinit_called) {\n> > +        ret = libssh2_init(0);\n> > +        if (ret) {\n> > +            error_setg(errp, \"libssh2 initialization failed with %d\", ret);\n> > +            return ret;\n> \n> Do we know if this number is always positive or negative?\n\nFWIW documentation says:\n\n  \"Returns 0 if succeeded, or a negative value for error.\"\n\nI was holding off on reviewing this patch in general since there's a\nlibssh-based alternative driver under development, which should be\nbetter.\n\nRich.","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=rjones@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjZJ46YNDz9sQl\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 17:48:51 +1000 (AEST)","from localhost ([::1]:54360 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnKDY-0002L7-5U\n\tfor incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 03:48:48 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:35677)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <rjones@redhat.com>) id 1dnKBJ-0000Gr-Fg\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 03:46:30 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <rjones@redhat.com>) id 1dnKBI-0006oN-GV\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 03:46:29 -0400","from mx1.redhat.com ([209.132.183.28]:33680)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <rjones@redhat.com>)\n\tid 1dnKBD-0006kJ-VM; Thu, 31 Aug 2017 03:46:24 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 5C9C9267C8;\n\tThu, 31 Aug 2017 07:46:21 +0000 (UTC)","from localhost (ovpn-117-64.ams2.redhat.com [10.36.117.64])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 0079991D3B;\n\tThu, 31 Aug 2017 07:46:20 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 5C9C9267C8","Date":"Thu, 31 Aug 2017 08:46:20 +0100","From":"\"Richard W.M. Jones\" <rjones@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20170831074620.GR20914@redhat.com>","References":"<cover.1504112061.git.jcody@redhat.com>\n\t<af4268153bce149a9599e4079a0f8908e32fdef8.1504112061.git.jcody@redhat.com>\n\t<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<94eb9a23-1cb7-a139-039e-4d0f138a6244@redhat.com>","User-Agent":"Mutt/1.5.20 (2009-12-10)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tThu, 31 Aug 2017 07:46:21 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 1/7] block/ssh: don't call\n\tlibssh2_init() in block_init()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, qemu-block@nongnu.org, mitake.hitoshi@lab.ntt.co.jp,\n\tJeff Cody <jcody@redhat.com>, qemu-devel@nongnu.org,\n\tptoscano@redhat.com, namei.unix@gmail.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]