From nobody Sat Jul 12 04:50:31 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623254030; cv=none; d=zohomail.com; s=zohoarc; b=eKps2nDQ6fmt7KI+cxJRyuOeJHcKlzI7loJeojSCiA0bSAJKQU43ISAS2Od5p2UbqdjddP7PkTh3R0VnKWGNQkTmKKaP4XkwLvnwK7AnyKxoF/DLxUcLR9RJ6qryLCn2A889d09by4WbmW7aAoi/RBNlBWETGeEBwoUyk3f4EY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623254030; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q3FKQlHkGfNUWftxKfhvnk0jyAMxY9WtPIUYiEnccnU=; b=azTfV0zbXw18GTdeR9ZEgjvneGYCwGZRBs+VIgH4wts9JWm7C6O+Xc/1vD2TP/utC/dN1KhKQlnAcWq0cn1+CTz11IH6rnBxjMLZpxXFobr3BfVcvb152d3xwSF5Uq37TuaLH+cM94YnYo5SYXl0yrHHRoMC61jnybLxOp+lz7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1623254030586756.9213711878836; Wed, 9 Jun 2021 08:53:50 -0700 (PDT) Received: from localhost ([::1]:38086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lr0Wb-00087X-Fg for importer2@patchew.org; Wed, 09 Jun 2021 11:53:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lr0QS-0007X3-RW for qemu-devel@nongnu.org; Wed, 09 Jun 2021 11:47:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lr0QN-0003Yh-Mu for qemu-devel@nongnu.org; Wed, 09 Jun 2021 11:47:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-I-yG0DLDPTG-Yxp3AqPYGQ-1; Wed, 09 Jun 2021 11:47:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 908D01922963; Wed, 9 Jun 2021 15:47:20 +0000 (UTC) Received: from merkur.fritz.box (ovpn-114-230.ams2.redhat.com [10.36.114.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36BB760C04; Wed, 9 Jun 2021 15:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623253643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q3FKQlHkGfNUWftxKfhvnk0jyAMxY9WtPIUYiEnccnU=; b=ROC5FkTg46AtIwdcFF6no+zMlBmUJ4swVZXzProQN49tXteSVm4ymcEXLKNQ1Dnmcsp2BI yB0tBxpA/GglEy+4/gdvJUmUkZck0GyGj7NNZwHVjFUdnT+8YNffXSoX8a2QG8Jaq5M+o4 594QolWYf2XRnx74m5AZ5FfaehrWT8U= X-MC-Unique: I-yG0DLDPTG-Yxp3AqPYGQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 4/7] vhost-user-blk: Add Error parameter to vhost_user_blk_start() Date: Wed, 9 Jun 2021 17:46:55 +0200 Message-Id: <20210609154658.350308-5-kwolf@redhat.com> In-Reply-To: <20210609154658.350308-1-kwolf@redhat.com> References: <20210609154658.350308-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: kwolf@redhat.com, raphael.norwitz@nutanix.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Instead of letting the caller make up a meaningless error message, add an Error parameter to allow reporting the real error. Signed-off-by: Kevin Wolf Reviewed-by: Raphael Norwitz Reviewed-by: Stefano Garzarella --- hw/block/vhost-user-blk.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 0cb56baefb..e9382e152a 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -113,7 +113,7 @@ const VhostDevConfigOps blk_ops =3D { .vhost_dev_config_notifier =3D vhost_user_blk_handle_config_change, }; =20 -static int vhost_user_blk_start(VirtIODevice *vdev) +static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -121,19 +121,19 @@ static int vhost_user_blk_start(VirtIODevice *vdev) int i, ret; =20 if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); + error_setg(errp, "binding does not support guest notifiers"); return -ENOSYS; } =20 ret =3D vhost_dev_enable_notifiers(&s->dev, vdev); if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); + error_setg_errno(errp, -ret, "Error enabling host notifiers"); return ret; } =20 ret =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, true); if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); + error_setg_errno(errp, -ret, "Error binding guest notifier"); goto err_host_notifiers; } =20 @@ -141,27 +141,27 @@ static int vhost_user_blk_start(VirtIODevice *vdev) =20 ret =3D vhost_dev_prepare_inflight(&s->dev, vdev); if (ret < 0) { - error_report("Error set inflight format: %d", -ret); + error_setg_errno(errp, -ret, "Error setting inflight format"); goto err_guest_notifiers; } =20 if (!s->inflight->addr) { ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight= ); if (ret < 0) { - error_report("Error get inflight: %d", -ret); + error_setg_errno(errp, -ret, "Error getting inflight"); goto err_guest_notifiers; } } =20 ret =3D vhost_dev_set_inflight(&s->dev, s->inflight); if (ret < 0) { - error_report("Error set inflight: %d", -ret); + error_setg_errno(errp, -ret, "Error setting inflight"); goto err_guest_notifiers; } =20 ret =3D vhost_dev_start(&s->dev, vdev); if (ret < 0) { - error_report("Error starting vhost: %d", -ret); + error_setg_errno(errp, -ret, "Error starting vhost"); goto err_guest_notifiers; } s->started_vu =3D true; @@ -214,6 +214,7 @@ static void vhost_user_blk_set_status(VirtIODevice *vde= v, uint8_t status) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); bool should_start =3D virtio_device_started(vdev, status); + Error *local_err =3D NULL; int ret; =20 if (!vdev->vm_running) { @@ -229,10 +230,9 @@ static void vhost_user_blk_set_status(VirtIODevice *vd= ev, uint8_t status) } =20 if (should_start) { - ret =3D vhost_user_blk_start(vdev); + ret =3D vhost_user_blk_start(vdev, &local_err); if (ret < 0) { - error_report("vhost-user-blk: vhost start failed: %s", - strerror(-ret)); + error_reportf_err(local_err, "vhost-user-blk: vhost start fail= ed: "); qemu_chr_fe_disconnect(&s->chardev); } } else { @@ -270,6 +270,7 @@ static uint64_t vhost_user_blk_get_features(VirtIODevic= e *vdev, static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + Error *local_err =3D NULL; int i, ret; =20 if (!vdev->start_on_kick) { @@ -287,10 +288,9 @@ static void vhost_user_blk_handle_output(VirtIODevice = *vdev, VirtQueue *vq) /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start * vhost here instead of waiting for .set_status(). */ - ret =3D vhost_user_blk_start(vdev); + ret =3D vhost_user_blk_start(vdev, &local_err); if (ret < 0) { - error_report("vhost-user-blk: vhost start failed: %s", - strerror(-ret)); + error_reportf_err(local_err, "vhost-user-blk: vhost start failed: = "); qemu_chr_fe_disconnect(&s->chardev); return; } @@ -340,9 +340,8 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) =20 /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { - ret =3D vhost_user_blk_start(vdev); + ret =3D vhost_user_blk_start(vdev, errp); if (ret < 0) { - error_setg_errno(errp, -ret, "vhost start failed"); return ret; } } --=20 2.30.2