From nobody Mon Feb 9 07:38:47 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603983024; cv=none; d=zohomail.com; s=zohoarc; b=Iktw5tLbU0A4jk9a3ZDh+iadTGTNagI0A2nh99U295sG2oVW7UhwrHsMyXym0TBjrrQM/nzJsrLXsa11YQtQxyqrowunqHVUm8JuUVrRPYOYGwsGaf+CkcvL4o8DSnD8zq2cVkSLKiyINSNJtdg8q+oHfiTG6G6vXDC1eW5Sos4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603983024; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fvVMqZSd4VN1ZLw8n4EK7pU8ZfGt/oolMQPE84iYdls=; b=Exxk1AM1K04IyAZyxO86iXwiIlU7OSKPgoSuDdTADM3MoTbe7CLzYC7EFGrMgkjyT76ZFe6CFwyGqyrw6fES4vjV02OKhIGVXCMs248RaGWn4YLaDTGF693sbRVvDktJbhbt78sXyFbb7kWBTbo7K8L40UjhRjaHUWhI5YlPy5g= 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; dmarc=pass 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 1603983024176677.3086547890811; Thu, 29 Oct 2020 07:50:24 -0700 (PDT) Received: from localhost ([::1]:56516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY9Fu-0004E3-Us for importer@patchew.org; Thu, 29 Oct 2020 10:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY9Ee-0003TX-7o for qemu-devel@nongnu.org; Thu, 29 Oct 2020 10:49:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51231) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY9Ec-0000Tl-0Y for qemu-devel@nongnu.org; Thu, 29 Oct 2020 10:49:03 -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-111-0gFQdUguOhuQbsrx1Mf05g-1; Thu, 29 Oct 2020 10:48:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A13891019635 for ; Thu, 29 Oct 2020 14:48:56 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-112-127.ams2.redhat.com [10.36.112.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id F095F5B4CD; Thu, 29 Oct 2020 14:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603982939; 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; bh=fvVMqZSd4VN1ZLw8n4EK7pU8ZfGt/oolMQPE84iYdls=; b=LCPolFshlOU0CYLoSXZIl14RXsSk+dGRwPojrHAPMIuVAn2DYTO7+bZ1dZ/4FQ7WHOu6T7 srkyI0doOBGIgon9vd8QulqgaOZfuYqkmSiLfw60e/uXN2fs12I6gKc2S8G4mlpenl2Te8 /whCPI6gEF7A60He4l2nEWIkFBdwmPc= X-MC-Unique: 0gFQdUguOhuQbsrx1Mf05g-1 From: Stefano Garzarella To: qemu-devel@nongnu.org Subject: [PATCH] vhost-vsock: set vhostfd to non-blocking mode Date: Thu, 29 Oct 2020 15:48:49 +0100 Message-Id: <20201029144849.70958-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=sgarzare@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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=sgarzare@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" vhost IOTLB API uses read()/write() to exchange iotlb messages with the kernel module. The QEMU implementation expects a non-blocking fd, indeed commit c471ad0e9b ("vhost_net: device IOTLB support") set it for vhost-net. Without this patch, if we enable iommu for the vhost-vsock device, QEMU can hang when exchanging IOTLB messages. As commit 894022e616 ("net: check if the file descriptor is valid before using it") did for tap, let's use qemu_try_set_nonblock() when fd is provided by the user. Signed-off-by: Stefano Garzarella --- hw/virtio/vhost-vsock.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index f9db4beb47..8ddfb9abfe 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -16,6 +16,7 @@ #include "qapi/error.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" +#include "qemu/sockets.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" @@ -148,6 +149,13 @@ static void vhost_vsock_device_realize(DeviceState *de= v, Error **errp) error_prepend(errp, "vhost-vsock: unable to parse vhostfd: "); return; } + + ret =3D qemu_try_set_nonblock(vhostfd); + if (ret < 0) { + error_setg_errno(errp, -ret, + "vhost-vsock: unable to set non-blocking mode= "); + return; + } } else { vhostfd =3D open("/dev/vhost-vsock", O_RDWR); if (vhostfd < 0) { @@ -155,6 +163,8 @@ static void vhost_vsock_device_realize(DeviceState *dev= , Error **errp) "vhost-vsock: failed to open vhost device"); return; } + + qemu_set_nonblock(vhostfd); } =20 vhost_vsock_common_realize(vdev, "vhost-vsock"); --=20 2.26.2