From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,PDS_BAD_THREAD_QP_64,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2733DC48BE0 for ; Fri, 11 Jun 2021 19:50:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94C1061003 for ; Fri, 11 Jun 2021 19:50:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94C1061003 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrnAz-0005ji-Jf for qemu-devel@archiver.kernel.org; Fri, 11 Jun 2021 15:50:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrn9a-0004Bu-Ph; Fri, 11 Jun 2021 15:49:18 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:40082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrn9Y-0006Mw-94; Fri, 11 Jun 2021 15:49:18 -0400 Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15BJloi4010120; Fri, 11 Jun 2021 12:49:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=g4eKTtW5iguLl2B3om9w0pnPTD61jNe7GEhZdySgB+4=; b=Q/plTM1kWsuMRuI7mJr/+/jPJITeMBosqbHaOm3oSw6cpy9Tlb5rNN3lK++zQqqvm9oA JN5DZpGS0F83f77Q9F+7LEYVhkcpBQDbgIfpFyxCrxaEgYC6gY56tG8hgoUUZSMyCK+g xR2p8Je3fVv0As+qa7gyRT2LqGXuIYyJYVaMiMgDLvhhD9Pkz1MiUy8QOOKGhYIZyFls A0L/LZ8cM8EnafToLY3OAF6jkWSgk0p5cQSglTEXxOrrHf3enWFQR/PR6urau+GlCPuL ymP7IXn2mcPgS7MEj63iqcvCpvjGobJE+D9mqKlxgWaURdrL71XjF9w/3oGLj1xjZz/6 6A== Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2043.outbound.protection.outlook.com [104.47.57.43]) by mx0b-002c1b01.pphosted.com with ESMTP id 394b4mrcgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Jun 2021 12:49:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PleJL6YDnZu+oKk7PDEI/EL7Irua/pmQ6YKjez4q7WrSLttmXXKgh6NXFTb2C9jOoymraVMy+qO+EAfHXPHwPMjCGnYFusgcFiBamcANrhzkbGmIsGuEXavdCBnZDsCF728Yt2ydM1oEbXpc3WJnKs8ddmdHIRrsTA4FNqX+SS1y7mlYttWF/5SSJnFlNin1j3CjDjJuNf8Uv5po/cw54rdmtNOUDFhVcj9DmdIx+rpOLZDBIkTclcAVSY1RPzdp11ojwK28OP3/mfecwz7N0XKzKJKdWdYEgdeIDfB4xpmTu/WQxtjhS9SUPn+Q1JBYbGsjH2+ICDcvLoMDucNjHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g4eKTtW5iguLl2B3om9w0pnPTD61jNe7GEhZdySgB+4=; b=IGq7QnhDE5M2L+XdbkKywtGjLl/gEjU0T0GVETG3zM1aQ2yiqTg8/DXNFXXgeARitW1T8KZ+1DTE2VFkLIY5Fx3aODC7SSrDdfAQme6UBXIOtzLI/rwMRCL3js9OsXl9ljCv1HdChwFEVxwharGtGA+Z1pfsW44oGzyh6yIbalFXoxj1f0ctOuYflm+WduoxrmOAuXykSs4775HH2zwXmrENlnCMLsKA8vDOzSDCy37WM0ASYyeguTFn5lAYlYaiJy+Z6kJz5KETXaYChNTdZKlAS9Es2GgfHHRRm5ZBHfm2zFKYg5AqjW8d0asctal7gJVDE8jG6Xday1BxzSXkgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from SN6PR02MB4543.namprd02.prod.outlook.com (2603:10b6:805:b1::24) by SN6PR02MB5070.namprd02.prod.outlook.com (2603:10b6:805:73::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.24; Fri, 11 Jun 2021 19:49:11 +0000 Received: from SN6PR02MB4543.namprd02.prod.outlook.com ([fe80::182b:62b8:51c1:ba59]) by SN6PR02MB4543.namprd02.prod.outlook.com ([fe80::182b:62b8:51c1:ba59%5]) with mapi id 15.20.4219.024; Fri, 11 Jun 2021 19:49:11 +0000 From: Raphael Norwitz To: Kevin Wolf Subject: Re: [PATCH 3/7] vhost: Return 0/-errno in vhost_dev_init() Thread-Topic: [PATCH 3/7] vhost: Return 0/-errno in vhost_dev_init() Thread-Index: AQHXXUa9hEw3/6k9eUmBgp0LVn7ab6sPOyMA Date: Fri, 11 Jun 2021 19:49:11 +0000 Message-ID: <20210611194910.GB26687@raphael-debian-dev> References: <20210609154658.350308-1-kwolf@redhat.com> <20210609154658.350308-4-kwolf@redhat.com> In-Reply-To: <20210609154658.350308-4-kwolf@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mutt/1.10.1 (2018-07-13) authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nutanix.com; x-originating-ip: [24.193.215.228] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 46a1359d-c76b-44da-d70c-08d92d11fc10 x-ms-traffictypediagnostic: SN6PR02MB5070: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:4941; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nSL58s2yt0J+Z4i7RsHHHoPiukIPAIFybuQaMm9FKkoB8ieyreTbOKQiU2NDwVcTpuZZuzcAa2zDOvLrSDe5xJkAZZQsAxY4I26qY+W1zeSwPglckzY5HMKkCU1ZiPrADRuoHprN19xPoxbLBaLJXLgA4VIKio5q6sArS2CHlNAYpyyxkpzywFT8TdB6onh81sJ+INlK/kwGdXf5PBozBeFX7TeD9B1aJgXgEXxYEqWQq71JZMEN1MrrHMZd2CdbHy9J9rKdz38LkI774mssCDh+VrBjBeSi+Cig7wIP8T/CfZ0HaZz25z2wn9VwDOMTspZkc/T3iyik7fUeE+Iuy5JgWR/QGcL03hUHFNn0oaEvtOq23MNgnaJywMaTf2kd5hfZRVtJDkbXqSlV4oCj3xvrp/VhPcAs3Lb89VYYSTGJN3G0e3KuwYJYb721sfJQzsBPJvJsKZ/K2T8HoNpFlwGEGP3N4nI8gty4c/zvS5itI01ne9w7zv6nmk+hoT6Oir3pCOuHtXTKm2leE3wIpGFuANSiKGlE+kJ14sl0BpK38MuAro7naXR31dUhOD/cbRUeFeVxO69X/ZHFtsYm5bLCGpVwqTFgKiGXuxpGjaI= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR02MB4543.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(7916004)(346002)(39860400002)(366004)(396003)(136003)(376002)(26005)(66946007)(6512007)(33716001)(8936002)(66476007)(64756008)(66556008)(5660300002)(66446008)(9686003)(6506007)(86362001)(33656002)(1076003)(4326008)(6916009)(186003)(122000001)(6486002)(83380400001)(2906002)(44832011)(478600001)(91956017)(71200400001)(8676002)(76116006)(316002)(54906003)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rg+EMJKg3ruL4qtCDE7oqqC1v63cAt81nndRZoPf4YBAKdg9q9EiDAdxHLro?= =?us-ascii?Q?8osn0W4zNr7Sprip6ne3c4EhTPlFl7ddjgzJorLPJA/LhxOIVLhVlpdpdhJy?= =?us-ascii?Q?ro/3JOeX+Hqr5IFN5L+VsvE0qevlA1pDxDGH32fLYTLUXr9/HDuRaw+1KXly?= =?us-ascii?Q?rWt5HNdFjh9HCZgm3x44j/XGWLX7YxkGliFtrx2t1ZzxiU6j6RWXK2Si0Zku?= =?us-ascii?Q?ZzD1uAELris4KAQiOiywzGlyXMJt4lk6UUlWNLtuza3Y09x0p8/2NCK3gXw2?= =?us-ascii?Q?XhtIqyyRhI7z2krvfj+Ni3r0t7hZZEhjWkFOvPvzzT+A35S8c8cb2bW8CRlI?= =?us-ascii?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JzQZO4eVhAG5KX3Qx?= =?us-ascii?Q?A4I68vPe6rteDNNHa1W6xxro//I0dM0hei4qDdmDDE47CcflRbxLYqbeAUaX?= =?us-ascii?Q?EcLBQ2I6DNXTB2vv2Wyb0prAHDnprY7HStdnf+2O0yG5Eg=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <02136C0ACBBD3F4BB2DF1ADADE3092FB@namprd02.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR02MB4543.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46a1359d-c76b-44da-d70c-08d92d11fc10 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jun 2021 19:49:11.4702 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ppNIZGS9lsGfdKGg2TUMJ2BR5a5GkAVYzGltPodV0KIq23Yt1oEa9rmW5JnADk3kPBpPzM7n31wD35hqOoMpVApwxgrh3BgzTYQzssZjG/c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB5070 X-Proofpoint-GUID: 8WV57oM4USpsGqEo6q42l16gdlZFaZNZ X-Proofpoint-ORIG-GUID: 8WV57oM4USpsGqEo6q42l16gdlZFaZNZ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-11_06:2021-06-11, 2021-06-11 signatures=0 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=raphael.norwitz@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Raphael Norwitz , "qemu-devel@nongnu.org" , "qemu-block@nongnu.org" , "mst@redhat.com" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, Jun 09, 2021 at 05:46:54PM +0200, Kevin Wolf wrote: > Instead of just returning 0/-1 and letting the caller make up a > meaningless error message, switch to 0/-errno so that different kinds of > errors can be distinguished in the caller. >=20 > This involves changing a few more callbacks in VhostOps to return > 0/-errno: .vhost_set_owner(), .vhost_get_features() and > .vhost_virtqueue_set_busyloop_timeout(). The implementations of these > functions are trivial as they generally just send a message to the > backend. >=20 > Signed-off-by: Kevin Wolf Reviewed-by: Raphael Norwitz > --- > hw/virtio/vhost-backend.c | 4 +++- > hw/virtio/vhost-user.c | 10 +++++++--- > hw/virtio/vhost-vdpa.c | 4 +++- > hw/virtio/vhost.c | 8 ++++---- > 4 files changed, 17 insertions(+), 9 deletions(-) >=20 > diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c > index f4f71cf58a..594d770b75 100644 > --- a/hw/virtio/vhost-backend.c > +++ b/hw/virtio/vhost-backend.c > @@ -24,10 +24,12 @@ static int vhost_kernel_call(struct vhost_dev *dev, u= nsigned long int request, > void *arg) > { > int fd =3D (uintptr_t) dev->opaque; > + int ret; > =20 > assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_KERNEL= ); > =20 > - return ioctl(fd, request, arg); > + ret =3D ioctl(fd, request, arg); > + return ret < 0 ? -errno : ret; > } > =20 > static int vhost_kernel_init(struct vhost_dev *dev, void *opaque, Error = **errp) > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c > index 024cb201bb..889559d86a 100644 > --- a/hw/virtio/vhost-user.c > +++ b/hw/virtio/vhost-user.c > @@ -1353,7 +1353,11 @@ static int vhost_user_get_u64(struct vhost_dev *de= v, int request, uint64_t *u64) > =20 > static int vhost_user_get_features(struct vhost_dev *dev, uint64_t *feat= ures) > { > - return vhost_user_get_u64(dev, VHOST_USER_GET_FEATURES, features); > + if (vhost_user_get_u64(dev, VHOST_USER_GET_FEATURES, features) < 0) = { > + return -EPROTO; > + } > + > + return 0; > } > =20 > static int vhost_user_set_owner(struct vhost_dev *dev) > @@ -1364,7 +1368,7 @@ static int vhost_user_set_owner(struct vhost_dev *d= ev) > }; > =20 > if (vhost_user_write(dev, &msg, NULL, 0) < 0) { > - return -1; > + return -EPROTO; > } > =20 > return 0; > @@ -1872,7 +1876,7 @@ static int vhost_user_backend_init(struct vhost_dev= *dev, void *opaque, > =20 > err =3D vhost_user_get_features(dev, &features); > if (err < 0) { > - return -EPROTO; > + return err; > } > =20 > if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) { > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c > index c2aadb57cb..71897c1a01 100644 > --- a/hw/virtio/vhost-vdpa.c > +++ b/hw/virtio/vhost-vdpa.c > @@ -253,10 +253,12 @@ static int vhost_vdpa_call(struct vhost_dev *dev, u= nsigned long int request, > { > struct vhost_vdpa *v =3D dev->opaque; > int fd =3D v->device_fd; > + int ret; > =20 > assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); > =20 > - return ioctl(fd, request, arg); > + ret =3D ioctl(fd, request, arg); > + return ret < 0 ? -errno : ret; > } > =20 > static void vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index fd13135706..c7f9d8bb06 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -1309,13 +1309,13 @@ int vhost_dev_init(struct vhost_dev *hdev, void *= opaque, > =20 > r =3D hdev->vhost_ops->vhost_set_owner(hdev); > if (r < 0) { > - error_setg(errp, "vhost_set_owner failed"); > + error_setg_errno(errp, -r, "vhost_set_owner failed"); > goto fail; > } > =20 > r =3D hdev->vhost_ops->vhost_get_features(hdev, &features); > if (r < 0) { > - error_setg(errp, "vhost_get_features failed"); > + error_setg_errno(errp, -r, "vhost_get_features failed"); > goto fail; > } > =20 > @@ -1332,7 +1332,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *op= aque, > r =3D vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_in= dex + i, > busyloop_timeout); > if (r < 0) { > - error_setg(errp, "Failed to set busyloop timeout"); > + error_setg_errno(errp, -r, "Failed to set busyloop timeo= ut"); > goto fail_busyloop; > } > } > @@ -1391,7 +1391,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *op= aque, > if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hd= ev)) { > error_setg(errp, "vhost backend memory slots limit is less" > " than current number of present memory slots"); > - r =3D -1; > + r =3D -EINVAL; > goto fail_busyloop; > } > =20 > --=20 > 2.30.2 > =