From patchwork Mon Mar 23 05:29:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 11452981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 891DA1392 for ; Mon, 23 Mar 2020 13:34:00 +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 2821220735 for ; Mon, 23 Mar 2020 13:34:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=smartx-com.20150623.gappssmtp.com header.i=@smartx-com.20150623.gappssmtp.com header.b="B9kLgXi3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2821220735 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGNDL-0000Os-5f for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Mar 2020 09:33:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59258) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGFe4-0007jz-Vs for qemu-devel@nongnu.org; Mon, 23 Mar 2020 01:29:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGFe3-0001UJ-IP for qemu-devel@nongnu.org; Mon, 23 Mar 2020 01:29:04 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGFe3-0001TS-6K for qemu-devel@nongnu.org; Mon, 23 Mar 2020 01:29:03 -0400 Received: by mail-pg1-x544.google.com with SMTP id d17so6049883pgo.0 for ; Sun, 22 Mar 2020 22:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:to:cc:subject:date:message-id :content-transfer-encoding; bh=rn1rzPyZjU/1uasX4nLAsRBp6Z3yrACVS7w/C5ZCX9E=; b=B9kLgXi3vNJYNNkLfWhZnzynGcZLN8KTTOi8S+uISLsDOJcRwitaSnkEzROIMMeoLG 58xy7wUshKtDWX0p3yk9rEFKtVu5tpJ6BANPa/D7Mxg9uDZce6unDBjZsxeRgr17ZmOu KmV7mLqlJLXMRbzmbgSR9gILYafA3hHaoxYmR5g5/w4UHDEM06P2ekTmi+xfxg9BdFmF NTx8fYak39FQyEcLGEV8F9X5/gUjkgikmgZyoXSQYhHUwXXZmH+cwKezXB3t/lDZj+1E 0sJRbXvJy79ovmcsYirW4KiOYN10y+A5A7jQxr18/Am1cps9juRk/ZRP50aazcjJJ6NQ sWSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :content-transfer-encoding; bh=rn1rzPyZjU/1uasX4nLAsRBp6Z3yrACVS7w/C5ZCX9E=; b=gD8qNpjyNB3a9xyA7D5EizXFF7KPkEphL1EaO6eh7akbMiKhViIbeYhwCRaq+GPP7J KwaLX4NInBFJuSHHkgeuXxJPuvu39nuphWBO8SHSCXZxWfm9yujdSiZLnR9/h0Qsxy2U iD5tZclcLk2u3QgSdpPCaBGsliJc1T7tfpKY2gcLq/XgzM/O/hDdcXMXDJ7JnCcWmWlZ +VGr6C3NOSZZeKSI2HmwYTQnOL4G8EwRmR8mcTUnKcVmh0YQTvgagTW9FAEqeTTus4nR jyo8+3KVJNC5REZsxGnj77/YgVHOpsWccNtBU0Y6ameGLsaImtVt9h1aPhKtJ5dgommG vI8A== MIME-Version: 1.0 X-Gm-Message-State: ANhLgQ20QCZKqtRCMMJrkdFsGnAFoUieAbfHgi2em7nUzf8t8PGvEKmn +FluWJPE3aGpnhPbRbn41Ya9aYQdPIhv39Q9mOzpwr/VOYShGGOr/ZsnJmsRxgRkkuMjpcg8JbH OCRXduEEW X-Google-Smtp-Source: ADFU+vv8MuenS8R5ry2qx46wBcwxJrWPxc3S3Nn2FVeAf73oMUwG6iP99FeBCSokK4B8UY/nHoPA8A== X-Received: by 2002:aa7:8f3a:: with SMTP id y26mr22191464pfr.180.1584941341253; Sun, 22 Mar 2020 22:29:01 -0700 (PDT) Received: from 31_216.localdomain ([47.75.244.237]) by smtp.gmail.com with ESMTPSA id o14sm7905195pfh.147.2020.03.22.22.28.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2020 22:29:00 -0700 (PDT) From: Li Feng To: "Michael S. Tsirkin" , Kevin Wolf , Max Reitz , qemu-block@nongnu.org (open list:Block layer core), qemu-devel@nongnu.org (open list:All patches CC here) Subject: [PATCH] fix vhost_user_blk_watch crash Date: Mon, 23 Mar 2020 13:29:24 +0800 Message-Id: <20200323052924.29286-1-fengli@smartx.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-Mailman-Approved-At: Mon, 23 Mar 2020 09:32:41 -0400 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: Li Feng Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" the G_IO_HUP is watched in tcp_chr_connect, and the callback vhost_user_blk_watch is not needed, because tcp_chr_hup is registered as callback. And it will close the tcp link. Signed-off-by: Li Feng Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 19 ------------------- include/hw/virtio/vhost-user-blk.h | 1 - 2 files changed, 20 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 12925a47ec..17df5338e7 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -349,18 +349,6 @@ static void vhost_user_blk_disconnect(DeviceState *dev) vhost_dev_cleanup(&s->dev); } -static gboolean vhost_user_blk_watch(GIOChannel *chan, GIOCondition cond, - void *opaque) -{ - DeviceState *dev = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserBlk *s = VHOST_USER_BLK(vdev); - - qemu_chr_fe_disconnect(&s->chardev); - - return true; -} - static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) { DeviceState *dev = opaque; @@ -373,15 +361,9 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) qemu_chr_fe_disconnect(&s->chardev); return; } - s->watch = qemu_chr_fe_add_watch(&s->chardev, G_IO_HUP, - vhost_user_blk_watch, dev); break; case CHR_EVENT_CLOSED: vhost_user_blk_disconnect(dev); - if (s->watch) { - g_source_remove(s->watch); - s->watch = 0; - } break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: @@ -428,7 +410,6 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) s->inflight = g_new0(struct vhost_inflight, 1); s->vhost_vqs = g_new0(struct vhost_virtqueue, s->num_queues); - s->watch = 0; s->connected = false; qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event, diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-user-blk.h index 05ea0ad183..34ad6f0c0e 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -38,7 +38,6 @@ typedef struct VHostUserBlk { VhostUserState vhost_user; struct vhost_virtqueue *vhost_vqs; VirtQueue **virtqs; - guint watch; bool connected; } VHostUserBlk;