From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898456; cv=none; d=zohomail.com; s=zohoarc; b=GMIeXN5hHyAmTUxBt7fWCvuLuHTOuzQbF29I0tkHYUb4jtukmqKPOO6uVJVqWU6J1jZbTNVWvNTnjj6J9to7SEByg27y2739tkLI21wv+x3TgdO5JY2GUW04xuONq0ZFk6rbC+PgjZOPAa6ozRXbNFeuYFlWp5IA9lCidPO41Go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898456; 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=VF68uyWFilZpHj5bABsThH0akvfjRoVBR9ksieJzwHo=; b=DAPZJdnorwTJ6/2eczg4DX14GJq2hoLJV4F2+xA9h5TJRbxYkx/5rmh0svcyiBtecYz+LRbBzaxNzQtBW32hVVMcbqD9DUFSOzjpQMtcIlxRRf0eKkXuYeoDa+WeIK+tMD8L5QTY1j5NvDKl+w0iGAa4uGEQS4Az9i5u35ga4wM= 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+importer=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 1605898456978421.4375080125742; Fri, 20 Nov 2020 10:54:16 -0800 (PST) Received: from localhost ([::1]:33786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBXz-0005WF-89 for importer@patchew.org; Fri, 20 Nov 2020 13:54:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBVl-00045U-O7 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:51:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBVZ-0006sY-Cz for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:51:56 -0500 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-125-5oC7RBGnOfe3nRKgW98M6A-1; Fri, 20 Nov 2020 13:51:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2F0E1842159; Fri, 20 Nov 2020 18:51:30 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 440965C1D5; Fri, 20 Nov 2020 18:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898295; 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=VF68uyWFilZpHj5bABsThH0akvfjRoVBR9ksieJzwHo=; b=R4QjhXmk3NTOZ5E1hI4nQ0rI7jo+E6TZDmhwBc7LGnGJJz9wQv6riO0NWMERY7lW305SUH CxERRyiEF9wEiuuPh4eeZp2uR7GzwzhqCZxLXGiQ0Meau3DF9tKKZKx+W8Z9LTlOl3JqF0 mq/+Ia3EyAH2be5pGfwUXgHEh1wBZ8k= X-MC-Unique: 5oC7RBGnOfe3nRKgW98M6A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 01/27] vhost: Add vhost_dev_can_log Date: Fri, 20 Nov 2020 19:50:39 +0100 Message-Id: <20201120185105.279030-2-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Just syntactic sugar. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 614ccc2bcb..2bd8cdf893 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -61,6 +61,11 @@ bool vhost_has_free_slot(void) return slots_limit > used_memslots; } =20 +static bool vhost_dev_can_log(const struct vhost_dev *hdev) +{ + return hdev->features & (0x1ULL << VHOST_F_LOG_ALL); +} + static void vhost_dev_sync_region(struct vhost_dev *dev, MemoryRegionSection *section, uint64_t mfirst, uint64_t mlast, @@ -1347,7 +1352,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, }; =20 if (hdev->migration_blocker =3D=3D NULL) { - if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { + if (!vhost_dev_can_log(hdev)) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL fe= ature."); } else if (vhost_dev_log_is_shared(hdev) && !qemu_memfd_alloc_chec= k()) { --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899104; cv=none; d=zohomail.com; s=zohoarc; b=loCeNXkTpD46mOBwRy3/DuzXgr7MM7L1r0+j48fp4wXRWA1uaYiRY5Eq3ilJdGGJnZ+Uw2upWlVrWMCNhejq2C+0emOVDIcU7iNdMatIcO1tnYiUw8vB2ygPJihCTQIEjfqrATPhR7WXCUr1eAV6OTU0KVmmtRaWc2Vrp57ZPWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899104; 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=hB04k6BmQFwa3NAoUh0c6SZfxRFuR9AWa1v2aVbfxk4=; b=GGxwPvpQAxONrdmdRb3KMYQ81ZA/1sWgyEagik/Byya3SDZBJlXcEAhVp5FF00aGOKpUCaP39kbNOWkJUU9mDT9OnqHlEZRicvRKJ1D4nqZXBuQaLJhoYS1z0XQa/F0H9RcCmewyKyRSCDIaMZRpMte37eBCRp2YnkHDckk3jRM= 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+importer=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 1605899104591180.78418169281156; Fri, 20 Nov 2020 11:05:04 -0800 (PST) Received: from localhost ([::1]:59626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBiR-00082O-Ff for importer@patchew.org; Fri, 20 Nov 2020 14:05:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBVo-000478-D4 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBVk-0006vi-Vk for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:00 -0500 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-238-ZCnzaR28NEuQleuWtg2vfQ-1; Fri, 20 Nov 2020 13:51:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 671DD1842159; Fri, 20 Nov 2020 18:51:43 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26B075C1D5; Fri, 20 Nov 2020 18:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898310; 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=hB04k6BmQFwa3NAoUh0c6SZfxRFuR9AWa1v2aVbfxk4=; b=PwIRLYwrvqHT4UyXpKM8/TF5+veSWLwJUFRKifbdWDurUZQJ079MvHlYSUhvxknQANYIpx n8ByMmt5LXYNX6psf25QvY7+OTIilLtQSLwJDfWbJsIwW6p2oQgGEf5919VSH/nARVIIuw tzWSiorBEwXXy7CxTJNughv07hRz3Ko= X-MC-Unique: ZCnzaR28NEuQleuWtg2vfQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 02/27] vhost: Add device callback in vhost_migration_log Date: Fri, 20 Nov 2020 19:50:40 +0100 Message-Id: <20201120185105.279030-3-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This allows code to reuse the logic to not to re-enable or re-disable migration mechanisms. Code works the same way as before. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2bd8cdf893..2adb2718c1 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -862,7 +862,9 @@ err_features: return r; } =20 -static int vhost_migration_log(MemoryListener *listener, bool enable) +static int vhost_migration_log(MemoryListener *listener, + bool enable, + int (*device_cb)(struct vhost_dev *, bool)) { struct vhost_dev *dev =3D container_of(listener, struct vhost_dev, memory_listener); @@ -877,14 +879,14 @@ static int vhost_migration_log(MemoryListener *listen= er, bool enable) =20 r =3D 0; if (!enable) { - r =3D vhost_dev_set_log(dev, false); + r =3D device_cb(dev, false); if (r < 0) { goto check_dev_state; } vhost_log_put(dev, false); } else { vhost_dev_log_resize(dev, vhost_get_log_size(dev)); - r =3D vhost_dev_set_log(dev, true); + r =3D device_cb(dev, true); if (r < 0) { goto check_dev_state; } @@ -916,7 +918,7 @@ static void vhost_log_global_start(MemoryListener *list= ener) { int r; =20 - r =3D vhost_migration_log(listener, true); + r =3D vhost_migration_log(listener, true, vhost_dev_set_log); if (r < 0) { abort(); } @@ -926,7 +928,7 @@ static void vhost_log_global_stop(MemoryListener *liste= ner) { int r; =20 - r =3D vhost_migration_log(listener, false); + r =3D vhost_migration_log(listener, false, vhost_dev_set_log); if (r < 0) { abort(); } --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898457; cv=none; d=zohomail.com; s=zohoarc; b=UqlnuOQc3SHsFWPZg6eirCH0mZYOgsN3+KsIOf3X/8OVl+sEbu79JDeIWsqH0trGcrTTh1QCCl8LgQmqtNqknyOByZUihMRocbhA8raSuRuN1osQj5FJUHQmCjKiTLoqC76biCKwkKlXSt4s1ejt+ZIjXsiDpkrKwa+OtNTibuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898457; 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=4varrbTkFQFU3BGiSDv77OV+Am6FgvunCFxXqhYibgk=; b=JzRWM4b8A0FCNBiFy6BJnwhAIHkUv0XbbuLERBxIurGijFOasROSl6A2XgraJz250umQT5GdzTfIme6wcy4szIuyMlF8lKy8w2nX9Vf2O+CGXijL+8vRN+tTR3ePxcDtz6FYaWVE4TVbLiKbR/olxzbA/TvswbSBcyHSM3v0R1I= 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+importer=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 1605898457524745.6773107511972; Fri, 20 Nov 2020 10:54:17 -0800 (PST) Received: from localhost ([::1]:33884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBY0-0005Yk-5w for importer@patchew.org; Fri, 20 Nov 2020 13:54:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBVp-00048L-8u for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBVn-0006wv-B7 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:00 -0500 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-325-icKHBA9mMzOymkuJgqFU_Q-1; Fri, 20 Nov 2020 13:51:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA084107AD30; Fri, 20 Nov 2020 18:51:52 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B5435C1D5; Fri, 20 Nov 2020 18:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898318; 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=4varrbTkFQFU3BGiSDv77OV+Am6FgvunCFxXqhYibgk=; b=TnUoj5tlsNT0shyl+zdVVBGZ/18D3iyeTOEN8LWCVhHzNSHp8id6wWT0zq73779kJ3AkPZ oemY6TirrHp4RV97AAtIy187A48jnRsZ1WW/ABNyNQU1SG7vdTgmW27QtsjVx7HDNgQYb0 KhzHcyp04YOHLZuvuVYfuj6ezyyuT+o= X-MC-Unique: icKHBA9mMzOymkuJgqFU_Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 03/27] vhost: Move log resize/put to vhost_dev_set_log Date: Fri, 20 Nov 2020 19:50:41 +0100 Message-Id: <20201120185105.279030-4-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Software assisted live migration does not allocate vhost log. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2adb2718c1..9cbd52a7f1 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -828,6 +828,10 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bo= ol enable_log) int r, i, idx; hwaddr addr; =20 + if (enable_log) { + vhost_dev_log_resize(dev, vhost_get_log_size(dev)); + } + r =3D vhost_dev_set_features(dev, enable_log); if (r < 0) { goto err_features; @@ -850,6 +854,10 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bo= ol enable_log) goto err_vq; } } + + if (!enable_log) { + vhost_log_put(dev, false); + } return 0; err_vq: for (; i >=3D 0; --i) { @@ -877,22 +885,8 @@ static int vhost_migration_log(MemoryListener *listene= r, return 0; } =20 - r =3D 0; - if (!enable) { - r =3D device_cb(dev, false); - if (r < 0) { - goto check_dev_state; - } - vhost_log_put(dev, false); - } else { - vhost_dev_log_resize(dev, vhost_get_log_size(dev)); - r =3D device_cb(dev, true); - if (r < 0) { - goto check_dev_state; - } - } + r =3D device_cb(dev, enable); =20 -check_dev_state: dev->log_enabled =3D enable; /* * vhost-user-* devices could change their state during log --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898689; cv=none; d=zohomail.com; s=zohoarc; b=JVjPbTIhHPw2SjAOuEItF3/8RZQZTGU/49mDLdVr3oWLH0FjWGmG0jwe6ot7Hg/95xv5mHLVLXNPUtsmQglxBVDmNfxhUy3qeM0Ve2dd8a804Kjj74R9jPJzQdxV2ez/VkrHTUSZ6R5uTsy4EyAFGeJ+iKPqiFwQ0ruHDTUIJBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898689; 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=f1xuNkaaPUcrhHGAqp8H+FXDGPjhfJDXls907UFvbJo=; b=amKHHRoyWhDEOVcuqY9h0e/GKVqRTgrH7pKUNS8VxbP+hB1fzn5cSC/V0ZKJohzKtnluANXIjxxBQvlGdHdgwZieWuWgr3JI9CtisrkOWLzljvPOke9TK1PISyFG0G+YryajQjyE71I5IgkWZChRYmiJz7BtpmE0xkna0YPTXvg= 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+importer=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 1605898689483104.15318527448346; Fri, 20 Nov 2020 10:58:09 -0800 (PST) Received: from localhost ([::1]:40848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBbk-00007M-FT for importer@patchew.org; Fri, 20 Nov 2020 13:58:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBW6-0004Pd-1q for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBW4-00070H-AT for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:17 -0500 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-139-BqEhkUiMPp2_cG8WPQgPOg-1; Fri, 20 Nov 2020 13:52:13 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38DCE8030BC; Fri, 20 Nov 2020 18:52:10 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DEE05C1D5; Fri, 20 Nov 2020 18:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898335; 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=f1xuNkaaPUcrhHGAqp8H+FXDGPjhfJDXls907UFvbJo=; b=g54XMXCCRdOh7wxzq8edRmtDXM/MfH/UxkG1FkPv+qHs3qMX+qVCkqfcL3ZedSEHnHmi2l RopbTdT5fFDH++GYZjotreCCN4ULRN023dNRp5fS3MVtulYLqt/oSZrorl9HgO/JRLAh3p THEq89Jrqgl+qJ1x1y9b4HGRT2e57c4= X-MC-Unique: BqEhkUiMPp2_cG8WPQgPOg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 04/27] vhost: add vhost_kernel_set_vring_enable Date: Fri, 20 Nov 2020 19:50:42 +0100 Message-Id: <20201120185105.279030-5-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-backend.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 222bbcc62d..317f1f96fa 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -201,6 +201,34 @@ static int vhost_kernel_get_vq_index(struct vhost_dev = *dev, int idx) return idx - dev->vq_index; } =20 +static int vhost_kernel_set_vq_enable(struct vhost_dev *dev, unsigned idx, + bool enable) +{ + struct vhost_vring_file file =3D { + .index =3D idx, + }; + + if (!enable) { + file.fd =3D -1; /* Pass -1 to unbind from file. */ + } else { + struct vhost_net *vn_dev =3D container_of(dev, struct vhost_net, d= ev); + file.fd =3D vn_dev->backend; + } + + return vhost_kernel_net_set_backend(dev, &file); +} + +static int vhost_kernel_set_vring_enable(struct vhost_dev *dev, int enable) +{ + int i; + + for (i =3D 0; i < dev->nvqs; ++i) { + vhost_kernel_set_vq_enable(dev, i, enable); + } + + return 0; +} + #ifdef CONFIG_VHOST_VSOCK static int vhost_kernel_vsock_set_guest_cid(struct vhost_dev *dev, uint64_t guest_cid) @@ -317,6 +345,7 @@ static const VhostOps kernel_ops =3D { .vhost_set_owner =3D vhost_kernel_set_owner, .vhost_reset_device =3D vhost_kernel_reset_device, .vhost_get_vq_index =3D vhost_kernel_get_vq_index, + .vhost_set_vring_enable =3D vhost_kernel_set_vring_enable, #ifdef CONFIG_VHOST_VSOCK .vhost_vsock_set_guest_cid =3D vhost_kernel_vsock_set_guest_cid, .vhost_vsock_set_running =3D vhost_kernel_vsock_set_running, --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898688; cv=none; d=zohomail.com; s=zohoarc; b=ZT6pCt+cRjLXCdIZt2MOGpQ8RTT94ShCN6FUSgd/C6o4dnQ2NuY4M5MQkqvrSz24IglokIZSYPm0pRJSDBUU1Xcp8trZnLYGHeAqhTkAigfukga9FcbR9RFH1boB44o9f1OjIbAS5TwwkInPeUs+c9XMMWz6E/hw54dnpOYpYa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898688; 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=FBKfLERfSf5dIrOoBodiDDSFxkynaDNC4JNMEvaUCDk=; b=ZYfD21s8Ne2qihmcFrxhHLhSJliHbYJvg5ZBN+DQkFuBJvEQ02evXTIfq/vwAsh7AUPh0yVJPjOrRxdZj1UK5B+oIe9GFXQet5dlMOMRWFTvBJxls5UiFKHETiHabmfOqyv9hbdhiR4sVB/+Bc1I+rJQsuG3goyLMxjKDwA3J5E= 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+importer=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 1605898688074796.5774550404126; Fri, 20 Nov 2020 10:58:08 -0800 (PST) Received: from localhost ([::1]:40732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBbi-0008WG-Ru for importer@patchew.org; Fri, 20 Nov 2020 13:58:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBWE-0004Ud-4T for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBWC-00071S-6A for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:25 -0500 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-592-DQLDp4S1P1eb-cRn3OpcPw-1; Fri, 20 Nov 2020 13:52:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A853E814418; Fri, 20 Nov 2020 18:52:16 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90D515C1D5; Fri, 20 Nov 2020 18:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898341; 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=FBKfLERfSf5dIrOoBodiDDSFxkynaDNC4JNMEvaUCDk=; b=SCiB1HEka9YFy0+h+PBOK8XD5eWwyPmcFGaPN4Nb18MFGJwsyVwLFc1aM6Kp8rRBA2xxt9 Z6X0BdxyiQ2WDtsj4HhbY3trcbKBvnrzWcLDaUwArLqh0jclOIAat7hGYw7QuUalkyK079 EtE5yiVvlJiJuEvD3TCR/42B/dY1SJI= X-MC-Unique: DQLDp4S1P1eb-cRn3OpcPw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 05/27] vhost: Add hdev->dev.sw_lm_vq_handler Date: Fri, 20 Nov 2020 19:50:43 +0100 Message-Id: <20201120185105.279030-6-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Only virtio-net honors it. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost.h | 1 + hw/net/virtio-net.c | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 4a8bc75415..b5b7496537 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -83,6 +83,7 @@ struct vhost_dev { bool started; bool log_enabled; uint64_t log_size; + VirtIOHandleOutput sw_lm_vq_handler; Error *migration_blocker; const VhostOps *vhost_ops; void *opaque; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9179013ac4..9a69ae3598 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2628,24 +2628,32 @@ static void virtio_net_tx_bh(void *opaque) } } =20 -static void virtio_net_add_queue(VirtIONet *n, int index) +static void virtio_net_add_queue(VirtIONet *n, int index, + VirtIOHandleOutput custom_handler) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + VirtIOHandleOutput rx_vq_handler =3D virtio_net_handle_rx; + VirtIOHandleOutput tx_vq_handler; + bool tx_timer =3D n->net_conf.tx && !strcmp(n->net_conf.tx, "timer"); + + if (custom_handler) { + rx_vq_handler =3D tx_vq_handler =3D custom_handler; + } else if (tx_timer) { + tx_vq_handler =3D virtio_net_handle_tx_timer; + } else { + tx_vq_handler =3D virtio_net_handle_tx_bh; + } =20 n->vqs[index].rx_vq =3D virtio_add_queue(vdev, n->net_conf.rx_queue_si= ze, - virtio_net_handle_rx); + rx_vq_handler); + n->vqs[index].tx_vq =3D virtio_add_queue(vdev, n->net_conf.tx_queue_si= ze, + tx_vq_handler); =20 - if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) { - n->vqs[index].tx_vq =3D - virtio_add_queue(vdev, n->net_conf.tx_queue_size, - virtio_net_handle_tx_timer); + if (tx_timer) { n->vqs[index].tx_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_net_tx_timer, &n->vqs[index]); } else { - n->vqs[index].tx_vq =3D - virtio_add_queue(vdev, n->net_conf.tx_queue_size, - virtio_net_handle_tx_bh); n->vqs[index].tx_bh =3D qemu_bh_new(virtio_net_tx_bh, &n->vqs[inde= x]); } =20 @@ -2677,6 +2685,10 @@ static void virtio_net_del_queue(VirtIONet *n, int i= ndex) static void virtio_net_change_num_queues(VirtIONet *n, int new_max_queues) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + NetClientState *nc =3D n->nic->conf->peers.ncs[0]; + struct vhost_net *hdev =3D get_vhost_net(nc); + VirtIOHandleOutput custom_handler =3D hdev ? hdev->dev.sw_lm_vq_handler + : NULL; int old_num_queues =3D virtio_get_num_queues(vdev); int new_num_queues =3D new_max_queues * 2 + 1; int i; @@ -2702,7 +2714,7 @@ static void virtio_net_change_num_queues(VirtIONet *n= , int new_max_queues) =20 for (i =3D old_num_queues - 1; i < new_num_queues - 1; i +=3D 2) { /* new_num_queues > old_num_queues */ - virtio_net_add_queue(n, i / 2); + virtio_net_add_queue(n, i / 2, custom_handler); } =20 /* add ctrl_vq last */ @@ -3256,6 +3268,8 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIONet *n =3D VIRTIO_NET(dev); NetClientState *nc; + struct vhost_net *hdev; + VirtIOHandleOutput custom_handler; int i; =20 if (n->net_conf.mtu) { @@ -3347,8 +3361,11 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) n->net_conf.tx_queue_size =3D MIN(virtio_net_max_tx_queue_size(n), n->net_conf.tx_queue_size); =20 + nc =3D n->nic_conf.peers.ncs[0]; + hdev =3D get_vhost_net(nc); + custom_handler =3D hdev ? hdev->dev.sw_lm_vq_handler : NULL; for (i =3D 0; i < n->max_queues; i++) { - virtio_net_add_queue(n, i); + virtio_net_add_queue(n, i, custom_handler); } =20 n->ctrl_vq =3D virtio_add_queue(vdev, 64, virtio_net_handle_ctrl); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898889; cv=none; d=zohomail.com; s=zohoarc; b=FuhZoMJRA2JewLVmDcrzhaIdlzbBl+7K6860gaAu4jsY6c+0BtOWVKRwM9wtY4pTVGBupZaJShY9cuUlyZlJdmIOSnmgliYMD7jFmkeFky/qS+QiyveW0SRroCV/70Zr8D5gxk1bkEq7cYZZPDAlwGhIS1yxE6pJ+bTWTjFN8lQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898889; 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=Y17EVO/s0xg6tqcxCWG6nhFINdKj1LKpomp8rmt7L8A=; b=DIdQ88rf8NGHxpDhxRrDF1PQ3t2VFRMzzEytjGR+kTea1BA+1aoVG8IU2w2pK0jPGjyFnoHlly1GEhL48VtIuQFWsJX+3PPzN7F+QntA4KE2jVaqClZx8pv2R7E1VMSE0tWKNS9X1rjUbhhkx5Wu2mZWWxJ62AdJzkOZa/eCcig= 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+importer=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 160589888989541.50273230965195; Fri, 20 Nov 2020 11:01:29 -0800 (PST) Received: from localhost ([::1]:49946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBex-0003yn-Sr for importer@patchew.org; Fri, 20 Nov 2020 14:01:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBWS-0004gd-Do for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBWP-00078J-Vd for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:52:40 -0500 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-392-H2Z1tymUMiSbaQlXOnSUjA-1; Fri, 20 Nov 2020 13:52:35 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7889F8144EC; Fri, 20 Nov 2020 18:52:32 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C9F25C1D5; Fri, 20 Nov 2020 18:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898357; 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=Y17EVO/s0xg6tqcxCWG6nhFINdKj1LKpomp8rmt7L8A=; b=chx1PoKwHguedkukAvHrJivJv5Rwt98XLRA7ctOf0oCdpiyw+5LJEWeRcupj1lWtbT33uY AjHibdD8AZ68VGkEk4w2ag518WA7S+Zwd7poqC6n1gnGIRiWSssaVR/2OEJAqXoAOPG3U+ aDY8Jcv/ogccym8TEi93Bq4joN3SJL0= X-MC-Unique: H2Z1tymUMiSbaQlXOnSUjA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 06/27] virtio: Add virtio_queue_get_used_notify_split Date: Fri, 20 Nov 2020 19:50:44 +0100 Message-Id: <20201120185105.279030-7-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This function is just used for a few commits, so SW LM is developed incrementally, and it is deleted after it is useful. For a few commits, only the events (irqfd, eventfd) are forwarded. This series adds descriptors forwarding on top of that. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/virtio.h | 1 + hw/virtio/virtio.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b7ece7a6a8..b9b8497ea0 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -225,6 +225,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id); =20 void virtio_notify_config(VirtIODevice *vdev); =20 +bool virtio_queue_get_used_notify_split(VirtQueue *vq); bool virtio_queue_get_notification(VirtQueue *vq); void virtio_queue_set_notification(VirtQueue *vq, int enable); =20 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ceb58fda6c..3469946538 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -377,6 +377,20 @@ static inline void vring_used_idx_set(VirtQueue *vq, u= int16_t val) vq->used_idx =3D val; } =20 +bool virtio_queue_get_used_notify_split(VirtQueue *vq) +{ + VRingMemoryRegionCaches *caches; + hwaddr pa =3D offsetof(VRingUsed, flags); + uint16_t flags; + + RCU_READ_LOCK_GUARD(); + + caches =3D vring_get_region_caches(vq); + assert(caches); + flags =3D virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); + return !(VRING_USED_F_NO_NOTIFY & flags); +} + /* Called within rcu_read_lock(). */ static inline void vring_used_flags_set_bit(VirtQueue *vq, int mask) { --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899075; cv=none; d=zohomail.com; s=zohoarc; b=RZWJmbxt0fzeUDXSPE0PxLC5oomEC5XGV/JTSa3pVIhPO0Eboe6fHvbHGPbZTW3so2aXZ7JNUgsGkuYj2ZJpY2tkmdTE/D880a3OzN2tzYNr3P4UUJaI93UPz9HqWpX/OBWTxMgOhLFRfRxWIFVVpGSFwDzn6Vy9bgqw/XgTDM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899075; 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=PHs7w9gRWn5Mh5hB2N7v2usauab9QEU61xYfrhNJnDI=; b=lDH/089Ga3gIK613UJ5ixXaBBivlDckISbuMBRO6LLlN3wKMSoBrIjfiJaUaK+W0Lxd7lEVuXQ+XW76+z7ojG6L1izJW6nDFAJlh+LcRvDOqfpZ9rw+c1Hi7vlld2kTbyDINTfqzFbrqfwRWGPB5Hngl3KaziN0nh4S27ZaGD5U= 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+importer=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 1605899075851688.3060219394786; Fri, 20 Nov 2020 11:04:35 -0800 (PST) Received: from localhost ([::1]:58416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBhy-0007Vy-IX for importer@patchew.org; Fri, 20 Nov 2020 14:04:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBWr-00050M-7r for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBWh-0007Cn-0f for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:04 -0500 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-103-GxLlklPmNPC1LNXpQGTGGQ-1; Fri, 20 Nov 2020 13:52:51 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5249C5B36A; Fri, 20 Nov 2020 18:52:48 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1B785C1D5; Fri, 20 Nov 2020 18:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898374; 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=PHs7w9gRWn5Mh5hB2N7v2usauab9QEU61xYfrhNJnDI=; b=alqDTXGfrJTpNAPLNvDSicdLpX/hRZXQhDf46ZOg4dRtIngwveUWDTHWMcxEgSX0z9MSAr pfp+fMd/a/sWe3wUu4J0GwKHZionJ1gR3e9GAub1jx9ih+tQ5dracp0FB2yMbqTBCvgBx9 PqJ50GO99si1geZxZSPsV96jcCLR6O4= X-MC-Unique: GxLlklPmNPC1LNXpQGTGGQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 07/27] vhost: Route guest->host notification through qemu Date: Fri, 20 Nov 2020 19:50:45 +0100 Message-Id: <20201120185105.279030-8-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.h | 26 +++++++++ include/hw/virtio/vhost.h | 3 ++ hw/virtio/vhost-sw-lm-ring.c | 60 +++++++++++++++++++++ hw/virtio/vhost.c | 100 +++++++++++++++++++++++++++++++++-- hw/virtio/meson.build | 2 +- 5 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 hw/virtio/vhost-sw-lm-ring.h create mode 100644 hw/virtio/vhost-sw-lm-ring.c diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h new file mode 100644 index 0000000000..86dc081b93 --- /dev/null +++ b/hw/virtio/vhost-sw-lm-ring.h @@ -0,0 +1,26 @@ +/* + * vhost software live migration ring + * + * SPDX-FileCopyrightText: Red Hat, Inc. 2020 + * SPDX-FileContributor: Author: Eugenio P=C3=A9rez + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef VHOST_SW_LM_RING_H +#define VHOST_SW_LM_RING_H + +#include "qemu/osdep.h" + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" + +typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; + +bool vhost_vring_kick(VhostShadowVirtqueue *vq); + +VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost_dev *dev, int idx= ); + +void vhost_sw_lm_shadow_vq_free(VhostShadowVirtqueue *vq); + +#endif diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index b5b7496537..93cc3f1ae3 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -54,6 +54,8 @@ struct vhost_iommu { QLIST_ENTRY(vhost_iommu) iommu_next; }; =20 +typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; + typedef struct VhostDevConfigOps { /* Vhost device config space changed callback */ @@ -83,6 +85,7 @@ struct vhost_dev { bool started; bool log_enabled; uint64_t log_size; + VhostShadowVirtqueue *sw_lm_shadow_vq[2]; VirtIOHandleOutput sw_lm_vq_handler; Error *migration_blocker; const VhostOps *vhost_ops; diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c new file mode 100644 index 0000000000..0192e77831 --- /dev/null +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -0,0 +1,60 @@ +/* + * vhost software live migration ring + * + * SPDX-FileCopyrightText: Red Hat, Inc. 2020 + * SPDX-FileContributor: Author: Eugenio P=C3=A9rez + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "hw/virtio/vhost-sw-lm-ring.h" +#include "hw/virtio/vhost.h" + +#include "standard-headers/linux/vhost_types.h" +#include "standard-headers/linux/virtio_ring.h" + +#include "qemu/event_notifier.h" + +typedef struct VhostShadowVirtqueue { + EventNotifier hdev_notifier; + VirtQueue *vq; +} VhostShadowVirtqueue; + +static inline bool vhost_vring_should_kick(VhostShadowVirtqueue *vq) +{ + return virtio_queue_get_used_notify_split(vq->vq); +} + +bool vhost_vring_kick(VhostShadowVirtqueue *vq) +{ + return vhost_vring_should_kick(vq) ? event_notifier_set(&vq->hdev_noti= fier) + : true; +} + +VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost_dev *dev, int idx) +{ + struct vhost_vring_file file =3D { + .index =3D idx + }; + VirtQueue *vq =3D virtio_get_queue(dev->vdev, idx); + VhostShadowVirtqueue *svq; + int r; + + svq =3D g_new0(VhostShadowVirtqueue, 1); + svq->vq =3D vq; + + r =3D event_notifier_init(&svq->hdev_notifier, 0); + assert(r =3D=3D 0); + + file.fd =3D event_notifier_get_fd(&svq->hdev_notifier); + r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &file); + assert(r =3D=3D 0); + + return svq; +} + +void vhost_sw_lm_shadow_vq_free(VhostShadowVirtqueue *vq) +{ + event_notifier_cleanup(&vq->hdev_notifier); + g_free(vq); +} diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9cbd52a7f1..a55b684b5f 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -13,6 +13,8 @@ * GNU GPL, version 2 or (at your option) any later version. */ =20 +#include "hw/virtio/vhost-sw-lm-ring.h" + #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/virtio/vhost.h" @@ -61,6 +63,20 @@ bool vhost_has_free_slot(void) return slots_limit > used_memslots; } =20 +static struct vhost_dev *vhost_dev_from_virtio(const VirtIODevice *vdev) +{ + struct vhost_dev *hdev; + + QLIST_FOREACH(hdev, &vhost_devices, entry) { + if (hdev->vdev =3D=3D vdev) { + return hdev; + } + } + + assert(hdev); + return NULL; +} + static bool vhost_dev_can_log(const struct vhost_dev *hdev) { return hdev->features & (0x1ULL << VHOST_F_LOG_ALL); @@ -148,6 +164,12 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *d= ev, return 0; } =20 +static void vhost_log_sync_nop(MemoryListener *listener, + MemoryRegionSection *section) +{ + return; +} + static void vhost_log_sync(MemoryListener *listener, MemoryRegionSection *section) { @@ -928,6 +950,71 @@ static void vhost_log_global_stop(MemoryListener *list= ener) } } =20 +static void handle_sw_lm_vq(VirtIODevice *vdev, VirtQueue *vq) +{ + struct vhost_dev *hdev =3D vhost_dev_from_virtio(vdev); + uint16_t idx =3D virtio_get_queue_index(vq); + + VhostShadowVirtqueue *svq =3D hdev->sw_lm_shadow_vq[idx]; + + vhost_vring_kick(svq); +} + +static int vhost_sw_live_migration_stop(struct vhost_dev *dev) +{ + int idx; + + vhost_dev_enable_notifiers(dev, dev->vdev); + for (idx =3D 0; idx < dev->nvqs; ++idx) { + vhost_sw_lm_shadow_vq_free(dev->sw_lm_shadow_vq[idx]); + } + + return 0; +} + +static int vhost_sw_live_migration_start(struct vhost_dev *dev) +{ + int idx; + + for (idx =3D 0; idx < dev->nvqs; ++idx) { + dev->sw_lm_shadow_vq[idx] =3D vhost_sw_lm_shadow_vq(dev, idx); + } + + vhost_dev_disable_notifiers(dev, dev->vdev); + + return 0; +} + +static int vhost_sw_live_migration_enable(struct vhost_dev *dev, + bool enable_lm) +{ + if (enable_lm) { + return vhost_sw_live_migration_start(dev); + } else { + return vhost_sw_live_migration_stop(dev); + } +} + +static void vhost_sw_lm_global_start(MemoryListener *listener) +{ + int r; + + r =3D vhost_migration_log(listener, true, vhost_sw_live_migration_enab= le); + if (r < 0) { + abort(); + } +} + +static void vhost_sw_lm_global_stop(MemoryListener *listener) +{ + int r; + + r =3D vhost_migration_log(listener, false, vhost_sw_live_migration_ena= ble); + if (r < 0) { + abort(); + } +} + static void vhost_log_start(MemoryListener *listener, MemoryRegionSection *section, int old, int new) @@ -1334,9 +1421,14 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, .region_nop =3D vhost_region_addnop, .log_start =3D vhost_log_start, .log_stop =3D vhost_log_stop, - .log_sync =3D vhost_log_sync, - .log_global_start =3D vhost_log_global_start, - .log_global_stop =3D vhost_log_global_stop, + .log_sync =3D !vhost_dev_can_log(hdev) ? + vhost_log_sync_nop : + vhost_log_sync, + .log_global_start =3D !vhost_dev_can_log(hdev) ? + vhost_sw_lm_global_start : + vhost_log_global_start, + .log_global_stop =3D !vhost_dev_can_log(hdev) ? vhost_sw_lm_global= _stop : + vhost_log_global_sto= p, .eventfd_add =3D vhost_eventfd_add, .eventfd_del =3D vhost_eventfd_del, .priority =3D 10 @@ -1364,6 +1456,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, error_free(hdev->migration_blocker); goto fail_busyloop; } + } else { + hdev->sw_lm_vq_handler =3D handle_sw_lm_vq; } =20 hdev->mem =3D g_malloc0(offsetof(struct vhost_memory, regions)); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc9d4..17419cb13e 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -11,7 +11,7 @@ softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-= stub.c')) =20 virtio_ss =3D ss.source_set() virtio_ss.add(files('virtio.c')) -virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backe= nd.c')) +virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backe= nd.c', 'vhost-sw-lm-ring.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c')) virtio_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloo= n.c')) --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899397; cv=none; d=zohomail.com; s=zohoarc; b=kd156p+cIXcT+TRxuC5C0KdECSTucXLp7DTlMAydlOBgv320uq/geZGuDDoipDb+tLehWpX22xpFDrBcxFR/Mt7MzxyPTnfqoQ+NErMYBE+Eenzr27/QG2jqqqIyIYSanYfGB9fa7RWTOWSP4AteBLVnkkh7Vnj9y045s5hllI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899397; 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=Qu8CTJiydQcChlxQWTNmkAEwFHT33IJLluEvEtsX/ss=; b=hIDXXKI01HzP2h/Tlb+dBX4Y7155TEbEQp32zQ8XUOleSfroVng1dWGBP1+jAYPwn8tt7Tmivrk8ntGsAlb+0tk/EzXGyatjNpT9q0nUI+YhBsao4gt5ADhEU5E6RnyLUlmzg7yK6Bg/SRDigCJxJh/6WUy2Itm2MiqyBny2FW4= 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+importer=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 1605899397007830.3006748125434; Fri, 20 Nov 2020 11:09:57 -0800 (PST) Received: from localhost ([::1]:39880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBn7-0003HZ-UY for importer@patchew.org; Fri, 20 Nov 2020 14:09:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBX9-0005Ku-HW for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBWz-0007Gz-HC for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:20 -0500 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-458-_JNmgddUNyaRjjXM5pQgFA-1; Fri, 20 Nov 2020 13:53:10 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10C3C8797E8; Fri, 20 Nov 2020 18:53:08 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAD965C1D5; Fri, 20 Nov 2020 18:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898392; 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=Qu8CTJiydQcChlxQWTNmkAEwFHT33IJLluEvEtsX/ss=; b=X0UqFWHt5Y5UpnjR+b0lXwVdmCbdlm94xDVTuttICwnEHuseS3etSoJRxZ0qMMX/nhUPHG V9qfpmvprls5onSjJ+PajPwGl9lprPgYuz3aRhAnmIrBQ021BJr12pNFcPNN81eoYnZXDY MHxjGMuW9MyO5B31HkrAlvmwBtk1paA= X-MC-Unique: _JNmgddUNyaRjjXM5pQgFA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 08/27] vhost: Add a flag for software assisted Live Migration Date: Fri, 20 Nov 2020 19:50:46 +0100 Message-Id: <20201120185105.279030-9-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost.h | 1 + hw/virtio/vhost.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 93cc3f1ae3..ef920a8076 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -84,6 +84,7 @@ struct vhost_dev { uint64_t backend_cap; bool started; bool log_enabled; + bool sw_lm_enabled; uint64_t log_size; VhostShadowVirtqueue *sw_lm_shadow_vq[2]; VirtIOHandleOutput sw_lm_vq_handler; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a55b684b5f..1d55e26d45 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -988,11 +988,16 @@ static int vhost_sw_live_migration_start(struct vhost= _dev *dev) static int vhost_sw_live_migration_enable(struct vhost_dev *dev, bool enable_lm) { + int r; + if (enable_lm) { - return vhost_sw_live_migration_start(dev); + r =3D vhost_sw_live_migration_start(dev); } else { - return vhost_sw_live_migration_stop(dev); + r =3D vhost_sw_live_migration_stop(dev); } + + dev->sw_lm_enabled =3D enable_lm; + return r; } =20 static void vhost_sw_lm_global_start(MemoryListener *listener) @@ -1466,6 +1471,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, hdev->log =3D NULL; hdev->log_size =3D 0; hdev->log_enabled =3D false; + hdev->sw_lm_enabled =3D false; hdev->started =3D false; memory_listener_register(&hdev->memory_listener, &address_space_memory= ); QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); @@ -1571,6 +1577,13 @@ void vhost_dev_disable_notifiers(struct vhost_dev *h= dev, VirtIODevice *vdev) BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); int i, r; =20 + if (hdev->sw_lm_enabled) { + /* We've been called after migration is completed, so no need to + disable it again + */ + return; + } + for (i =3D 0; i < hdev->nvqs; ++i) { r =3D virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_inde= x + i, false); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899372; cv=none; d=zohomail.com; s=zohoarc; b=IM7io7EhjHSNEeGjHW3CPMxH6x5mfQ1fvqxaVxf7DKpwUpDScJKRtJ1XGDTxd2+4ZWs3rZU1fJupyIN1jbTq/RyC0hV9kJSZVw8yOVA6/2DbwK6HFmGcs4zs+2Zd4TTE59/gc2ToK6W8DEn2sUvgfngba4gkDKUEOVA0xYPaWgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899372; 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=u/Ojn4cpi7xAVMskNFT0feT7MkBDEW4NMg9WWPtVNhY=; b=UAAfKvLvyIihLFuYnkm9tZvJs/X6IKdaxen6Oq+fZRfpvi10JkUb//wPczybgimAfrkHQysI8PddeDcTbDdy1jSrR5/aHKphkH65URNv4UprcRrQARj/WkDpT2s3gZjcfw17ZuyxdrqNHeyyG9hkUmMrC1fY1PPC6xvoGWl8ERk= 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+importer=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 1605899372542600.7797632294477; Fri, 20 Nov 2020 11:09:32 -0800 (PST) Received: from localhost ([::1]:38756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBml-0002pS-Hg for importer@patchew.org; Fri, 20 Nov 2020 14:09:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBXP-0005P7-2r for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBXK-0007LJ-UH for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:38 -0500 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-281-syOVuANoOUy-jKfm_jOXDg-1; Fri, 20 Nov 2020 13:53:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EFBC8145E2; Fri, 20 Nov 2020 18:53:24 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66FD25C230; Fri, 20 Nov 2020 18:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898412; 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=u/Ojn4cpi7xAVMskNFT0feT7MkBDEW4NMg9WWPtVNhY=; b=ee8D6rCEOQJnungZiScW+nZ8NWam0KBxqbj8e9H5gFlvVZYB91Vjcawm+DMunipMmS3caQ R1mqqf1DH8YfDuY2Xbe13AY0zObcczSobLExm0bHLvl3FTPIEHFeXvNeG4FX8fBtHDFXDU s875UpWOvYwUGGkqwqftne4FcDneZ8Q= X-MC-Unique: syOVuANoOUy-jKfm_jOXDg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 09/27] vhost: Route host->guest notification through qemu Date: Fri, 20 Nov 2020 19:50:47 +0100 Message-Id: <20201120185105.279030-10-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.c | 3 +++ hw/virtio/vhost.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index 0192e77831..cbf53965cd 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -50,6 +50,9 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost_= dev *dev, int idx) r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &file); assert(r =3D=3D 0); =20 + vhost_virtqueue_mask(dev, dev->vdev, idx, true); + vhost_virtqueue_pending(dev, idx); + return svq; } =20 diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1d55e26d45..9352c56bfa 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -960,12 +960,29 @@ static void handle_sw_lm_vq(VirtIODevice *vdev, VirtQ= ueue *vq) vhost_vring_kick(svq); } =20 +static void vhost_handle_call(EventNotifier *n) +{ + struct vhost_virtqueue *hvq =3D container_of(n, + struct vhost_virtqueue, + masked_notifier); + struct vhost_dev *vdev =3D hvq->dev; + int idx =3D vdev->vq_index + (hvq =3D=3D &vdev->vqs[0] ? 0 : 1); + VirtQueue *vq =3D virtio_get_queue(vdev->vdev, idx); + + if (event_notifier_test_and_clear(n)) { + virtio_queue_invalidate_signalled_used(vdev->vdev, idx); + virtio_notify_irqfd(vdev->vdev, vq); + } +} + static int vhost_sw_live_migration_stop(struct vhost_dev *dev) { int idx; =20 vhost_dev_enable_notifiers(dev, dev->vdev); for (idx =3D 0; idx < dev->nvqs; ++idx) { + vhost_virtqueue_mask(dev, dev->vdev, idx, false); + vhost_virtqueue_pending(dev, idx); vhost_sw_lm_shadow_vq_free(dev->sw_lm_shadow_vq[idx]); } =20 @@ -977,7 +994,10 @@ static int vhost_sw_live_migration_start(struct vhost_= dev *dev) int idx; =20 for (idx =3D 0; idx < dev->nvqs; ++idx) { + struct vhost_virtqueue *vq =3D &dev->vqs[idx]; + dev->sw_lm_shadow_vq[idx] =3D vhost_sw_lm_shadow_vq(dev, idx); + event_notifier_set_handler(&vq->masked_notifier, vhost_handle_call= ); } =20 vhost_dev_disable_notifiers(dev, dev->vdev); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899598; cv=none; d=zohomail.com; s=zohoarc; b=aIn4YdAP4ku+m/05QcLF7V+T8lFXjXvqvJ/Rrf+aHpqw119GXQgatgMvXuM4Er2DxA0d7awziF8LrNUceelmgBILJZEGPyf/s0AsegWhX/nBSGQLaiWL2qRshzlbz3cdXQUvHNCUJmVdlbYjuV6K1FFbmx75pGqwpRCtWOuKmHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899598; 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=geMra6s2mk7qQGmiDf6FdjeAxAi7bQOlm3m+XgBp7eM=; b=nJ0FHjM0dH7fHye6FIh40HFrFV9g+DZYbpBcVdfeM57Y5mIeFrRYqw8RgpREFfYIWg6xoc0BsGgThbzIi8axCOjxRDYRj4oJka8bH8Z9fy1Y4JS6Rq8epUaO7tUyajmQgWMcj9V1ACrOX/eTXpYzOqR9uRMiJwgTfj5ZSMm21Zg= 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+importer=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 1605899598842647.0067729770035; Fri, 20 Nov 2020 11:13:18 -0800 (PST) Received: from localhost ([::1]:48284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBqP-0006sT-Po for importer@patchew.org; Fri, 20 Nov 2020 14:13:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBXW-0005Zd-T7 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28328) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBXV-0007Nc-16 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:53:46 -0500 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-307-O0I0LkrQMrGPImdL7SOirQ-1; Fri, 20 Nov 2020 13:53:39 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 437D1801AF1; Fri, 20 Nov 2020 18:53:36 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97F395C1D5; Fri, 20 Nov 2020 18:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898421; 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=geMra6s2mk7qQGmiDf6FdjeAxAi7bQOlm3m+XgBp7eM=; b=doo1gPHiehCgbvYbC7n4JtUOXU1SKlYIGsMxxgpX762R/iLEILbNqI9kjY8c1bgFiF4fwF +GzH2SO2oJVefAWUhL2bKcJa41ENAj9X6S8wlaLDNZGqlmz/lF8BJZa6C59HJ5wXKALvuT WGkO28UOlo2LVEU2ocwgD49aklphrBE= X-MC-Unique: O0I0LkrQMrGPImdL7SOirQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 10/27] vhost: Allocate shadow vring Date: Fri, 20 Nov 2020 19:50:48 +0100 Message-Id: <20201120185105.279030-11-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index cbf53965cd..cd7b5ba772 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -16,8 +16,11 @@ #include "qemu/event_notifier.h" =20 typedef struct VhostShadowVirtqueue { + struct vring vring; EventNotifier hdev_notifier; VirtQueue *vq; + + vring_desc_t descs[]; } VhostShadowVirtqueue; =20 static inline bool vhost_vring_should_kick(VhostShadowVirtqueue *vq) @@ -37,10 +40,12 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhos= t_dev *dev, int idx) .index =3D idx }; VirtQueue *vq =3D virtio_get_queue(dev->vdev, idx); + unsigned num =3D virtio_queue_get_num(dev->vdev, idx); + size_t ring_size =3D vring_size(num, VRING_DESC_ALIGN_SIZE); VhostShadowVirtqueue *svq; int r; =20 - svq =3D g_new0(VhostShadowVirtqueue, 1); + svq =3D g_malloc0(sizeof(*svq) + ring_size); svq->vq =3D vq; =20 r =3D event_notifier_init(&svq->hdev_notifier, 0); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898873; cv=none; d=zohomail.com; s=zohoarc; b=TMJAEz0KAeK7D/TuUaGvai6SAIM/IwbRVj4wiOZaelJ05XqBWachu8uILi8m48wdx2NeNwSzsvTE45H4K32C/afgAHaS4FDqYHr0DjfJ04bV10ttv6EUJwBIqWjatLpDrnDtJ0/l8AuXXRoicCZ6ErBLBYLZmiLrMG/ZHMHSZOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898873; 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=GYiokrtmxVGaxHYQFYtHrYcyj4QArcgChV2OGqAzahY=; b=ai08KTLHnbE8Mycsm7bUXlyxkRHo1PrN5bVuDNCYjvMIOQdvp0p/0UEGrBOXefjxWnIrRZLv1K4sUy3U8cWjOKHIFH7LdZHqsPkdvTYbHE43P7/4Z5rh5/k8EhL4Zq5pDHIeqdmncEnv8FUezK3os/Fn4TBstJ/zh6zv0qiObpM= 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+importer=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 1605898873494998.1090898853099; Fri, 20 Nov 2020 11:01:13 -0800 (PST) Received: from localhost ([::1]:49332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBeh-0003fa-Ss for importer@patchew.org; Fri, 20 Nov 2020 14:01:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBXn-0005s8-2N for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:54:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBXl-0007TF-1l for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:54:02 -0500 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-71-Q2QN0RgLOE-Z4tC5OIvHtg-1; Fri, 20 Nov 2020 13:53:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4232100C605; Fri, 20 Nov 2020 18:53:54 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 721AB5C1D5; Fri, 20 Nov 2020 18:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898440; 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=GYiokrtmxVGaxHYQFYtHrYcyj4QArcgChV2OGqAzahY=; b=Hc3ctVPSgydSURZY66CjMLPs0tM+la9i9XB0tRnsg+tZd0LGxS2DJ8bseaWfMCGmMtbasA qqB2jXefNJIIAJwlkoW1TWAn2VA22dpwYOPmnAiye3z+wB+0xhoitpJqj5fYywyeQrE2Ml HMSpUrJX2XCxIvKkraO3+Go1ub0Xsrw= X-MC-Unique: Q2QN0RgLOE-Z4tC5OIvHtg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 11/27] virtio: const-ify all virtio_tswap* functions Date: Fri, 20 Nov 2020 19:50:49 +0100 Message-Id: <20201120185105.279030-12-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) They do not modify vdev, so these should be const as qemu coding style guideline. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/virtio-access.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-a= ccess.h index 6818a23a2d..7474f89b5f 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -24,7 +24,7 @@ #define LEGACY_VIRTIO_IS_BIENDIAN 1 #endif =20 -static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) +static inline bool virtio_access_is_big_endian(const VirtIODevice *vdev) { #if defined(LEGACY_VIRTIO_IS_BIENDIAN) return virtio_is_big_endian(vdev); @@ -147,7 +147,7 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev,= const void *ptr) } } =20 -static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s) +static inline uint16_t virtio_tswap16(const VirtIODevice *vdev, uint16_t s) { #ifdef HOST_WORDS_BIGENDIAN return virtio_access_is_big_endian(vdev) ? s : bswap16(s); @@ -213,7 +213,7 @@ static inline void virtio_tswap16s(VirtIODevice *vdev, = uint16_t *s) *s =3D virtio_tswap16(vdev, *s); } =20 -static inline uint32_t virtio_tswap32(VirtIODevice *vdev, uint32_t s) +static inline uint32_t virtio_tswap32(const VirtIODevice *vdev, uint32_t s) { #ifdef HOST_WORDS_BIGENDIAN return virtio_access_is_big_endian(vdev) ? s : bswap32(s); @@ -227,7 +227,7 @@ static inline void virtio_tswap32s(VirtIODevice *vdev, = uint32_t *s) *s =3D virtio_tswap32(vdev, *s); } =20 -static inline uint64_t virtio_tswap64(VirtIODevice *vdev, uint64_t s) +static inline uint64_t virtio_tswap64(const VirtIODevice *vdev, uint64_t s) { #ifdef HOST_WORDS_BIGENDIAN return virtio_access_is_big_endian(vdev) ? s : bswap64(s); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899581; cv=none; d=zohomail.com; s=zohoarc; b=JWwDPhVO6CwZFR/TvYI0J7MLlrqZVXpTLMobC3ssgXjvcNt/yt0HaQ1Uxeqvw0iDxz7mJyk29xvoBQrfAXBIRz346gE02HCmUbg/WbsWFWXWaZTANEtCWiNRTuufd3B4YrmbGfyYinSj82tVBlwz8jOpZiEkYad6C89HkVgVwE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899581; 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=P54fNkbLFlDhwRYgmtpG8Llho8C34w4aU/D/fzEYMnA=; b=fqK+OTQyeQPrqtBEN3VfliIddDOcLe2NdZl0DV/h7L+eYP8E0aLkw1zMBI9YoeA+FwoAU+Rol3ZlMIrgVB0u+m+8UuN1MCX8nHpcU6GBzuFiTz2QSGfKzQPhp07vToi9IjUEXntjCh3YQKHIpBgtaenlIRB/WzXmwQ2imcwUuTQ= 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+importer=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 1605899581841602.4866963836132; Fri, 20 Nov 2020 11:13:01 -0800 (PST) Received: from localhost ([::1]:47122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBq8-0006M0-JE for importer@patchew.org; Fri, 20 Nov 2020 14:13:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBXz-00068k-U3 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:54:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBXx-0007WS-U4 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:54:15 -0500 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-547-Ibt8zbtuMPKnozMX7xzKtA-1; Fri, 20 Nov 2020 13:54:11 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 636981084423; Fri, 20 Nov 2020 18:54:08 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 375E35C1D5; Fri, 20 Nov 2020 18:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898453; 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=P54fNkbLFlDhwRYgmtpG8Llho8C34w4aU/D/fzEYMnA=; b=R5zHjq7tn3D7j+fjx8/YfqB+mxNQXtT7BN3NqhJ5BiyC/g2PaNPXjwsY8wx9gYI1zxkHCg Hp1qHrWio0wTkBF4cbHzqb0UBsSFTEDvJnVuXCNqn5X2BLxI2CwISqpfjon3sO/JkyF6HY YswnYeVOow6bjZEGaShk/zMMFUB88DU= X-MC-Unique: Ibt8zbtuMPKnozMX7xzKtA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 12/27] virtio: Add virtio_queue_full Date: Fri, 20 Nov 2020 19:50:50 +0100 Message-Id: <20201120185105.279030-13-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b9b8497ea0..0a7f5cc63e 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -233,6 +233,8 @@ int virtio_queue_ready(VirtQueue *vq); =20 int virtio_queue_empty(VirtQueue *vq); =20 +bool virtio_queue_full(const VirtQueue *vq); + /* Host binding interface. */ =20 uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3469946538..77ca5f6b6f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -684,6 +684,17 @@ int virtio_queue_empty(VirtQueue *vq) } } =20 +static bool virtio_queue_full_rcu(const VirtQueue *vq) +{ + return vq->inuse >=3D vq->vring.num; +} + +bool virtio_queue_full(const VirtQueue *vq) +{ + RCU_READ_LOCK_GUARD(); + return virtio_queue_full_rcu(vq); +} + static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len) { @@ -1453,7 +1464,7 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_= t sz) =20 max =3D vq->vring.num; =20 - if (vq->inuse >=3D vq->vring.num) { + if (unlikely(virtio_queue_full_rcu(vq))) { virtio_error(vdev, "Virtqueue size exceeded"); goto done; } @@ -1588,7 +1599,7 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size= _t sz) =20 max =3D vq->vring.num; =20 - if (vq->inuse >=3D vq->vring.num) { + if (unlikely(virtio_queue_full_rcu(vq))) { virtio_error(vdev, "Virtqueue size exceeded"); goto done; } --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605898981; cv=none; d=zohomail.com; s=zohoarc; b=lt6bOowSnygkCglQiXP3ufXCxfMZ6EsKBOxvgOljid4tsipgYu21d3WeNPdAvmguhCQyackXkVnu7JyJ1P0wFzxc3opaV2aYJtXqfvmAO1DAfSjXm3HFhjQIJfASkA5MVR+zEsmYK14KD9My+EpxtO0czsz6nst8JF1WrA78Wyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605898981; 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=DBP6ZYk56FcgCXgaWqpbvzcgYqNFQcFTrZnQ3USZwTQ=; b=Jb/BUk0yyPqkQ0fsitVpnCNnteVlmytUuz2BNlUDp6R21i6IpA3NxYVModlwjYsFA446J7mGjEYVioXfTKGWUuH+r8fBpS52zfWPkznQaLYXm+SORvUj2Wtr1Zv0WWG96sUwNnTh77/grOkZGkJ9tX8Ic8r9PKQugQol+DvIKbo= 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+importer=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 1605898981573888.5623527448606; Fri, 20 Nov 2020 11:03:01 -0800 (PST) Received: from localhost ([::1]:54460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBgS-0005tv-DR for importer@patchew.org; Fri, 20 Nov 2020 14:03:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBYM-0006Kb-H0 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:54:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBYJ-0007dN-O3 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:54:38 -0500 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-289-lEeqo5FhPaaoSZsN_h9FbQ-1; Fri, 20 Nov 2020 13:54:31 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64E8B184215F; Fri, 20 Nov 2020 18:54:28 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD0785C1D5; Fri, 20 Nov 2020 18:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898473; 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=DBP6ZYk56FcgCXgaWqpbvzcgYqNFQcFTrZnQ3USZwTQ=; b=QLgW7ThkHg9++LdDA7A4xuZD2t4QbDVsCdYuwFze2SH/swZU6G8R/G1TWnKiHokSKv/9IG b+Kk9KVzl/mYk+elhAaPzolgrWMmv/2eszT3QYuOVBKO4v2E52V+ygGve1jp9O3Bc+8hwk MV5sRFzn7gAZp4t/zRQKlQvR/4rZVAo= X-MC-Unique: lEeqo5FhPaaoSZsN_h9FbQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 13/27] vhost: Send buffers to device Date: Fri, 20 Nov 2020 19:50:51 +0100 Message-Id: <20201120185105.279030-14-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.h | 3 + hw/virtio/vhost-sw-lm-ring.c | 134 +++++++++++++++++++++++++++++++++-- hw/virtio/vhost.c | 59 ++++++++++++++- 3 files changed, 189 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h index 86dc081b93..29d21feaf4 100644 --- a/hw/virtio/vhost-sw-lm-ring.h +++ b/hw/virtio/vhost-sw-lm-ring.h @@ -18,6 +18,9 @@ typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; =20 bool vhost_vring_kick(VhostShadowVirtqueue *vq); +int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem); +void vhost_vring_write_addr(const VhostShadowVirtqueue *vq, + struct vhost_vring_addr *addr); =20 VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost_dev *dev, int idx= ); =20 diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index cd7b5ba772..aed005c2d9 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -9,6 +9,7 @@ =20 #include "hw/virtio/vhost-sw-lm-ring.h" #include "hw/virtio/vhost.h" +#include "hw/virtio/virtio-access.h" =20 #include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_ring.h" @@ -19,21 +20,140 @@ typedef struct VhostShadowVirtqueue { struct vring vring; EventNotifier hdev_notifier; VirtQueue *vq; + VirtIODevice *vdev; + + /* Map for returning guest's descriptors */ + VirtQueueElement **ring_id_maps; + + /* Next head to expose to device */ + uint16_t avail_idx_shadow; + + /* Number of descriptors added since last notification */ + uint16_t num_added; + + /* Next free descriptor */ + uint16_t free_head; =20 vring_desc_t descs[]; } VhostShadowVirtqueue; =20 -static inline bool vhost_vring_should_kick(VhostShadowVirtqueue *vq) +static bool vhost_vring_should_kick_rcu(VhostShadowVirtqueue *vq) { - return virtio_queue_get_used_notify_split(vq->vq); + VirtIODevice *vdev =3D vq->vdev; + vq->num_added =3D 0; + + smp_rmb(); + return !(vq->vring.used->flags + & virtio_tswap16(vdev, VRING_USED_F_NO_NOTIFY)); } =20 +static bool vhost_vring_should_kick(VhostShadowVirtqueue *vq) +{ + RCU_READ_LOCK_GUARD(); + return vhost_vring_should_kick_rcu(vq); +} + + bool vhost_vring_kick(VhostShadowVirtqueue *vq) { return vhost_vring_should_kick(vq) ? event_notifier_set(&vq->hdev_noti= fier) : true; } =20 +static void vhost_vring_write_descs(VhostShadowVirtqueue *vq, + const struct iovec *iovec, + size_t num, bool more_descs, bool writ= e) +{ + uint16_t i =3D vq->free_head, last =3D vq->free_head; + unsigned n; + const VirtIODevice *vdev =3D vq->vdev; + uint16_t flags =3D write ? virtio_tswap16(vdev, VRING_DESC_F_WRITE) : = 0; + vring_desc_t *descs =3D vq->vring.desc; + + if (num =3D=3D 0) { + return; + } + + for (n =3D 0; n < num; n++) { + if (more_descs || (n + 1 < num)) { + descs[i].flags =3D flags | virtio_tswap16(vdev, VRING_DESC_F_N= EXT); + } else { + descs[i].flags =3D flags; + } + descs[i].addr =3D virtio_tswap64(vdev, (hwaddr)iovec[n].iov_base); + descs[i].len =3D virtio_tswap32(vdev, iovec[n].iov_len); + + last =3D i; + i =3D virtio_tswap16(vdev, descs[i].next); + } + + vq->free_head =3D virtio_tswap16(vdev, descs[last].next); +} + +/* virtqueue_add: + * @vq: The #VirtQueue + * @elem: The #VirtQueueElement + * + * Add an avail element to a virtqueue. + */ +static int vhost_vring_add_split(VhostShadowVirtqueue *vq, + const VirtQueueElement *elem) +{ + int head; + unsigned avail_idx; + const VirtIODevice *vdev; + vring_avail_t *avail; + + RCU_READ_LOCK_GUARD(); + vdev =3D vq->vdev; + avail =3D vq->vring.avail; + + head =3D vq->free_head; + + /* We need some descriptors here */ + assert(elem->out_num || elem->in_num); + + vhost_vring_write_descs(vq, elem->out_sg, elem->out_num, + elem->in_num > 0, false); + vhost_vring_write_descs(vq, elem->in_sg, elem->in_num, false, true); + + /* Put entry in available array (but don't update avail->idx until they + * do sync). */ + avail_idx =3D vq->avail_idx_shadow & (vq->vring.num - 1); + avail->ring[avail_idx] =3D virtio_tswap16(vdev, head); + vq->avail_idx_shadow++; + + /* Expose descriptors to device */ + smp_wmb(); + avail->idx =3D virtio_tswap16(vdev, vq->avail_idx_shadow); + + /* threoretically possible. Kick just in case */ + if (unlikely(vq->num_added++ =3D=3D (uint16_t)-1)) { + vhost_vring_kick(vq); + } + + return head; +} + +int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem) +{ + int host_head =3D vhost_vring_add_split(vq, elem); + if (vq->ring_id_maps[host_head]) { + g_free(vq->ring_id_maps[host_head]); + } + + vq->ring_id_maps[host_head] =3D elem; + return 0; +} + +void vhost_vring_write_addr(const VhostShadowVirtqueue *vq, + struct vhost_vring_addr *addr) +{ + addr->desc_user_addr =3D (uint64_t)vq->vring.desc; + addr->avail_user_addr =3D (uint64_t)vq->vring.avail; + addr->used_user_addr =3D (uint64_t)vq->vring.used; +} + VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost_dev *dev, int idx) { struct vhost_vring_file file =3D { @@ -43,9 +163,11 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhos= t_dev *dev, int idx) unsigned num =3D virtio_queue_get_num(dev->vdev, idx); size_t ring_size =3D vring_size(num, VRING_DESC_ALIGN_SIZE); VhostShadowVirtqueue *svq; - int r; + int r, i; =20 svq =3D g_malloc0(sizeof(*svq) + ring_size); + svq->ring_id_maps =3D g_new0(VirtQueueElement *, num); + svq->vdev =3D dev->vdev; svq->vq =3D vq; =20 r =3D event_notifier_init(&svq->hdev_notifier, 0); @@ -55,8 +177,9 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost= _dev *dev, int idx) r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &file); assert(r =3D=3D 0); =20 - vhost_virtqueue_mask(dev, dev->vdev, idx, true); - vhost_virtqueue_pending(dev, idx); + vring_init(&svq->vring, num, svq->descs, VRING_DESC_ALIGN_SIZE); + for (i =3D 0; i < num - 1; i++) + svq->descs[i].next =3D virtio_tswap16(dev->vdev, i + 1); =20 return svq; } @@ -64,5 +187,6 @@ VhostShadowVirtqueue *vhost_sw_lm_shadow_vq(struct vhost= _dev *dev, int idx) void vhost_sw_lm_shadow_vq_free(VhostShadowVirtqueue *vq) { event_notifier_cleanup(&vq->hdev_notifier); + g_free(vq->ring_id_maps); g_free(vq); } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9352c56bfa..304e0baa61 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -956,8 +956,34 @@ static void handle_sw_lm_vq(VirtIODevice *vdev, VirtQu= eue *vq) uint16_t idx =3D virtio_get_queue_index(vq); =20 VhostShadowVirtqueue *svq =3D hdev->sw_lm_shadow_vq[idx]; + VirtQueueElement *elem; =20 - vhost_vring_kick(svq); + /* + * Make available all buffers as possible. + */ + do { + if (virtio_queue_get_notification(vq)) { + virtio_queue_set_notification(vq, false); + } + + while (true) { + int r; + if (virtio_queue_full(vq)) { + break; + } + + elem =3D virtqueue_pop(vq, sizeof(*elem)); + if (!elem) { + break; + } + + r =3D vhost_vring_add(svq, elem); + assert(r >=3D 0); + vhost_vring_kick(svq); + } + + virtio_queue_set_notification(vq, true); + } while(!virtio_queue_empty(vq)); } =20 static void vhost_handle_call(EventNotifier *n) @@ -975,6 +1001,11 @@ static void vhost_handle_call(EventNotifier *n) } } =20 +static void vhost_virtqueue_stop(struct vhost_dev *dev, + struct VirtIODevice *vdev, + struct vhost_virtqueue *vq, + unsigned idx); + static int vhost_sw_live_migration_stop(struct vhost_dev *dev) { int idx; @@ -991,17 +1022,41 @@ static int vhost_sw_live_migration_stop(struct vhost= _dev *dev) =20 static int vhost_sw_live_migration_start(struct vhost_dev *dev) { - int idx; + int idx, r; + + assert(dev->vhost_ops->vhost_set_vring_enable); + dev->vhost_ops->vhost_set_vring_enable(dev, false); =20 for (idx =3D 0; idx < dev->nvqs; ++idx) { struct vhost_virtqueue *vq =3D &dev->vqs[idx]; + struct vhost_vring_addr addr =3D { + .index =3D idx, + }; + struct vhost_vring_state s =3D { + .index =3D idx, + }; + + vhost_virtqueue_stop(dev, dev->vdev, &dev->vqs[idx], idx); =20 dev->sw_lm_shadow_vq[idx] =3D vhost_sw_lm_shadow_vq(dev, idx); event_notifier_set_handler(&vq->masked_notifier, vhost_handle_call= ); + + vhost_vring_write_addr(dev->sw_lm_shadow_vq[idx], &addr); + r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); + assert(r =3D=3D 0); + + r =3D dev->vhost_ops->vhost_set_vring_base(dev, &s); + assert(r =3D=3D 0); } =20 + dev->vhost_ops->vhost_set_vring_enable(dev, true); vhost_dev_disable_notifiers(dev, dev->vdev); =20 + for (idx =3D 0; idx < dev->nvqs; ++idx) { + vhost_virtqueue_mask(dev, dev->vdev, idx, true); + vhost_virtqueue_pending(dev, idx); + } + return 0; } =20 --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899831; cv=none; d=zohomail.com; s=zohoarc; b=h9BkypEubIlqZ1ponihAZuUJgqrQtYS2w4Mvya3aINidOpnpwcOODsGaRoeI+dlUl6nNs1ycZlcvAo50eJ0h15l0Rhj0VXq7VPgNg98zE/6peJodzG6Hk1EXlubuF2eit+dxuHLBFCXk1/ITLLIsoKsL20l3qHkQMz36nUP7kgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899831; 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=y9YecuAZNjK7boQsGuALrrDDzK7DqtNNTDUOzMBa16g=; b=bZkIAnCZpGrEltqSZ6+N/lLIucZikj9PA5zCiRvZLJGHj1zdI0s9eTAnkAN/Z51x/vmT+MppSEZiST00CdB10fuaOpHuKdaa4QQ93Flzp3SEt6XPgjUUHPAkEH6Fb9kLuqwhGjoppxVJ76j+4T1LHSUA3jMgZ4iPzPWrjAQY32Q= 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+importer=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 1605899831242972.4405980004386; Fri, 20 Nov 2020 11:17:11 -0800 (PST) Received: from localhost ([::1]:55580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBuA-0001TE-1b for importer@patchew.org; Fri, 20 Nov 2020 14:17:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBYl-0006eP-0w for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBYi-0007kA-VY for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:02 -0500 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-269-1Z2VrzOYN9q29U6WGS9-vA-1; Fri, 20 Nov 2020 13:54:52 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 027678030AD; Fri, 20 Nov 2020 18:54:49 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD2B65C1D5; Fri, 20 Nov 2020 18:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898494; 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=y9YecuAZNjK7boQsGuALrrDDzK7DqtNNTDUOzMBa16g=; b=OkILHZ1lh47KN9mPSEjMoZu7opIqgnGF2L9gMJCE62FitmNdeV9l4unHzIyiqxXNUS/rOc 0guRHbOrIAkwhHxyVyEqPD2aDhqqs9tGKR4gFrCG5dsDq4SeS6IjL5MNxOUd5IRs946sO2 bFuF1XjjIHunLqh9kWi0GBX1mWNP14o= X-MC-Unique: 1Z2VrzOYN9q29U6WGS9-vA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 14/27] virtio: Remove virtio_queue_get_used_notify_split Date: Fri, 20 Nov 2020 19:50:52 +0100 Message-Id: <20201120185105.279030-15-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) No more uses beyond this point Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/virtio.h | 1 - hw/virtio/virtio.c | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0a7f5cc63e..79212141a6 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -225,7 +225,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id); =20 void virtio_notify_config(VirtIODevice *vdev); =20 -bool virtio_queue_get_used_notify_split(VirtQueue *vq); bool virtio_queue_get_notification(VirtQueue *vq); void virtio_queue_set_notification(VirtQueue *vq, int enable); =20 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 77ca5f6b6f..ad9dc5dfa7 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -377,20 +377,6 @@ static inline void vring_used_idx_set(VirtQueue *vq, u= int16_t val) vq->used_idx =3D val; } =20 -bool virtio_queue_get_used_notify_split(VirtQueue *vq) -{ - VRingMemoryRegionCaches *caches; - hwaddr pa =3D offsetof(VRingUsed, flags); - uint16_t flags; - - RCU_READ_LOCK_GUARD(); - - caches =3D vring_get_region_caches(vq); - assert(caches); - flags =3D virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); - return !(VRING_USED_F_NO_NOTIFY & flags); -} - /* Called within rcu_read_lock(). */ static inline void vring_used_flags_set_bit(VirtQueue *vq, int mask) { --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899238; cv=none; d=zohomail.com; s=zohoarc; b=c7POK1NU8PkkB9nJ2ar9MtVM0XG8NGeDflvy2vbT7IcIx6HYnKIboPh6lh4u2UebVuLKQKQRWmOHHCeP+QwJo0DJkDIY+KDR6XMFtb4pQ6HQiLKDxZy6OU+hAbvXLQ97RSMTBK+epfLwxbH8ALw9NY3NSSrkCTXYfhM4PPUvvpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899238; 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=4wp9YwTYGJnUKm2v8rubzSiDU/VoJ3Bb1DJ/6lk+2es=; b=iWLvHhBXVtbi2cN1kmL4cax5fXcah6tLRNdtAdJ57Y6vENx4KX/+OM+GZGJOIjb3iRN+a3G5qxmAzxVjOzZwmIKeOie5pQ2P+QUwMPJJlivv8PLHEnDqP5+rxwDecDES5KF1WIV+lz3ykoqPJ9l7tByFp1OBCRkhhXQu5IfyCRc= 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+importer=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 1605899238877627.5572405267831; Fri, 20 Nov 2020 11:07:18 -0800 (PST) Received: from localhost ([::1]:34848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBkb-0001BF-KC for importer@patchew.org; Fri, 20 Nov 2020 14:07:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBYq-0006mj-4J for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBYn-0007mi-Vl for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:07 -0500 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-364-vhU3u-tTOGC90Zymqu4hTA-1; Fri, 20 Nov 2020 13:55:01 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 951ED8030AD; Fri, 20 Nov 2020 18:54:58 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7628E5C1D5; Fri, 20 Nov 2020 18:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898505; 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=4wp9YwTYGJnUKm2v8rubzSiDU/VoJ3Bb1DJ/6lk+2es=; b=OGwTUoY0ZbWHvLDtCRfDAfbzluKzXjFl+sTW/D3U57HC6gjuNIa59+ocRgwhUodCXxQNOI PeNkydEUr2mkKQV2k+PXNBTkL+CVQiRQE5oaAFCTLwGOMeL5Wt24Y0tpat1bgAjX+9SrG7 FSpfojOTUUnbCjoFmdg7M2MA94pdW4o= X-MC-Unique: vhU3u-tTOGC90Zymqu4hTA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 15/27] vhost: Do not invalidate signalled used Date: Fri, 20 Nov 2020 19:50:53 +0100 Message-Id: <20201120185105.279030-16-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Since we are in control of guest' VQ again, we can trust on it. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 304e0baa61..ac2bc14190 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -996,7 +996,6 @@ static void vhost_handle_call(EventNotifier *n) VirtQueue *vq =3D virtio_get_queue(vdev->vdev, idx); =20 if (event_notifier_test_and_clear(n)) { - virtio_queue_invalidate_signalled_used(vdev->vdev, idx); virtio_notify_irqfd(vdev->vdev, vq); } } --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899865; cv=none; d=zohomail.com; s=zohoarc; b=Jkf9jSLBinvTE1hHcHu1FlM3TUihMINOxU0z+XUz94LuB6pzyWR7jf3uwVNC21AI+1qWwfAn9P9C6FYkg7ExYNbMaX6bMj4T8bkv/1pjeSms4A3e2x3bTytg0GEVz1p6vwFHVOasTt9EQKDqc6VMG1tIZFsL6tu7lJMUYMvMu3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899865; 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=2NtO6niIGV95EKH2ITwzudVB3tBfrLrd6tahFyFqPtU=; b=BqcqR67ygFqDcEqGLYymK+WTbbi0gAuZvXZgkGQI7/ZyRC0UpWbFFROqKbV5x6awCnV8CCB6SJRbF1DAIncwO2MSZu1te6kos5L07Tmxkh4ZkPF4fqKKj9souk9nicE5p53+2mjB0rP02iJcJtzdJ1RzMaWOLh06Zd0IsJ1UFcs= 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+importer=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 160589986539374.18931497660094; Fri, 20 Nov 2020 11:17:45 -0800 (PST) Received: from localhost ([::1]:56638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBui-0001zU-4A for importer@patchew.org; Fri, 20 Nov 2020 14:17:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBZ2-0006rs-L2 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBZ0-0007sj-2S for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:20 -0500 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-540-zR19Dr3RMGSdd3PWouysKg-1; Fri, 20 Nov 2020 13:55:14 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE8D25B375; Fri, 20 Nov 2020 18:55:11 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0B3E5C1D5; Fri, 20 Nov 2020 18:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898517; 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=2NtO6niIGV95EKH2ITwzudVB3tBfrLrd6tahFyFqPtU=; b=QsFByzEME5Iqh723uJG8oIS89Qow2A6+5/3qLL1/jrNLFapK7+6KDYVIcPWicYT1V0V7WZ Lua+549CDpuldfbk7C6BDettL53ePUbwjyD12bZuyQV57yozyHIZdJGyp96W75SbHD4ILF zDtxy3EFEvWa7UCRTi+Try6B333FIs4= X-MC-Unique: zR19Dr3RMGSdd3PWouysKg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 16/27] virtio: Expose virtqueue_alloc_element Date: Fri, 20 Nov 2020 19:50:54 +0100 Message-Id: <20201120185105.279030-17-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Specify VirtQueueElement * as return type makes no harm at this moment. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 79212141a6..ee8fe96f32 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -196,6 +196,8 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueEleme= nt *elem, unsigned int len, unsigned int idx); =20 void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem); +VirtQueueElement *virtqueue_alloc_element(size_t sz, unsigned out_num, + unsigned in_num); void *virtqueue_pop(VirtQueue *vq, size_t sz); unsigned int virtqueue_drop_all(VirtQueue *vq); void *qemu_get_virtqueue_element(VirtIODevice *vdev, QEMUFile *f, size_t s= z); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ad9dc5dfa7..a89525f067 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1400,7 +1400,8 @@ void virtqueue_map(VirtIODevice *vdev, VirtQueueEleme= nt *elem) fa= lse); } =20 -static void *virtqueue_alloc_element(size_t sz, unsigned out_num, unsigned= in_num) +VirtQueueElement *virtqueue_alloc_element(size_t sz, unsigned out_num, + unsigned in_num) { VirtQueueElement *elem; size_t in_addr_ofs =3D QEMU_ALIGN_UP(sz, __alignof__(elem->in_addr[0])= ); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899328; cv=none; d=zohomail.com; s=zohoarc; b=Mnswo4Jj2Y5X7CJ+QrzHpMPK3pr09ArmDh5f1EMy4cFr6Dd1wPFcsvM6nyHJ05ElqG+f/0HKkLCqsClP1WgVY10m5TMqVBrzhOD7GeWhsgYjMlbAf0QIbIgjg4XH5FF2uGZ9LbzkkZSoAAGRwULF2/J5Fls+gDbYbWKvTk8NRk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899328; 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=0UHivzc6s/JNkkNVrXBKkPRfSO+gYprJIEU1Xp+Kgh8=; b=I7UquLpRxChnB080m6gIfTF8tCfnptb5Uh01yMc80QqLWt92H9ThlI4sb00EZ3/4i9B6veYRXBZdW7kZ/e5Yb4SM3vw1g9PlaShUSKDgMjCQJt7Wi8enRnpNJ70MdQKGcktBb0Xq95o7qpIN7y8W3anntTIZjCNiReVsvlh38Dc= 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+importer=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 1605899328070740.5775840347972; Fri, 20 Nov 2020 11:08:48 -0800 (PST) Received: from localhost ([::1]:37630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBm2-0002Ll-N7 for importer@patchew.org; Fri, 20 Nov 2020 14:08:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBZB-0006wp-Pu for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBZ9-0007y9-Pp for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:29 -0500 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-206-70ESR6YbNbOEQU5MD20vSA-1; Fri, 20 Nov 2020 13:55:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22C821842159; Fri, 20 Nov 2020 18:55:21 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 130455C1D5; Fri, 20 Nov 2020 18:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898525; 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=0UHivzc6s/JNkkNVrXBKkPRfSO+gYprJIEU1Xp+Kgh8=; b=QWM/Vy++egcDcQqlX7DvSZZ9zN/B01vUeA9siEzqXmD4oSyfg0OIFM0eQPocRTvzRNH8AZ fk6k555VehMjef3F16Y5BW7T2yxN3EOSRipU6LCDnNo2KGlTkaPGKrLCO/R8eNVzu6/M5E PLvVxoZhRX83SqhOB+wtHAmgq4NNTM4= X-MC-Unique: 70ESR6YbNbOEQU5MD20vSA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 17/27] vhost: add vhost_vring_set_notification_rcu Date: Fri, 20 Nov 2020 19:50:55 +0100 Message-Id: <20201120185105.279030-18-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.h | 4 ++++ hw/virtio/vhost-sw-lm-ring.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h index 29d21feaf4..c537500d9e 100644 --- a/hw/virtio/vhost-sw-lm-ring.h +++ b/hw/virtio/vhost-sw-lm-ring.h @@ -19,6 +19,10 @@ typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; =20 bool vhost_vring_kick(VhostShadowVirtqueue *vq); int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem); + +/* Called within rcu_read_lock(). */ +void vhost_vring_set_notification_rcu(VhostShadowVirtqueue *vq, bool enabl= e); + void vhost_vring_write_addr(const VhostShadowVirtqueue *vq, struct vhost_vring_addr *addr); =20 diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index aed005c2d9..c3244c550e 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -34,6 +34,9 @@ typedef struct VhostShadowVirtqueue { /* Next free descriptor */ uint16_t free_head; =20 + /* Cache for exposed notification flag */ + bool notification; + vring_desc_t descs[]; } VhostShadowVirtqueue; =20 @@ -60,6 +63,26 @@ bool vhost_vring_kick(VhostShadowVirtqueue *vq) : true; } =20 +void vhost_vring_set_notification_rcu(VhostShadowVirtqueue *vq, bool enabl= e) +{ + uint16_t notification_flag; + + if (vq->notification =3D=3D enable) { + return; + } + + notification_flag =3D virtio_tswap16(vq->vdev, VRING_AVAIL_F_NO_INTERR= UPT); + + vq->notification =3D enable; + if (enable) { + vq->vring.avail->flags &=3D ~notification_flag; + } else { + vq->vring.avail->flags |=3D notification_flag; + } + + smp_mb(); +} + static void vhost_vring_write_descs(VhostShadowVirtqueue *vq, const struct iovec *iovec, size_t num, bool more_descs, bool writ= e) --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899531; cv=none; d=zohomail.com; s=zohoarc; b=Npzhak/D+o1UsHsEcp8NfGeOfXXr1LnGTB2Ok369bbDl8AwjmGw7lxFiR5XlGtGBzKg3CSvREy0hK94YobgjRvG66EwnYv4uiJ91r1RLvA3O3nZLzAlHb0A2mzU+ughsdt6h94jBnhlFPKcabk3xyr/fSVUAE7Uss2eVeZfEijw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899531; 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=XrOQ1s9JEtCDaxgd6vNOOY/KU2hMoYwe0eOTlPEs1LA=; b=CGmh5mXS/1n0ejNS6naCkLVYn0HLESZQthBN6zfeDR90Nze6DwUxRhijo8p1IG4pTPh9CrLLRU+9A2RhmH8Xdfx5hY2jog8R8qUgWgklUghga74fij7RHMANEDxVwlFizfofKSDcXG07Q8L2wtP0jpju8Yu03umdqQkteYF1h7w= 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+importer=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 16058995315091011.9051409993756; Fri, 20 Nov 2020 11:12:11 -0800 (PST) Received: from localhost ([::1]:46016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBpI-0005us-3a for importer@patchew.org; Fri, 20 Nov 2020 14:12:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBZN-0007OC-2m for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBZL-000819-5T for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:40 -0500 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-539-3a8sTKaMN8eKwFoqmbXgCw-1; Fri, 20 Nov 2020 13:55:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF8875B365; Fri, 20 Nov 2020 18:55:30 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 798045C1D5; Fri, 20 Nov 2020 18:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898538; 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=XrOQ1s9JEtCDaxgd6vNOOY/KU2hMoYwe0eOTlPEs1LA=; b=XsfvQ946fvsuibV8/03b3I3UksPC3LDRzzL/LnPzHRJS45M8G+z7Sb28OWqmHET3iR5Dl/ U2Ddm3TcmEfThfGhPku1kRhbqM+tK9RQJw4+jj5HKTTzjuwScYEMdJ37UpxxarA5dPCauk RVGYEYDqrfRp21Nnycsscnu++Qj67BY= X-MC-Unique: 3a8sTKaMN8eKwFoqmbXgCw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 18/27] vhost: add vhost_vring_poll_rcu Date: Fri, 20 Nov 2020 19:50:56 +0100 Message-Id: <20201120185105.279030-19-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.h | 2 ++ hw/virtio/vhost-sw-lm-ring.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h index c537500d9e..03257d60c1 100644 --- a/hw/virtio/vhost-sw-lm-ring.h +++ b/hw/virtio/vhost-sw-lm-ring.h @@ -22,6 +22,8 @@ int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueEl= ement *elem); =20 /* Called within rcu_read_lock(). */ void vhost_vring_set_notification_rcu(VhostShadowVirtqueue *vq, bool enabl= e); +/* Called within rcu_read_lock(). */ +bool vhost_vring_poll_rcu(VhostShadowVirtqueue *vq); =20 void vhost_vring_write_addr(const VhostShadowVirtqueue *vq, struct vhost_vring_addr *addr); diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index c3244c550e..3652889d8e 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -34,6 +34,12 @@ typedef struct VhostShadowVirtqueue { /* Next free descriptor */ uint16_t free_head; =20 + /* Last seen used idx */ + uint16_t shadow_used_idx; + + /* Next head to consume from device */ + uint16_t used_idx; + /* Cache for exposed notification flag */ bool notification; =20 @@ -83,6 +89,18 @@ void vhost_vring_set_notification_rcu(VhostShadowVirtque= ue *vq, bool enable) smp_mb(); } =20 +bool vhost_vring_poll_rcu(VhostShadowVirtqueue *vq) +{ + if (vq->used_idx !=3D vq->shadow_used_idx) { + return true; + } + + smp_rmb(); + vq->shadow_used_idx =3D virtio_tswap16(vq->vdev, vq->vring.used->idx); + + return vq->used_idx !=3D vq->shadow_used_idx; +} + static void vhost_vring_write_descs(VhostShadowVirtqueue *vq, const struct iovec *iovec, size_t num, bool more_descs, bool writ= e) --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605900038; cv=none; d=zohomail.com; s=zohoarc; b=E3EEUz9I4F4mfToR+kfwEQJhiXFKDcFadLv2gkd97CsHzf12RofmTvkYMqhV6Tm+Ehs6CoGAaQU+aPZ9EbC4p9Sqz01FsYYfjFMRS374DSx0xkeg8WW9Csz03OVImvWuSluoOp97ewrAtETQGbKsJaLkA8hHAmesYCLsu/8pi7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605900038; 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=dZxEbXIS4zyXv2m5LGIw7P1HSVQ2S2HneDTGUSzuoD4=; b=Smo19rAVEePoJbOz1iUy+V17KNR5PgnPp4HwgzfrMvW1F76VGCRL9sv4bWOf5Ab+zvT4cnx6hKmZUitzNg/SFZc4LMmbkSHu7wDdwfzsxQ9m1MvN6+jgtq0f0eJqxPnyn0SSC1kRCXN00LxgOW1RzZISpufYhfLoyGehn4YMKHU= 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+importer=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 1605900038190726.0122264363945; Fri, 20 Nov 2020 11:20:38 -0800 (PST) Received: from localhost ([::1]:35738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBxU-00051z-6C for importer@patchew.org; Fri, 20 Nov 2020 14:20:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBZf-0007Rz-Bv for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBZY-00086K-Ud for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:55:59 -0500 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-84-TAvJhVXkPzytOL7DCgwuCw-1; Fri, 20 Nov 2020 13:55:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A68DA8030A3; Fri, 20 Nov 2020 18:55:43 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 146EB5C1D5; Fri, 20 Nov 2020 18:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898551; 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=dZxEbXIS4zyXv2m5LGIw7P1HSVQ2S2HneDTGUSzuoD4=; b=NeKpx8RDCXzDnVnnSzOwCMIQ8c7SFIOlDZcO5QZWV5zm63yJ5FhSfj5feU2fgi6M/unwvz 14kE38Y+iNbaK3/Mqvr6bAk3I9U+UHkSo6/AQGONa+p65hTvK4V+OTH9fiv6VNJy8JY6G2 zI8QWUER6F5hagsRF+QxPfeV+It9FBk= X-MC-Unique: TAvJhVXkPzytOL7DCgwuCw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 19/27] vhost: add vhost_vring_get_buf_rcu Date: Fri, 20 Nov 2020 19:50:57 +0100 Message-Id: <20201120185105.279030-20-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.h | 1 + hw/virtio/vhost-sw-lm-ring.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h index 03257d60c1..429a125558 100644 --- a/hw/virtio/vhost-sw-lm-ring.h +++ b/hw/virtio/vhost-sw-lm-ring.h @@ -19,6 +19,7 @@ typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; =20 bool vhost_vring_kick(VhostShadowVirtqueue *vq); int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem); +VirtQueueElement *vhost_vring_get_buf_rcu(VhostShadowVirtqueue *vq, size_t= sz); =20 /* Called within rcu_read_lock(). */ void vhost_vring_set_notification_rcu(VhostShadowVirtqueue *vq, bool enabl= e); diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index 3652889d8e..4fafd1b278 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -187,6 +187,35 @@ int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueu= eElement *elem) return 0; } =20 +VirtQueueElement *vhost_vring_get_buf_rcu(VhostShadowVirtqueue *vq, size_t= sz) +{ + const vring_used_t *used =3D vq->vring.used; + VirtQueueElement *ret; + vring_used_elem_t used_elem; + uint16_t last_used; + + if (!vhost_vring_poll_rcu(vq)) { + return NULL; + } + + last_used =3D vq->used_idx & (vq->vring.num - 1); + used_elem.id =3D virtio_tswap32(vq->vdev, used->ring[last_used].id); + used_elem.len =3D virtio_tswap32(vq->vdev, used->ring[last_used].len); + + if (unlikely(used_elem.id >=3D vq->vring.num)) { + virtio_error(vq->vdev, "Device says index %u is available", + used_elem.id); + return NULL; + } + + ret =3D vq->ring_id_maps[used_elem.id]; + ret->len =3D used_elem.len; + + vq->used_idx++; + + return ret; +} + void vhost_vring_write_addr(const VhostShadowVirtqueue *vq, struct vhost_vring_addr *addr) { --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899483; cv=none; d=zohomail.com; s=zohoarc; b=bmtY0L9k6XoP8lH8Ivqi6N46ixmrgtcHuNmJ64y+jNL0A6Q7k3KjzSf1prLtf/U8c+h9O01nlxuZ9aZGE4FQxEmFkrc8h0xqjqz6ZUYAOgi8OfwXC96upmkBwtHJsuSESywcClTkx1z64R9goLqLfXwApgs3z696Cis8iJZxuB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899483; 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=DG7n1lY/Hiobxg4WLGYVhL1ajHj2aBFA91adPYMLFP4=; b=avHyVNql9WBMtgOkKHle4Gsj90xkHKwDRDcDFeCHk6f087xHUQXfp8Pzc1VCBIykpw7DVD3RfYMKYcsySszXZCibgOwfmvgiYWXqwJ8Lv2QAYBl/+ZsuQiqtkG142D6aLkZL/bCNYUlnJlbOsOqisYobTdF2AOFiq7Clh3HFm8w= 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+importer=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 1605899483564933.7913840170459; Fri, 20 Nov 2020 11:11:23 -0800 (PST) Received: from localhost ([::1]:43284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBoY-0004oR-AB for importer@patchew.org; Fri, 20 Nov 2020 14:11:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBZj-0007T8-Hy for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBZf-0008AU-3R for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:03 -0500 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-506-twp43SyfNR6F-fyrLqtTQA-1; Fri, 20 Nov 2020 13:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7487C801B1E; Fri, 20 Nov 2020 18:55:53 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B4585C1D5; Fri, 20 Nov 2020 18:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898558; 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=DG7n1lY/Hiobxg4WLGYVhL1ajHj2aBFA91adPYMLFP4=; b=Jf3rZABflxeqCx7FJNgc2aQRYnAU+aKiQMk1twWs7rjkO6fv2SYsCOQD/F7lp0r172BBEM BLrxzUjuoqMeZKNykZFQfDXqFsdFjCnz9okuxdZOykx1DycxTTSLunRhF2uMoNi1yBbx4f OSwgFPFbtbITSKxMhx9gaCWggpFusgA= X-MC-Unique: twp43SyfNR6F-fyrLqtTQA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 20/27] vhost: Return used buffers Date: Fri, 20 Nov 2020 19:50:58 +0100 Message-Id: <20201120185105.279030-21-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-sw-lm-ring.h | 3 +++ hw/virtio/vhost-sw-lm-ring.c | 14 +++++++---- hw/virtio/vhost.c | 46 +++++++++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-sw-lm-ring.h b/hw/virtio/vhost-sw-lm-ring.h index 429a125558..0c4fa772c7 100644 --- a/hw/virtio/vhost-sw-lm-ring.h +++ b/hw/virtio/vhost-sw-lm-ring.h @@ -17,6 +17,9 @@ =20 typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; =20 +VirtIODevice *vhost_vring_vdev(VhostShadowVirtqueue *svq); +VirtQueue *vhost_vring_vdev_vq(VhostShadowVirtqueue *svq); + bool vhost_vring_kick(VhostShadowVirtqueue *vq); int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem); VirtQueueElement *vhost_vring_get_buf_rcu(VhostShadowVirtqueue *vq, size_t= sz); diff --git a/hw/virtio/vhost-sw-lm-ring.c b/hw/virtio/vhost-sw-lm-ring.c index 4fafd1b278..244c722910 100644 --- a/hw/virtio/vhost-sw-lm-ring.c +++ b/hw/virtio/vhost-sw-lm-ring.c @@ -46,6 +46,16 @@ typedef struct VhostShadowVirtqueue { vring_desc_t descs[]; } VhostShadowVirtqueue; =20 +VirtIODevice *vhost_vring_vdev(VhostShadowVirtqueue *svq) +{ + return svq->vdev; +} + +VirtQueue *vhost_vring_vdev_vq(VhostShadowVirtqueue *svq) +{ + return svq->vq; +} + static bool vhost_vring_should_kick_rcu(VhostShadowVirtqueue *vq) { VirtIODevice *vdev =3D vq->vdev; @@ -179,10 +189,6 @@ static int vhost_vring_add_split(VhostShadowVirtqueue = *vq, int vhost_vring_add(VhostShadowVirtqueue *vq, VirtQueueElement *elem) { int host_head =3D vhost_vring_add_split(vq, elem); - if (vq->ring_id_maps[host_head]) { - g_free(vq->ring_id_maps[host_head]); - } - vq->ring_id_maps[host_head] =3D elem; return 0; } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index ac2bc14190..9a3c580dcf 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -986,17 +986,50 @@ static void handle_sw_lm_vq(VirtIODevice *vdev, VirtQ= ueue *vq) } while(!virtio_queue_empty(vq)); } =20 +static void handle_sw_lm_vq_call(struct vhost_dev *hdev, + VhostShadowVirtqueue *svq) +{ + VirtQueueElement *elem; + VirtIODevice *vdev =3D vhost_vring_vdev(svq); + VirtQueue *vq =3D vhost_vring_vdev_vq(svq); + uint16_t idx =3D virtio_get_queue_index(vq); + + RCU_READ_LOCK_GUARD(); + /* + * Make used all buffers as possible. + */ + do { + unsigned i =3D 0; + + vhost_vring_set_notification_rcu(svq, false); + while (true) { + elem =3D vhost_vring_get_buf_rcu(svq, sizeof(*elem)); + if (!elem) { + break; + } + + assert(i < virtio_queue_get_num(vdev, idx)); + virtqueue_fill(vq, elem, elem->len, i++); + } + + virtqueue_flush(vq, i); + virtio_notify_irqfd(vdev, vq); + + vhost_vring_set_notification_rcu(svq, true); + } while (vhost_vring_poll_rcu(svq)); +} + static void vhost_handle_call(EventNotifier *n) { struct vhost_virtqueue *hvq =3D container_of(n, struct vhost_virtqueue, masked_notifier); struct vhost_dev *vdev =3D hvq->dev; - int idx =3D vdev->vq_index + (hvq =3D=3D &vdev->vqs[0] ? 0 : 1); - VirtQueue *vq =3D virtio_get_queue(vdev->vdev, idx); + int idx =3D hvq =3D=3D &vdev->vqs[0] ? 0 : 1; + VhostShadowVirtqueue *vq =3D vdev->sw_lm_shadow_vq[idx]; =20 if (event_notifier_test_and_clear(n)) { - virtio_notify_irqfd(vdev->vdev, vq); + handle_sw_lm_vq_call(vdev, vq); } } =20 @@ -1028,6 +1061,7 @@ static int vhost_sw_live_migration_start(struct vhost= _dev *dev) =20 for (idx =3D 0; idx < dev->nvqs; ++idx) { struct vhost_virtqueue *vq =3D &dev->vqs[idx]; + unsigned num =3D virtio_queue_get_num(dev->vdev, idx); struct vhost_vring_addr addr =3D { .index =3D idx, }; @@ -1044,6 +1078,12 @@ static int vhost_sw_live_migration_start(struct vhos= t_dev *dev) r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); assert(r =3D=3D 0); =20 + r =3D vhost_backend_update_device_iotlb(dev, addr.used_user_addr, + addr.used_user_addr, + sizeof(vring_used_elem_t) * = num, + IOMMU_RW); + assert(r =3D=3D 0); + r =3D dev->vhost_ops->vhost_set_vring_base(dev, &s); assert(r =3D=3D 0); } --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899680; cv=none; d=zohomail.com; s=zohoarc; b=muYqat//VwmLc+tLeiXQs7mv0R86SoC5z8BYfoBUFQSmcuUJz78Vbi5AYAyIt+Bu6292WE8iXLYATfUjZnShZwfQGwA0bRH8sYK+KT8tzrDmGaht+JtXUAxeorr3seqjCfqIV1bCeoif5HhxFgFb5Ej+qwQcYLUdGbpa9xIq/Tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899680; 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=VvYPxnElcsRqPRB3x32KT+7TZhu7baplHklcHyJ3ntU=; b=XeXFYoIU7r4G0uoF0N7QjTeuaFw3IxjjFkXqGUW4teeinyF44CdrQe38+0PEXEZf7/bJkicBHZPfA3QceeOZuRLZh/lZ28Ov3q3i4Cu01RioVNRwGaQtiRFX6YXqZS1ojY7lBm8zmZsNWDNUy9zYZ914A/cUkBDte9J9IrhQfyM= 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+importer=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 16058996808843.982001752639917; Fri, 20 Nov 2020 11:14:40 -0800 (PST) Received: from localhost ([::1]:51636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBrj-0008Ee-Jo for importer@patchew.org; Fri, 20 Nov 2020 14:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBa1-0007n2-9T for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBZz-0008Ez-3z for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:21 -0500 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-387-mtyRzA7kNwS9vj-lQSG9zQ-1; Fri, 20 Nov 2020 13:56:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1189184215D; Fri, 20 Nov 2020 18:56:11 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB6785C1D5; Fri, 20 Nov 2020 18:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898576; 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=VvYPxnElcsRqPRB3x32KT+7TZhu7baplHklcHyJ3ntU=; b=R5jQwOePsG/Z9alAQ1wSiuAFdyiu+2yRgf6WdWIHTHD/g/KoroWA2G1DQbKKvzizQH8EjF qn855O5M4BR9c6Me9gOj8V0kbgfH4Js+EMhEHX71bNyhdrcREVd5l27qMj5348uo+ZHIVe VBn8feger9GZbOYDMxoj1b6QgFwKkWA= X-MC-Unique: mtyRzA7kNwS9vj-lQSG9zQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 21/27] vhost: Add vhost_virtqueue_memory_unmap Date: Fri, 20 Nov 2020 19:50:59 +0100 Message-Id: <20201120185105.279030-22-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is not a huge gain but helps in later changes. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9a3c580dcf..eafbbaa751 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -812,6 +812,21 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *= dev, return 0; } =20 +static void vhost_virtqueue_memory_unmap(struct vhost_dev *dev, + struct vhost_virtqueue *vq, + bool used_is_dirty) +{ + if (vq->used) { + vhost_memory_unmap(dev, vq->used, vq->used_size, used_is_dirty, 0); + } + if (vq->avail) { + vhost_memory_unmap(dev, vq->avail, vq->avail_size, 0, 0); + } + if (vq->desc) { + vhost_memory_unmap(dev, vq->desc, vq->desc_size, 0, 0); + } +} + static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) { @@ -1301,21 +1316,21 @@ static int vhost_virtqueue_start(struct vhost_dev *= dev, vq->desc =3D vhost_memory_map(dev, a, &l, false); if (!vq->desc || l !=3D s) { r =3D -ENOMEM; - goto fail_alloc_desc; + goto fail_alloc; } vq->avail_size =3D s =3D l =3D virtio_queue_get_avail_size(vdev, idx); vq->avail_phys =3D a =3D virtio_queue_get_avail_addr(vdev, idx); vq->avail =3D vhost_memory_map(dev, a, &l, false); if (!vq->avail || l !=3D s) { r =3D -ENOMEM; - goto fail_alloc_avail; + goto fail_alloc; } vq->used_size =3D s =3D l =3D virtio_queue_get_used_size(vdev, idx); vq->used_phys =3D a =3D virtio_queue_get_used_addr(vdev, idx); vq->used =3D vhost_memory_map(dev, a, &l, true); if (!vq->used || l !=3D s) { r =3D -ENOMEM; - goto fail_alloc_used; + goto fail_alloc; } =20 r =3D vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabl= ed); @@ -1358,15 +1373,7 @@ static int vhost_virtqueue_start(struct vhost_dev *d= ev, fail_vector: fail_kick: fail_alloc: - vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx= ), - 0, 0); -fail_alloc_used: - vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, i= dx), - 0, 0); -fail_alloc_avail: - vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx= ), - 0, 0); -fail_alloc_desc: + vhost_virtqueue_memory_unmap(dev, vq, false); return r; } =20 @@ -1408,12 +1415,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *d= ev, vhost_vq_index); } =20 - vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx= ), - 1, virtio_queue_get_used_size(vdev, idx)); - vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, i= dx), - 0, virtio_queue_get_avail_size(vdev, idx)); - vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx= ), - 0, virtio_queue_get_desc_size(vdev, idx)); + vhost_virtqueue_memory_unmap(dev, vq, true); } =20 static void vhost_eventfd_add(MemoryListener *listener, --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899936; cv=none; d=zohomail.com; s=zohoarc; b=DDRgfi5du7+dH9r76Q2nAykrS7JziZAc3IF4wpwBMYvQtJ6TGwhhLeFtr9BJbm7dy5Ue3vhNqREj3kUXRIo66DJdaBjZCWDBjjnSs+j5pPTSNPb72jRR4o2Uk6EsThImuEtdgB24wya14mm+SJxUY2lMfRxiHfergqXqCUpaa18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899936; 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=PTSVtxwsFfunaFRmsiJCHQSu2dQDXIap/g3V71hKaPI=; b=GT2Sw4bW++/oO+9YpADEEwlg86oupAKZYWJiW0JXJbwZ7K5a4/tX9JaL+AX3IfjlgzvN+UPXX99RXDnRPqZAPxeP2tU5amTGVVUCSQ08lv5ZFShD2UK+ixX6KG8im1N6w7Eos93OAmWmD7xplBRoLkcrFaClOcI9jmFYt3SUZXw= 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+importer=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 1605899936571732.8912083543094; Fri, 20 Nov 2020 11:18:56 -0800 (PST) Received: from localhost ([::1]:60050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBvq-0003Pj-4u for importer@patchew.org; Fri, 20 Nov 2020 14:18:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBaQ-00086G-Dd for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBaL-0008MG-Q4 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:56:46 -0500 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-370-xXhwUuTlODSMizKH-YZFMg-1; Fri, 20 Nov 2020 13:56:39 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4524A100C602; Fri, 20 Nov 2020 18:56:36 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A8FF5C1D5; Fri, 20 Nov 2020 18:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898600; 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=PTSVtxwsFfunaFRmsiJCHQSu2dQDXIap/g3V71hKaPI=; b=F9nhvc2IVK05wD3qnCCiNscMOhWYcpb0TqxjNLq+M9/9ZU89g0t597IdbfqkPYy8yGFsyT tsdcm0mEMFJGpw7Ec6mEUT1419A6b25NbefMPitsCxUheD/Hbbjv7kIwuyIHw3Gq5CEla+ j19CGEmZA4/V/olEg0ty3owPsT1Il0Q= X-MC-Unique: xXhwUuTlODSMizKH-YZFMg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 22/27] vhost: Add vhost_virtqueue_memory_map Date: Fri, 20 Nov 2020 19:51:00 +0100 Message-Id: <20201120185105.279030-23-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) To make it symmetric with _unmap. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 68 ++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index eafbbaa751..f640d4edf0 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -827,6 +827,42 @@ static void vhost_virtqueue_memory_unmap(struct vhost_= dev *dev, } } =20 +static int vhost_virtqueue_memory_map(struct vhost_dev *dev, + struct vhost_virtqueue *vq, + unsigned int vhost_vq_index) +{ + int r; + hwaddr a, l, s; + + a =3D vq->desc_phys; + s =3D l =3D vq->desc_size; + vq->desc =3D vhost_memory_map(dev, a, &l, false); + if (!vq->desc || l !=3D s) { + return -ENOMEM; + } + + a =3D vq->avail_phys; + s =3D l =3D vq->avail_size; + vq->avail =3D vhost_memory_map(dev, a, &l, false); + if (!vq->avail || l !=3D s) { + return -ENOMEM; + } + + a =3D vq->used_phys; + s =3D l =3D vq->used_size; + vq->used =3D vhost_memory_map(dev, a, &l, true); + if (!vq->used || l !=3D s) { + return -ENOMEM; + } + + r =3D vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabl= ed); + if (r < 0) { + return -errno; + } + + return 0; +} + static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) { @@ -1271,7 +1307,7 @@ static int vhost_virtqueue_start(struct vhost_dev *de= v, BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusState *vbus =3D VIRTIO_BUS(qbus); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); - hwaddr s, l, a; + hwaddr a; int r; int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_file file =3D { @@ -1311,31 +1347,15 @@ static int vhost_virtqueue_start(struct vhost_dev *= dev, } } =20 - vq->desc_size =3D s =3D l =3D virtio_queue_get_desc_size(vdev, idx); + vq->desc_size =3D virtio_queue_get_desc_size(vdev, idx); vq->desc_phys =3D a; - vq->desc =3D vhost_memory_map(dev, a, &l, false); - if (!vq->desc || l !=3D s) { - r =3D -ENOMEM; - goto fail_alloc; - } - vq->avail_size =3D s =3D l =3D virtio_queue_get_avail_size(vdev, idx); - vq->avail_phys =3D a =3D virtio_queue_get_avail_addr(vdev, idx); - vq->avail =3D vhost_memory_map(dev, a, &l, false); - if (!vq->avail || l !=3D s) { - r =3D -ENOMEM; - goto fail_alloc; - } - vq->used_size =3D s =3D l =3D virtio_queue_get_used_size(vdev, idx); - vq->used_phys =3D a =3D virtio_queue_get_used_addr(vdev, idx); - vq->used =3D vhost_memory_map(dev, a, &l, true); - if (!vq->used || l !=3D s) { - r =3D -ENOMEM; - goto fail_alloc; - } + vq->avail_size =3D virtio_queue_get_avail_size(vdev, idx); + vq->avail_phys =3D virtio_queue_get_avail_addr(vdev, idx); + vq->used_size =3D virtio_queue_get_used_size(vdev, idx); + vq->used_phys =3D virtio_queue_get_used_addr(vdev, idx); =20 - r =3D vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabl= ed); - if (r < 0) { - r =3D -errno; + r =3D vhost_virtqueue_memory_map(dev, vq, vhost_vq_index); + if (r) { goto fail_alloc; } =20 --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605900160; cv=none; d=zohomail.com; s=zohoarc; b=Zeag7GQtGdGOgai9wlnJudBj0OzWmSpJYQEyQ5ysvojhBlgNTj/Xqq4cFyXhIui/jbJWd09exGBxPF+kQMpglRHf6D8VyrfG7hWJYwi/v6OrByQxQ1DX7iBZnsfi0PCxguXp6Dpr5y2OQ+hfQj3ejTUGLVVZ6TOUvoCAijZjhkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605900160; 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=CrZ8HzqKH9jvP8Zbz9rlbrynGHpm+xBKQyRidhhC+ks=; b=GpL42rKzvkWj+Owco68ulQXau2cc2jGfxEewRm0wfI2ooZSquOPQiTlSvCrQONajeECJF9QTQLcqUCcjrfdNWhWVF6mnDIIj5brrML5Vu8To5/qTdS8KDpXFovNa5l958rIoXXvCe552p/Y0F8MgXm+AyxYBAyM152IhRAQABuY= 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+importer=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 1605900160640882.6528087579965; Fri, 20 Nov 2020 11:22:40 -0800 (PST) Received: from localhost ([::1]:40134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBzT-0006vH-Dt for importer@patchew.org; Fri, 20 Nov 2020 14:22:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBam-0008Cl-BL for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBaj-0008Qe-Ro for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:08 -0500 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-160-Fp2Ve2KaObiDeZeZtu8-8A-1; Fri, 20 Nov 2020 13:57:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5123B10059A4; Fri, 20 Nov 2020 18:56:58 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FE645C1D5; Fri, 20 Nov 2020 18:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898622; 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=CrZ8HzqKH9jvP8Zbz9rlbrynGHpm+xBKQyRidhhC+ks=; b=JODFRAB5AGFUsX6SEnxeUozM0HOQzKVxDixChQuzJZX5zk5ukmdEr/VjOXafDSMY6UbqTW 3qOf+Zht98YDcncGML6Q1tApaRmOJ9qK5hFVR6knNlb2GVugWv6810U3RLbJd53XIF3ExL fJ/w5hOmT41UJrQ2GR0/Ylp+WP+dgeM= X-MC-Unique: Fp2Ve2KaObiDeZeZtu8-8A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 23/27] vhost: unmap qemu's shadow virtqueues on sw live migration Date: Fri, 20 Nov 2020 19:51:01 +0100 Message-Id: <20201120185105.279030-24-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Since vhost does not need to access it, it has no sense to keep it mapped. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f640d4edf0..eebfac4455 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1124,6 +1124,7 @@ static int vhost_sw_live_migration_start(struct vhost= _dev *dev) =20 dev->sw_lm_shadow_vq[idx] =3D vhost_sw_lm_shadow_vq(dev, idx); event_notifier_set_handler(&vq->masked_notifier, vhost_handle_call= ); + vhost_virtqueue_memory_unmap(dev, &dev->vqs[idx], true); =20 vhost_vring_write_addr(dev->sw_lm_shadow_vq[idx], &addr); r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605900319; cv=none; d=zohomail.com; s=zohoarc; b=aEAf3gJc6jVN5Z92oj+064KjMHEbwBQ6InazWcsaVoegeD75JrI0TXasBy+xRIkLhGOiqrsloxb3R8QJTm2V12XKW6Wi3FP8RUIlDYisV8DVqtB/Nlq3m0IEhgK/XJAa4t5u59iBwNqdGMLdLF5qK3b+Ram40Cf7xXxzisHtkGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605900319; 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=ryEh3kyaXHqK19Bj8UjCon+CnIrYqmewzumtOEVqPsQ=; b=XWTiV/ROYfBdrOyHofsXTAPMJpCJrr2/dTsHcEtvyryImj/NBLFzUUVKj5kgEe2NAc8QiSN1Bp5MWsl7gBwMyPOyzs8IJJiu0DiYDLluU46QuZJeFUhr2Q1ofcCxwn2C9bYHLRpFjJhJEiTAgytvRrP5YDtwT1DUkyr3lPGhpAc= 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+importer=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 1605900319646378.53789246026315; Fri, 20 Nov 2020 11:25:19 -0800 (PST) Received: from localhost ([::1]:46372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgC20-00015z-9q for importer@patchew.org; Fri, 20 Nov 2020 14:25:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBb0-0008QI-Dy for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBay-0008UI-OS for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:22 -0500 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-434-OefOQcNqNjmjp4PHqy7Kmg-1; Fri, 20 Nov 2020 13:57:17 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F365B1084425; Fri, 20 Nov 2020 18:57:13 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id A90BD5C1D5; Fri, 20 Nov 2020 18:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898640; 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=ryEh3kyaXHqK19Bj8UjCon+CnIrYqmewzumtOEVqPsQ=; b=H3kjDMtdWUV1rYRruexbHqgbOsphrs5gegTpkCA3jDr9UmI6h+46lQ92aUxSZUBHC0dcJo iHhDngJ1Dir6s//vijMeZv7dk5tVxZkFDznyWOElxVVACCTGQ8qyXPov8pzVF5Z3BWf9vJ yusqNHEhxwHGpEPZYJebk5PK0m6wJ54= X-MC-Unique: OefOQcNqNjmjp4PHqy7Kmg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 24/27] vhost: iommu changes Date: Fri, 20 Nov 2020 19:51:02 +0100 Message-Id: <20201120185105.279030-25-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Since vhost is now asking for qemu's VA, iommu needs to be bypassed. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index eebfac4455..cb44b9997f 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1109,6 +1109,10 @@ static int vhost_sw_live_migration_start(struct vhos= t_dev *dev) =20 assert(dev->vhost_ops->vhost_set_vring_enable); dev->vhost_ops->vhost_set_vring_enable(dev, false); + if (vhost_dev_has_iommu(dev)) { + r =3D vhost_backend_invalidate_device_iotlb(dev, 0, -1ULL); + assert(r =3D=3D 0); + } =20 for (idx =3D 0; idx < dev->nvqs; ++idx) { struct vhost_virtqueue *vq =3D &dev->vqs[idx]; @@ -1269,6 +1273,19 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, u= int64_t iova, int write) =20 trace_vhost_iotlb_miss(dev, 1); =20 + if (dev->sw_lm_enabled) { + uaddr =3D iova; + len =3D 4096; + ret =3D vhost_backend_update_device_iotlb(dev, iova, uaddr, len, + IOMMU_RW); + if (ret) { + trace_vhost_iotlb_miss(dev, 2); + error_report("Fail to update device iotlb"); + } + + return ret; + } + iotlb =3D address_space_get_iotlb_entry(dev->vdev->dma_as, iova, write, MEMTXATTRS_UNSPECIFIED); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605900063; cv=none; d=zohomail.com; s=zohoarc; b=c2qqrN3aAuImEZI+xNguP75yOG+wxJOJ6jST7YLyu3G/2lm5756GUsu8+EXdWN3W0V9tfdSCf2wr93slkRPk8OOjo34YW/m2k8BI2rWVvJr9/SIR/kVXPMemGzINQS3sJyfWFh9HHsh+TJK9fpGf3MuQczlIVj3SpqdFsNuwFxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605900063; 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=7NFTh5Kxb25Zit2Z09Dwayle5qrijF2SdCF72+OTF/8=; b=TLemY7B21+Dur0Hg6KWD/2rzY9ecogkqwIV/5njovuddPzjQvQuzqNGrr75+AFXYfGuKlwI7ZdR1Z2ZPmotmiyxKFy1z2Bfe5wcQl239jXz/IHs05FZeMBxz29GnMVJ11NUrsM8pOxiuH8nL3GxDMWnNbyRdv6Kt8zQIeGDwwcw= 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+importer=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 1605900063464551.9987007463349; Fri, 20 Nov 2020 11:21:03 -0800 (PST) Received: from localhost ([::1]:36774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBxu-0005Xo-9j for importer@patchew.org; Fri, 20 Nov 2020 14:21:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBbC-00009J-HW for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBb8-00006K-PE for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:34 -0500 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-APAVSU7rNfasUb3rHao7YA-1; Fri, 20 Nov 2020 13:57:26 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77F0D801B19; Fri, 20 Nov 2020 18:57:23 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 571CD5C1D5; Fri, 20 Nov 2020 18:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898648; 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=7NFTh5Kxb25Zit2Z09Dwayle5qrijF2SdCF72+OTF/8=; b=RT45NiFtEwtJYp6ul1BBomD8AI8Vo3w3Qeeyyxs/lyHAWCLzbRCRogw7h7tDB24dWp2i+a GgqZm52gsb1S7pMGcrolZrF5MDa1G+mNv3zzLR5XVcUxQZFbHktqPRtZeiLUmA+/hFpWyN J2QINy6U0yXMOhoAmPFx2B7TxxtatXE= X-MC-Unique: APAVSU7rNfasUb3rHao7YA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 25/27] vhost: Do not commit vhost used idx on vhost_virtqueue_stop Date: Fri, 20 Nov 2020 19:51:03 +0100 Message-Id: <20201120185105.279030-26-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) ... if sw lm is enabled Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index cb44b9997f..cf000b979f 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1424,17 +1424,22 @@ static void vhost_virtqueue_stop(struct vhost_dev *= dev, struct vhost_vring_state state =3D { .index =3D vhost_vq_index, }; - int r; + int r =3D -1; =20 if (virtio_queue_get_desc_addr(vdev, idx) =3D=3D 0) { /* Don't stop the virtqueue which might have not been started */ return; } =20 - r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); - if (r < 0) { - VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r); - /* Connection to the backend is broken, so let's sync internal + if (!dev->sw_lm_enabled) { + r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + if (r < 0) { + VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r); + } + } + + if (!dev->sw_lm_enabled || r < 0) { + /* Connection to the backend is unusable, so let's sync internal * last avail idx to the device used idx. */ virtio_queue_restore_last_avail_idx(vdev, idx); --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605899768; cv=none; d=zohomail.com; s=zohoarc; b=VmXT1mkE/fFEfV34irQLY8mQA7FjFif6765AwIIZAgg0Cwo3wrWIB/GvzSbNcIQJEs8YKFHMwUEWT4rRXukZGAByeW/IsZUfEPJRtb2BJEGaHbo8RQuVI96ap8yoyDtNDrbf4Y1ULXuYx69mSHpClR+jJ5ecxK1kgsOhBjdcP14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605899768; 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=O+qiriFl30O5ZK13M3dH3aBYCSEg2kw5TfbYjHT/iYc=; b=BWfzLtqp9qpN3cRV2XKXK1bTdPhcSt3adQxbsBZMDZP9/b8+IvChgbrTzXEBegXuz7KYsoLuDW2KoLVehIDFrEAj1yDA9w+xTfFFC7Y2MiSFfyzFhQPvYYwMetc4HIGe1IKcobvR6bN1JfZP9Q2/jm4KqgjGPoU8ZbVmeFNrK20= 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+importer=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 160589976894551.88977730428974; Fri, 20 Nov 2020 11:16:08 -0800 (PST) Received: from localhost ([::1]:54402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBt9-0000z3-RW for importer@patchew.org; Fri, 20 Nov 2020 14:16:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBbW-0000Rd-Vn for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBbP-0000AP-PO for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:52 -0500 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-320--iW6dT1CPiib-6aLo2w7YA-1; Fri, 20 Nov 2020 13:57:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA5C21084422; Fri, 20 Nov 2020 18:57:38 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDD7B5C1D5; Fri, 20 Nov 2020 18:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898664; 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=O+qiriFl30O5ZK13M3dH3aBYCSEg2kw5TfbYjHT/iYc=; b=JCfmfHLNpjpVSyGVWncCnaULYi7398HU2t8nYjCVLQGMvD2vl/iW7Z2TxBk5rKuuhoij8u qltNX6iCSCPJMFpsrq6VhaxmTMziE7A9JuMj7Etndm1Z6t4uGjfK35EYEznMHxLvC5lfJy 1CJl16f8WQubiUlwuUk3LCGRztrE5ZQ= X-MC-Unique: -iW6dT1CPiib-6aLo2w7YA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 26/27] vhost: Add vhost_hdev_can_sw_lm Date: Fri, 20 Nov 2020 19:51:04 +0100 Message-Id: <20201120185105.279030-27-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This allows a device to migrate if it meet a few requirements. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index cf000b979f..44a51ccf5e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1529,6 +1529,37 @@ static void vhost_virtqueue_cleanup(struct vhost_vir= tqueue *vq) event_notifier_cleanup(&vq->masked_notifier); } =20 +static bool vhost_hdev_can_sw_lm(struct vhost_dev *hdev) +{ + const char *cause =3D NULL; + + if (hdev->features & (VIRTIO_F_IOMMU_PLATFORM)) { + cause =3D "have iommu"; + } else if (hdev->features & VIRTIO_F_RING_PACKED) { + cause =3D "is packed"; + } else if (hdev->features & VIRTIO_RING_F_EVENT_IDX) { + cause =3D "Have event idx"; + } else if (hdev->features & VIRTIO_RING_F_INDIRECT_DESC) { + cause =3D "Supports indirect descriptors"; + } else if (hdev->nvqs !=3D 2) { + cause =3D "!=3D 2 #vq supported"; + } else if (!hdev->vhost_ops->vhost_net_set_backend) { + cause =3D "cannot pause device"; + } + + if (cause) { + if (!hdev->migration_blocker) { + error_setg(&hdev->migration_blocker, + "Migration disabled: vhost lacks VHOST_F_LOG_ALL feature a= nd %s.", + cause); + } + + return false; + } + + return true; +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t) { @@ -1604,7 +1635,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, }; =20 if (hdev->migration_blocker =3D=3D NULL) { - if (!vhost_dev_can_log(hdev)) { + if (!vhost_dev_can_log(hdev) && !vhost_hdev_can_sw_lm(hdev) + && hdev->migration_blocker =3D=3D NULL) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL fe= ature."); } else if (vhost_dev_log_is_shared(hdev) && !qemu_memfd_alloc_chec= k()) { --=20 2.18.4 From nobody Thu Apr 25 10:08:00 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605900017; cv=none; d=zohomail.com; s=zohoarc; b=krcL691FowaWqUfuk1B1dHnojAs+CPotd6xziIkoezkM1mnRnuGuPeAE5lQ0cOXt/694xKaKFxrKELVHMg70tBn1MjKjCvEQywv5DMOBOXbRdDk4+nKqDKpAxNaU8Q/tcbjfpZGS67VPOG74WYJWF48VF1mHU07vo9wJETZmjAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605900017; 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=K8v+fo5FJLI5mUneJtRG5p9f1qblLX12fPi1h8UA2TI=; b=lQVyQkF4vUkCcI9auSoObaAMwB1b1LfxJq9RHjtAlBf0q2eOXw9eNmfkJud+BBOYwbnMnFER7NE36peAz0COauh9ZSDh9IkD4EJGMdH9Euy7DQ/jr3uT7HI0xenSk21Wn1vr7p+o7ftipIXiOpEYaSOuZT0aFaNZoxLzUcyV+DQ= 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+importer=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 160590001755273.7392513345726; Fri, 20 Nov 2020 11:20:17 -0800 (PST) Received: from localhost ([::1]:34518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgBxA-0004X7-AH for importer@patchew.org; Fri, 20 Nov 2020 14:20:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgBbZ-0000Sy-1w for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgBbT-0000Bm-JQ for qemu-devel@nongnu.org; Fri, 20 Nov 2020 13:57:56 -0500 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-461-_2evQM4sOaKGsMBKkPjsGA-1; Fri, 20 Nov 2020 13:57:48 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48BCB814411; Fri, 20 Nov 2020 18:57:45 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-88.ams2.redhat.com [10.36.112.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E4555C1D5; Fri, 20 Nov 2020 18:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605898670; 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=K8v+fo5FJLI5mUneJtRG5p9f1qblLX12fPi1h8UA2TI=; b=MSI82BlGcPb0YkYZsGlgoAbRUOENMW8LR7b5AT46arhLmS+dKLTHF5WoPTHT2KTw0B5hLV JMe98+LWIN3Fh8lezSgD0UWncjsZgIfAbFoUjidPGS6YMzEpnyToLyqf35HrltRGj/DM7P LSp0WnwPyKuk730fAX1tDJs5ej3Q5lg= X-MC-Unique: _2evQM4sOaKGsMBKkPjsGA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 27/27] vhost: forbid vhost devices logging Date: Fri, 20 Nov 2020 19:51:05 +0100 Message-Id: <20201120185105.279030-28-eperezma@redhat.com> In-Reply-To: <20201120185105.279030-1-eperezma@redhat.com> References: <20201120185105.279030-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: kvm@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is NOT a commit intended for merge, but for test the patchset. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 44a51ccf5e..069e5c915d 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -79,7 +79,7 @@ static struct vhost_dev *vhost_dev_from_virtio(const Virt= IODevice *vdev) =20 static bool vhost_dev_can_log(const struct vhost_dev *hdev) { - return hdev->features & (0x1ULL << VHOST_F_LOG_ALL); + return false; } =20 static void vhost_dev_sync_region(struct vhost_dev *dev, --=20 2.18.4