From nobody Wed May 15 07:47:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1693371669; cv=none; d=zohomail.com; s=zohoarc; b=gb216tRhJoCUhehr7XpV72P6sWF4ea9Yf/d8F7rM0f7gjVuOfkaoao5IVwtNflB2cW5AYmJvfQd02Ql9wrwO9+Qc3NWvieor9DkQ6WvgwpTQQdwEa4wINi16miOtWGlx48ioPueq3tHcrQkDxDvi2G6cWjjmd2fPxkhPQP2zwQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693371669; h=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=7MzIajxlynAc7cZYmUnN0op416U5kko2ZZOVqw7m+l4=; b=jQCImsA52xYho+YB8luaWwqhlDsLPu/PIMp+2DxAJh2LDoYU9WHh27GoVC3wjBQwtGftp+BXvEKHE9eCcBGXkFxkrID1FTOKUmquyFvyNy+csX7261K4jl9mp4XfUSV+5/qabs1FBnSK3oVnHkjZEJKNc5fwgq1Zaxgz2peWInw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693371669136845.7115079166333; Tue, 29 Aug 2023 22:01:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbDJA-0007w3-Cw; Wed, 30 Aug 2023 01:00:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbDIw-0007uR-8x for qemu-devel@nongnu.org; Wed, 30 Aug 2023 00:59:49 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbDIm-00041X-DA for qemu-devel@nongnu.org; Wed, 30 Aug 2023 00:59:45 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1bf11b1c7d0so3535245ad.0 for ; Tue, 29 Aug 2023 21:57:36 -0700 (PDT) Received: from 64217.gitgo.cc ([8.210.91.195]) by smtp.gmail.com with ESMTPSA id t11-20020a170902a5cb00b001bfd92ec592sm10183553plq.292.2023.08.29.21.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 21:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20221208.gappssmtp.com; s=20221208; t=1693371455; x=1693976255; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7MzIajxlynAc7cZYmUnN0op416U5kko2ZZOVqw7m+l4=; b=ZzLol42ms8yOEm5GTaz+wPYn6pnTLbPtJA6Bat6gM/yIiJqC+EfN+KFx/CyYdjniUD 42MeprMYSi2HTrdOeVhcHQoawf5o4wsSQ+OMySCdDbUBIqLcUxdBlKXPOVnPjzEUa5Mh nD5hSj2a2wU4dyTjCjXxdGbDXGjli8dsrGyqephMNcN9vQytbstd9UU8eDHB9MOtA2kC 7WwL6QsquVSckMPiuJkN6UZyWYazVqSAFFeBK6EiRt6jJabHUag3aYygz5ztcb9vUK6L iDWgtCPQgHnvN1tfjVmtzv/heF3ynMWaz68L7pq1k7YU9tk6SOwdAbfJnRcpuDxOt3NN MFiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693371455; x=1693976255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7MzIajxlynAc7cZYmUnN0op416U5kko2ZZOVqw7m+l4=; b=fbRIFvoXXBaVCV+ebzJHCJsOyZKO2dqPo5OGm0zdwsl9IdNJsGxwBpGt2xnhO+sozO FA/gWI00BkGflcf8IMoq9hJig+dqET7C4fRk/U77GlPfs4r4wLsv2d24s+NaRX7QHPNp 9LSrkqufsiIHPGaQ+AOTCz9GX6hB1OO0dcpc1G4rbnlwJGX7xMsyQ/VcO7oBAgGLBokh g+dMcxYBv1Y87nMeJgKpqq27G4HOumvbRPusqnJVBKSDpiEHPDmfdJUUcTyskp29DL1t xnjIT0eFbCxslOxUTNhwj1KqOK9VhaJPDtQOfLa6HS6DfV61GU1fW1/IA0/yuSFd2DU2 ppGA== X-Gm-Message-State: AOJu0YzyXX/hCAYOym+z2chXX/QatmNPaOLTE88DcgSqE2YxD6CO1g/u x3KZeRJmZEPafqgBtX20toXJQg== X-Google-Smtp-Source: AGHT+IFO6SNQhekFb9XbMDM1rw0CVh1dFA6dwoQUqviYhI1VTisLX7Ls00pLXL9qluzCsuNKWGWRDA== X-Received: by 2002:a17:902:ed55:b0:1c0:bcbc:d66 with SMTP id y21-20020a170902ed5500b001c0bcbc0d66mr1896408plb.7.1693371455059; Tue, 29 Aug 2023 21:57:35 -0700 (PDT) From: Li Feng To: "Michael S. Tsirkin" , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Viresh Kumar , qemu-block@nongnu.org (open list:Block layer core), qemu-devel@nongnu.org (open list:All patches CC here) Cc: Li Feng Subject: [PATCH v3 1/2] vhost-user: Fix lost reconnect Date: Wed, 30 Aug 2023 12:57:13 +0800 Message-ID: <20230830045722.611224-2-fengli@smartx.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230830045722.611224-1-fengli@smartx.com> References: <20230804052954.2918915-1-fengli@smartx.com> <20230830045722.611224-1-fengli@smartx.com> MIME-Version: 1.0 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::62d; envelope-from=fengli@smartx.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1693371671508100005 Content-Type: text/plain; charset="utf-8" When the vhost-user is reconnecting to the backend, and if the vhost-user f= ails at the get_features in vhost_dev_init(), then the reconnect will fail and it will not be retriggered forever. The reason is: When the vhost-user fails at get_features, the vhost_dev_cleanup will be ca= lled immediately. vhost_dev_cleanup calls 'memset(hdev, 0, sizeof(struct vhost_dev))'. The reconnect path is: vhost_user_blk_event vhost_user_async_close(.. vhost_user_blk_disconnect ..) qemu_chr_fe_set_handlers <----- clear the notifier callback schedule vhost_user_async_close_bh The vhost->vdev is null, so the vhost_user_blk_disconnect will not be called, then the event fd callback will not be reinstalled. All vhost-user devices have this issue, including vhost-user-blk/scsi. With this patch, if the vdev->vdev is null, the fd callback will still be reinstalled. Fixes: 71e076a07d ("hw/virtio: generalise CHR_EVENT_CLOSED handling") Signed-off-by: Li Feng Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 2 +- hw/scsi/vhost-user-scsi.c | 3 ++- hw/virtio/vhost-user-gpio.c | 2 +- hw/virtio/vhost-user.c | 9 +++++++-- include/hw/virtio/vhost-user.h | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 3c69fa47d5..95c758200d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -391,7 +391,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrE= vent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &s->chardev, &s->dev, - vhost_user_blk_disconnect); + vhost_user_blk_disconnect, vhost_user_blk_e= vent); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index a7fa8e8df2..e931df9f5b 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -236,7 +236,8 @@ static void vhost_user_scsi_event(void *opaque, QEMUChr= Event event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vs->conf.chardev, &vsc->dev, - vhost_user_scsi_disconnect); + vhost_user_scsi_disconnect, + vhost_user_scsi_event); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index d9979aa5db..04c2cc79f4 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -283,7 +283,7 @@ static void vu_gpio_event(void *opaque, QEMUChrEvent ev= ent) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &gpio->chardev, &gpio->vhost_dev, - vu_gpio_disconnect); + vu_gpio_disconnect, vu_gpio_event); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 8dcf049d42..12c4a41f30 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2643,6 +2643,7 @@ typedef struct { DeviceState *dev; CharBackend *cd; struct vhost_dev *vhost; + IOEventHandler *event_cb; } VhostAsyncCallback; =20 static void vhost_user_async_close_bh(void *opaque) @@ -2657,7 +2658,10 @@ static void vhost_user_async_close_bh(void *opaque) */ if (vhost->vdev) { data->cb(data->dev); - } + } else if (data->event_cb) { + qemu_chr_fe_set_handlers(data->cd, NULL, NULL, data->event_cb, + NULL, data->dev, NULL, true); + } =20 g_free(data); } @@ -2669,7 +2673,8 @@ static void vhost_user_async_close_bh(void *opaque) */ void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb) + vu_async_close_fn cb, + IOEventHandler *event_cb) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { /* diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 191216a74f..649e9dd54f 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -84,6 +84,7 @@ typedef void (*vu_async_close_fn)(DeviceState *cb); =20 void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb); + vu_async_close_fn cb, + IOEventHandler *event_cb); =20 #endif --=20 2.41.0 From nobody Wed May 15 07:47:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1693371668; cv=none; d=zohomail.com; s=zohoarc; b=LiUxql0MshOqd6R+Zg46Ux82exBTa+QMbpWmAmVG7mrEGJ4sBHhiOqSknov+WYfHp+I0CMNNwBBA3wIS3dz2L2iSmq8XYSHXBJD+dFdNmgiZsk3hz/bZULzJcRzShIjuXsM5qVCQlmmlr0uzoUyjtsr6t/lFvZH3alaCmrgr1gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693371668; h=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=DYhaBgdJtds96WYpoue74AAWuPp3SkCXlJzfVY0iv9Y=; b=Yu4lkHZ1A7RDdizLGFSaM8dbcHnrI2+wZa7SBaKOG02I9TwYIA/gAkL57P/m4PCrP3zVNNU4AQXyJfQkhz2KRa8YKsjV9+1kd4kl9yRnLTVqBOQ5z/m4UTPE40ufvJJikb8bEY7hn0a2eLG7Vq4s1mZX6sY1PZuzUjZzgDXoFFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693371668007338.1466572455463; Tue, 29 Aug 2023 22:01:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbDJA-0007wF-Di; Wed, 30 Aug 2023 01:00:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbDIy-0007ua-EP for qemu-devel@nongnu.org; Wed, 30 Aug 2023 00:59:50 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbDIq-00041n-34 for qemu-devel@nongnu.org; Wed, 30 Aug 2023 00:59:47 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-56c2e882416so2602405a12.3 for ; Tue, 29 Aug 2023 21:57:39 -0700 (PDT) Received: from 64217.gitgo.cc ([8.210.91.195]) by smtp.gmail.com with ESMTPSA id t11-20020a170902a5cb00b001bfd92ec592sm10183553plq.292.2023.08.29.21.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 21:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20221208.gappssmtp.com; s=20221208; t=1693371459; x=1693976259; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DYhaBgdJtds96WYpoue74AAWuPp3SkCXlJzfVY0iv9Y=; b=OGVVy7dInTY9mmwoQGdvU26hEWy7AUMoUhnfJQ4Hm8U7UDWJhklXga0xysc/Okwkrw VyJgLglNqDwfpMUFTgN0w7HW4UqOsuylYHD1CVgpgKTJiFGhiWSx2kgKXwmjlyXN7jRf EZPbIXcpUvJh15e66Plo4qiPpoMECnzqUP7L76Vw2ZFafIIoCIFTJYxa5K0h2chMemUB 4JHe5icJAFSiAGbIEoWWsmWzHHlL4rx2NzpEbveEfNYQRFaGssiTgoEgs14izGSAKLh7 1fKRfoBX68MWHg/88rjGUS/pcB25XBwYm9AnDWU+2vXxpI16BB9gs9TpdjMZuuquoxTg CBhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693371459; x=1693976259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DYhaBgdJtds96WYpoue74AAWuPp3SkCXlJzfVY0iv9Y=; b=XvSl0hikmOKoBkbgIvWyFHOP/Ur2gORQQ6A0p7hveSV8ZTB9eyCzfOjtR/wqqkDOX6 y7xuRMxESLgNGlDzzMws2qvojF9XKyloMY/rJJt7DC+gwg+0zrKkCWoPNEvP2H9/jwB6 VpQ/gcyRmOlIRjeXGvM9AuNRcE6EW2yjTeAJiJGeVPtBFxP1WI2+hRh+3emGZDHYywa2 NghktydbwXy1LIkrZlqAgT05ZovDIWkgabLPKeB0GFIhYNmQPKCni5vmO60hfcmWEnQe rLEiI3PwFgTKKhOz3u5YFvJFkXersmS1+G0lvH3rucOuW5kEeQ/URz4vfxi34pKWM/sl BWcA== X-Gm-Message-State: AOJu0Yw8wxwP4OVTzfaQzJet+DgLxwIN4sr6pPKJdFvbUZuaA7arB9z8 FtebMFSlQFsWYLwoPxLbM30QMw== X-Google-Smtp-Source: AGHT+IE2ynpzfGWaybdZrAH0Vrqp8hJmK9tnFW523ym2FMzw2JjusJKiwB/hXeaTdA2IKuA4NpYiJw== X-Received: by 2002:a17:90a:f417:b0:26f:b158:ef2b with SMTP id ch23-20020a17090af41700b0026fb158ef2bmr1153079pjb.23.1693371458544; Tue, 29 Aug 2023 21:57:38 -0700 (PDT) From: Li Feng To: "Michael S. Tsirkin" , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Viresh Kumar , qemu-block@nongnu.org (open list:Block layer core), qemu-devel@nongnu.org (open list:All patches CC here) Cc: Li Feng Subject: [PATCH v3 2/2] vhost: Add Error parameter to vhost_scsi_common_start() Date: Wed, 30 Aug 2023 12:57:14 +0800 Message-ID: <20230830045722.611224-3-fengli@smartx.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230830045722.611224-1-fengli@smartx.com> References: <20230804052954.2918915-1-fengli@smartx.com> <20230830045722.611224-1-fengli@smartx.com> MIME-Version: 1.0 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::52b; envelope-from=fengli@smartx.com; helo=mail-pg1-x52b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1693371669767100003 Content-Type: text/plain; charset="utf-8" Add a Error parameter to report the real error, like vhost-user-blk. Signed-off-by: Li Feng Reviewed-by: Raphael Norwitz --- hw/scsi/vhost-scsi-common.c | 16 +++++++++------- hw/scsi/vhost-scsi.c | 5 +++-- hw/scsi/vhost-user-scsi.c | 14 ++++++++------ include/hw/virtio/vhost-scsi-common.h | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c index a61cd0e907..4c8637045d 100644 --- a/hw/scsi/vhost-scsi-common.c +++ b/hw/scsi/vhost-scsi-common.c @@ -16,6 +16,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "hw/virtio/vhost.h" @@ -25,7 +26,7 @@ #include "hw/virtio/virtio-access.h" #include "hw/fw-path-provider.h" =20 -int vhost_scsi_common_start(VHostSCSICommon *vsc) +int vhost_scsi_common_start(VHostSCSICommon *vsc, Error **errp) { int ret, i; VirtIODevice *vdev =3D VIRTIO_DEVICE(vsc); @@ -35,18 +36,19 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc) VirtIOSCSICommon *vs =3D (VirtIOSCSICommon *)vsc; =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(&vsc->dev, vdev); if (ret < 0) { + error_setg_errno(errp, -ret, "Error enabling host notifiers"); return ret; } =20 ret =3D k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, true); if (ret < 0) { - error_report("Error binding guest notifier"); + error_setg_errno(errp, -ret, "Error binding guest notifier"); goto err_host_notifiers; } =20 @@ -54,7 +56,7 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc) =20 ret =3D vhost_dev_prepare_inflight(&vsc->dev, vdev); if (ret < 0) { - error_report("Error setting inflight format: %d", -ret); + error_setg_errno(errp, -ret, "Error setting inflight format"); goto err_guest_notifiers; } =20 @@ -64,21 +66,21 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc) vs->conf.virtqueue_size, vsc->inflight); if (ret < 0) { - error_report("Error getting inflight: %d", -ret); + error_setg_errno(errp, -ret, "Error getting inflight"); goto err_guest_notifiers; } } =20 ret =3D vhost_dev_set_inflight(&vsc->dev, vsc->inflight); if (ret < 0) { - error_report("Error setting inflight: %d", -ret); + error_setg_errno(errp, -ret, "Error setting inflight"); goto err_guest_notifiers; } } =20 ret =3D vhost_dev_start(&vsc->dev, vdev, true); if (ret < 0) { - error_report("Error start vhost dev"); + error_setg_errno(errp, -ret, "Error starting vhost dev"); goto err_guest_notifiers; } =20 diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 443f67daa4..01a3ab4277 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -75,6 +75,7 @@ static int vhost_scsi_start(VHostSCSI *s) int ret, abi_version; VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); const VhostOps *vhost_ops =3D vsc->dev.vhost_ops; + Error *local_err =3D NULL; =20 ret =3D vhost_ops->vhost_scsi_get_abi_version(&vsc->dev, &abi_version); if (ret < 0) { @@ -88,14 +89,14 @@ static int vhost_scsi_start(VHostSCSI *s) return -ENOSYS; } =20 - ret =3D vhost_scsi_common_start(vsc); + ret =3D vhost_scsi_common_start(vsc, &local_err); if (ret < 0) { return ret; } =20 ret =3D vhost_scsi_set_endpoint(s); if (ret < 0) { - error_report("Error setting vhost-scsi endpoint"); + error_reportf_err(local_err, "Error setting vhost-scsi endpoint"); vhost_scsi_common_stop(vsc); } =20 diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index e931df9f5b..62fc98bb1c 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -43,12 +43,12 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, }; =20 -static int vhost_user_scsi_start(VHostUserSCSI *s) +static int vhost_user_scsi_start(VHostUserSCSI *s, Error **errp) { VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); int ret; =20 - ret =3D vhost_scsi_common_start(vsc); + ret =3D vhost_scsi_common_start(vsc, errp); s->started_vu =3D (ret < 0 ? false : true); =20 return ret; @@ -73,6 +73,7 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev= , uint8_t status) VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(dev); bool should_start =3D virtio_device_should_start(vdev, status); + Error *local_err =3D NULL; int ret; =20 if (!s->connected) { @@ -84,9 +85,10 @@ static void vhost_user_scsi_set_status(VirtIODevice *vde= v, uint8_t status) } =20 if (should_start) { - ret =3D vhost_user_scsi_start(s); + ret =3D vhost_user_scsi_start(s, &local_err); if (ret < 0) { - error_report("unable to start vhost-user-scsi: %s", strerror(-= ret)); + error_reportf_err(local_err, "unable to start vhost-user-scsi:= %s", + strerror(-ret)); qemu_chr_fe_disconnect(&vs->conf.chardev); } } else { @@ -139,7 +141,7 @@ static void vhost_user_scsi_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_scsi_start(s); + ret =3D vhost_user_scsi_start(s, &local_err); if (ret < 0) { error_reportf_err(local_err, "vhost-user-scsi: vhost start failed:= "); qemu_chr_fe_disconnect(&vs->conf.chardev); @@ -184,7 +186,7 @@ static int vhost_user_scsi_connect(DeviceState *dev, Er= ror **errp) =20 /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { - ret =3D vhost_user_scsi_start(s); + ret =3D vhost_user_scsi_start(s, errp); if (ret < 0) { return ret; } diff --git a/include/hw/virtio/vhost-scsi-common.h b/include/hw/virtio/vhos= t-scsi-common.h index 18f115527c..c5d2c09455 100644 --- a/include/hw/virtio/vhost-scsi-common.h +++ b/include/hw/virtio/vhost-scsi-common.h @@ -39,7 +39,7 @@ struct VHostSCSICommon { struct vhost_inflight *inflight; }; =20 -int vhost_scsi_common_start(VHostSCSICommon *vsc); +int vhost_scsi_common_start(VHostSCSICommon *vsc, Error **errp); void vhost_scsi_common_stop(VHostSCSICommon *vsc); char *vhost_scsi_common_get_fw_dev_path(FWPathProvider *p, BusState *bus, DeviceState *dev); --=20 2.41.0