From nobody Fri May 17 08:39:32 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=1612885266; cv=none; d=zohomail.com; s=zohoarc; b=fBLQfteHj02w+oakC6VSU9cQoQqCSjuIN6+FSSx8SkifvU7YD6uxHjzIoZ/JISoPuaQwvpULKxYhvE9636crHqhgxrBxr8z2Yb5rjKp55WBPop/YR0W3E/mfmRglLATD3yh9XysPu8BGeTN9kWfGlG98RTMrwKmU/4uq2qsmpts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885266; 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=0qfIuOSj3cCueqwaPC5zwvc4Qbcji7lEdGdJ+Qo6tpc=; b=hzZQahEC1F3kk9iOtvuMeSbDyrDgL4zQ3cE5TVhXStsFI+Oc/e5bKIddtrOjSpqG5Dyziex1vwSzaobpJpsMi3KXHxHvdwl/TF4ftR5jo+hs/Gm6+CjwIjTqMswDlzx4ZabggiAB7/5obltnMGuYJuXEruhZnMsODCu/6d2KiUg= 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 1612885265807622.2952122295181; Tue, 9 Feb 2021 07:41:05 -0800 (PST) Received: from localhost ([::1]:50772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9V8R-000523-He for importer@patchew.org; Tue, 09 Feb 2021 10:41:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9V5r-0003KF-PG for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42465) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V5l-0008Al-FU for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:23 -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-190-xTNTllDpPtO0RFp4W7npBQ-1; Tue, 09 Feb 2021 10:38:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 304721934103; Tue, 9 Feb 2021 15:38:13 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1A3A6F971; Tue, 9 Feb 2021 15:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885096; 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=0qfIuOSj3cCueqwaPC5zwvc4Qbcji7lEdGdJ+Qo6tpc=; b=RHuWtJnl5BWyl5TMDi934eOR2EtCSYj+21jfLJkKBIptyIJlgSmHGo/+HRMPkw9Bj876Mf xZgQMjBQ9ap9hHo5Xg9Woj50lwq/I+glHVSbRoI8hXYCH79ahc7r8GkScfnMDD3yC+CRwh b5xOzrYm0qbnfSsYWGiG3uNXqEk/pxE= X-MC-Unique: xTNTllDpPtO0RFp4W7npBQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 1/7] vhost: Delete trailing dot in errpr_setg argument Date: Tue, 9 Feb 2021 16:37:51 +0100 Message-Id: <20210209153757.1653598-2-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As error_setg points --- 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 6e17d631f7..1c5b442081 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1358,7 +1358,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, if (hdev->migration_blocker =3D=3D NULL) { if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { error_setg(&hdev->migration_blocker, - "Migration disabled: vhost lacks VHOST_F_LOG_ALL fe= ature."); + "Migration disabled: vhost lacks VHOST_F_LOG_ALL fe= ature"); } else if (vhost_dev_log_is_shared(hdev) && !qemu_memfd_alloc_chec= k()) { error_setg(&hdev->migration_blocker, "Migration disabled: failed to allocate shared memo= ry"); --=20 2.27.0 From nobody Fri May 17 08:39:32 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=1612885386; cv=none; d=zohomail.com; s=zohoarc; b=QPuigPcOR1o5TaJf+kRgu84dkXbwh+05pFmRlAStYx8xPaGJiwn3Z/l8ZPF3BfXcvrvi6o8f/0FQ3LIjqZwp2WAH3T6SFgh/6ZZddmd29t5qqfwU9TDgC9MEpagENZK5gDrAMwhniXt0i+XbxfzFZHlgVs99V2mkHq+i1EDh/OQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885386; 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=pvbvc9mRWdSbx+tqii1T5KfB2fGwy5/EA0WWIowXN54=; b=noarZAv1ga6KdsMbt9kpxyaonJDSOmmX0kjGF4q6V5sRQ/UIpIjMNnNE/R+QsRC/MjmdPhkxTl1yYB899d4PSAJjXN0LsxX/AwYyc1ej+sw+o0QwhIARdLHxGEMzxcv71pcbJW3F+P+WKkk7Mju80UivdoBCVpOx0ukZkCegJyQ= 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 161288538647718.228016979983522; Tue, 9 Feb 2021 07:43:06 -0800 (PST) Received: from localhost ([::1]:56516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9VAP-0007UG-Au for importer@patchew.org; Tue, 09 Feb 2021 10:43:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9V5v-0003PC-Gn for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V5q-0008Cm-6P for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:26 -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-179-jDrx0rwtM-6KCdLlHAgwow-1; Tue, 09 Feb 2021 10:38:19 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8831100B3B0; Tue, 9 Feb 2021 15:38:17 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8609060CCD; Tue, 9 Feb 2021 15:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885101; 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=pvbvc9mRWdSbx+tqii1T5KfB2fGwy5/EA0WWIowXN54=; b=NFs35mUIQ0lg/BdrZO/67g1LEoLdc5WGSHlmkaVPrfuwTRxqwr6kG2tsbduvQxhn25lDwT A/PyKWXASDxmGHqQTnp2/9WRkwGFs4+XJxH4FwUrb+ifzfFPalMt4xAhLMrZ9we2b+Q4mT NjhM/sAnqeYt0X44UX6BeQ2XR/6GxQE= X-MC-Unique: jDrx0rwtM-6KCdLlHAgwow-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 2/7] virtio: Add virtio_queue_host_notifier_status Date: Tue, 9 Feb 2021 16:37:52 +0100 Message-Id: <20210209153757.1653598-3-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_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: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This allows shadow virtqueue code to assert the queue status before making changes. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/virtio.h | 1 + hw/virtio/virtio.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b7ece7a6a8..227cec13a8 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -316,6 +316,7 @@ void virtio_device_release_ioeventfd(VirtIODevice *vdev= ); bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev); EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq); void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled); +bool virtio_queue_host_notifier_status(const VirtQueue *vq); void virtio_queue_host_notifier_read(EventNotifier *n); void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext = *ctx, VirtIOHandleAIOOutput hand= le_output); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 1fd1917ca0..53473ae4df 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3594,6 +3594,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQu= eue *vq) return &vq->host_notifier; } =20 +bool virtio_queue_host_notifier_status(const VirtQueue *vq) +{ + return vq->host_notifier_enabled; +} + void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled) { vq->host_notifier_enabled =3D enabled; --=20 2.27.0 From nobody Fri May 17 08:39:32 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=1612885595; cv=none; d=zohomail.com; s=zohoarc; b=Bh0v6o+64rpDWgquPmRZKi0Kfg9qV/Nw8Hmv2pegjfVw8tb5++emTfkkavR6gpAnvzl12uUGwVMe0JzqBnvjaf/Voejdpdk6HV6auO/RIJLgD/xYFpmRCO97xc0Jg+OJABI5bFwsF4+dWwvfNZoP+2RIX03XhgHlzL9mSBwg9Y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885595; 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=ayJbNG75ZtzXsG4iYJqDdTAoQt5V5N8yYCVLTMnbVak=; b=T/AkNkc5Vt6Zahw2gBHr1yE69l/8rilNVYgzpHXhgEg9VDgaVhoTY3p6gy/9Vqe/TxRgJIupBmpJxvGeiJJfDzp3eQckIYQAGJq2bkP0VZlAny/WNeAmI6Bg94TCmKwBAFf6P/nMwFqOOCBzzQTU6+OehNsZF1qfqF5x7PdC0wY= 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 1612885595444943.8962612125176; Tue, 9 Feb 2021 07:46:35 -0800 (PST) Received: from localhost ([::1]:33178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9VDk-0001IG-4X for importer@patchew.org; Tue, 09 Feb 2021 10:46:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9V5x-0003Sf-Dx for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V5v-0008Er-Qw for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38: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-380-VGohhTHuOX-roN4k0ULfIA-1; Tue, 09 Feb 2021 10:38:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85E326D4F3; Tue, 9 Feb 2021 15:38:22 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48EE660861; Tue, 9 Feb 2021 15:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885106; 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=ayJbNG75ZtzXsG4iYJqDdTAoQt5V5N8yYCVLTMnbVak=; b=TTCgW7JliLh3HbED86ISOUbMvhOF1ChYsmJ28o3RxFrnnXWCq3oFHemxDrwLGk1+1bp30M f1ggFkSSPZpdMUg87N2keLVv42q0I1P0FXvlujp1LXoU0ZFsaSgb0ldqDX4zzAth9RKelq KQFlUq1/BMliVjSsN7rfgCNi1pmp3MY= X-MC-Unique: VGohhTHuOX-roN4k0ULfIA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 3/7] vhost: Save masked_notifier state Date: Tue, 9 Feb 2021 16:37:53 +0100 Message-Id: <20210209153757.1653598-4-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) It will be used to recover call eventfd. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Stefan Hajnoczi --- include/hw/virtio/vhost.h | 1 + hw/virtio/vhost.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 4a8bc75415..ac963bf23d 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -28,6 +28,7 @@ struct vhost_virtqueue { unsigned avail_size; unsigned long long used_phys; unsigned used_size; + bool notifier_is_masked; EventNotifier masked_notifier; struct vhost_dev *dev; }; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1c5b442081..5d0c817b8f 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1518,6 +1518,8 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vir= tIODevice *vdev, int n, /* should only be called after backend is connected */ assert(hdev->vhost_ops); =20 + hdev->vqs[index].notifier_is_masked =3D mask; + if (mask) { assert(vdev->use_guest_notifier_mask); file.fd =3D event_notifier_get_fd(&hdev->vqs[index].masked_notifie= r); --=20 2.27.0 From nobody Fri May 17 08:39:32 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=1612885294; cv=none; d=zohomail.com; s=zohoarc; b=ArCV8HLC3OcPeqIe6gHrf9xMWYYWtXUGnCVTqIU/w8Z29f1FDRqjGcjnaJt2d5RiVSkFaISm5n1A/9dLL0fdCyVVBRfWTLnULG/JeQspybF9Wj8cEqFeMM6VGa0sq6xpx9zfXFDIzTwyUEM6+6M9Gl3IHPhYNqTs7dLW6c5yJVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885294; 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=Zyx4eZHRmfd6odC93cUlBS3eBpZrTCnYtL1f5lj1Zzo=; b=faqg4pBl8wZSSRRZtZA2Kddq/NcMp77KmQnx2VnXY8Wka5SM3dWqdguBMDe2h9VYiH1rzURi6SJpHeyV//iyUni3vza1el9GLK1w6GGwVTt96zLLVa/9ZL/IXWhN5UoSLv7OyYKEy2ZeLfrCr0jf0Dh2vUljxpEDfNnUvebTOls= 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 1612885294235314.3726498559223; Tue, 9 Feb 2021 07:41:34 -0800 (PST) Received: from localhost ([::1]:51616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9V8v-0005Nu-7u for importer@patchew.org; Tue, 09 Feb 2021 10:41:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9V6B-0003gJ-9e for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V67-0008JH-C4 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:43 -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-397-xVJdhbZMNvOGk3M7OG7WXg-1; Tue, 09 Feb 2021 10:38:34 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6DDB5801965; Tue, 9 Feb 2021 15:38:32 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD5C760861; Tue, 9 Feb 2021 15:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885115; 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=Zyx4eZHRmfd6odC93cUlBS3eBpZrTCnYtL1f5lj1Zzo=; b=PH9uepW4uiJHWZN2ekrsk3OD76HqN2SdBk0Pv6voQWbW6ghc+fI1BKWc9AlI6Xs4hqzJbI sxLdFkdBywKAhsOl2LqYdkGb820BOMzeGS0C12eaV2gTLPzwYAPSbLM/hxiamRig8SSSdH wsJDFSpeW9BpDDY8na7038/JwF5fOwg= X-MC-Unique: xVJdhbZMNvOGk3M7OG7WXg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 4/7] vhost: Add VhostShadowVirtqueue Date: Tue, 9 Feb 2021 16:37:54 +0100 Message-Id: <20210209153757.1653598-5-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_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: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Vhost shadow virtqueue is an intermediate jump for virtqueue notifications and buffers, allowing qemu to track them. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-shadow-virtqueue.h | 24 ++++++++++++ hw/virtio/vhost-shadow-virtqueue.c | 63 ++++++++++++++++++++++++++++++ hw/virtio/meson.build | 2 +- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-shadow-virtqueue.h create mode 100644 hw/virtio/vhost-shadow-virtqueue.c diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-vi= rtqueue.h new file mode 100644 index 0000000000..6cc18d6acb --- /dev/null +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -0,0 +1,24 @@ +/* + * vhost software live migration ring + * + * SPDX-FileCopyrightText: Red Hat, Inc. 2021 + * SPDX-FileContributor: Author: Eugenio P=C3=A9rez + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef VHOST_SHADOW_VIRTQUEUE_H +#define VHOST_SHADOW_VIRTQUEUE_H + +#include "qemu/osdep.h" + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" + +typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; + +VhostShadowVirtqueue *vhost_shadow_vq_new(struct vhost_dev *dev, int idx); + +void vhost_shadow_vq_free(VhostShadowVirtqueue *vq); + +#endif diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c new file mode 100644 index 0000000000..b5d2645ae0 --- /dev/null +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -0,0 +1,63 @@ +/* + * vhost software live migration ring + * + * SPDX-FileCopyrightText: Red Hat, Inc. 2021 + * SPDX-FileContributor: Author: Eugenio P=C3=A9rez + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "hw/virtio/vhost-shadow-virtqueue.h" + +#include "qemu/error-report.h" +#include "qemu/event_notifier.h" + +/* Shadow virtqueue to relay notifications */ +typedef struct VhostShadowVirtqueue { + /* Shadow kick notifier, sent to vhost */ + EventNotifier kick_notifier; + /* Shadow call notifier, sent to vhost */ + EventNotifier call_notifier; +} VhostShadowVirtqueue; + +/* + * Creates vhost shadow virtqueue, and instruct vhost device to use the sh= adow + * methods and file descriptors. + */ +VhostShadowVirtqueue *vhost_shadow_vq_new(struct vhost_dev *dev, int idx) +{ + g_autofree VhostShadowVirtqueue *svq =3D g_new0(VhostShadowVirtqueue, = 1); + int r; + + r =3D event_notifier_init(&svq->kick_notifier, 0); + if (r !=3D 0) { + error_report("Couldn't create kick event notifier: %s", + strerror(errno)); + goto err_init_kick_notifier; + } + + r =3D event_notifier_init(&svq->call_notifier, 0); + if (r !=3D 0) { + error_report("Couldn't create call event notifier: %s", + strerror(errno)); + goto err_init_call_notifier; + } + + return svq; + +err_init_call_notifier: + event_notifier_cleanup(&svq->kick_notifier); + +err_init_kick_notifier: + return NULL; +} + +/* + * Free the resources of the shadow virtqueue. + */ +void vhost_shadow_vq_free(VhostShadowVirtqueue *vq) +{ + event_notifier_cleanup(&vq->kick_notifier); + event_notifier_cleanup(&vq->call_notifier); + g_free(vq); +} diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc9d4..8b5a0225fe 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-shadow-virtqueue.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.27.0 From nobody Fri May 17 08:39:32 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=1612885709; cv=none; d=zohomail.com; s=zohoarc; b=Q4Cp435rCqypcB+UqMWzJm/WAPR3rT019z7bkn3rmEyeURXr55itPdyy46TTO0kzkppLCTFLGQpE9Tpug/qSIslq6bWVRS5LzEJU2OYW8rgqQKplwGXB9V5c7DF7eWueU31XnjnLuQwbI5CXIj2b3i6/KXn7eHILMfnYWz1wLcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885709; 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=FC3LOZzpMHUEZ3mWKy2ZQRizyLOeWYwFcOGeH0JGDl0=; b=Tgl3bp/9fNL6bmsSjnhEMBnbJQeYYCHxhs87dN74EuHJD+hVi/+t48eq89Jy6/9V1mTAnhXQoowlPt88XJ4PDBepHBX4rBOJI9Yafi5FDcYLldiBbJiP34yf8n5fthWpch5PYSfSjsLyry+V8W/bDyxEU9pumJAHBHyQzIbe7OY= 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 1612885708805593.7602903494303; Tue, 9 Feb 2021 07:48:28 -0800 (PST) Received: from localhost ([::1]:36250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9VFa-0002fn-Q9 for importer@patchew.org; Tue, 09 Feb 2021 10:48:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9V6D-0003ge-BQ for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35465) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V6B-0008Ji-2C for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:45 -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-317-227F_zDJMvWyTdK0qidx2Q-1; Tue, 09 Feb 2021 10:38:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44D786D4F0; Tue, 9 Feb 2021 15:38:36 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id C46C660861; Tue, 9 Feb 2021 15:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885121; 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=FC3LOZzpMHUEZ3mWKy2ZQRizyLOeWYwFcOGeH0JGDl0=; b=OQYysfifePRqtc182LtxIG4un6qKYPhpzHWUyHazGoyeXKPar/adue2uANpiPsHQpFjRtK 3Fgu51+22uMziFmaQTXHOPpTf91iZoTilSAaaCYcu/WX2xY5GoUPI7aLhDwERUvaOtV7y1 wOh3eCQp4fIZNqhlKaZ4bIfDcp0nzQQ= X-MC-Unique: 227F_zDJMvWyTdK0qidx2Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 5/7] vhost: Add x-vhost-enable-shadow-vq qmp Date: Tue, 9 Feb 2021 16:37:55 +0100 Message-Id: <20210209153757.1653598-6-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_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: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Command to enable shadow virtqueue looks like: { "execute": "x-vhost-enable-shadow-vq", "arguments": { "name": "dev0", "en= able": true } } Signed-off-by: Eugenio P=C3=A9rez --- qapi/net.json | 22 ++++++++++++++++++++++ hw/virtio/vhost.c | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/qapi/net.json b/qapi/net.json index c31748c87f..a1cdffb0f9 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -77,6 +77,28 @@ ## { 'command': 'netdev_del', 'data': {'id': 'str'} } =20 +## +# @x-vhost-enable-shadow-vq: +# +# Use vhost shadow virtqueue. +# +# @name: the device name of the virtual network adapter +# +# @enable: true to use he alternate shadow VQ notification path +# +# Returns: Error if failure, or 'no error' for success +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "x-vhost-enable-shadow-vq", "arguments": {"enable": true= } } +# +## +{ 'command': 'x-vhost-enable-shadow-vq', + 'data': {'name': 'str', 'enable': 'bool'}, + 'if': 'defined(CONFIG_VHOST_KERNEL)' } + ## # @NetLegacyNicOptions: # diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 5d0c817b8f..8fbf14385e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -15,6 +15,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-commands-net.h" #include "hw/virtio/vhost.h" #include "qemu/atomic.h" #include "qemu/range.h" @@ -1833,3 +1834,8 @@ int vhost_net_set_backend(struct vhost_dev *hdev, =20 return -1; } + +void qmp_x_vhost_enable_shadow_vq(const char *name, bool enable, Error **e= rrp) +{ + error_setg(errp, "Shadow virtqueue still not implemented"); +} --=20 2.27.0 From nobody Fri May 17 08:39:32 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=1612885791; cv=none; d=zohomail.com; s=zohoarc; b=C0fBOcS0rv8f+/vIRdhofKdddhSdC1QsF9nQJ2HfGZ4MjbWfus1SxAoYgL2n7tIb6xu4Oy/mivbt6+MYnmUaWkRE3ZSVx55lRKqwLKVb1lSAzaD92XZXAsPyXkB2Iq5ZCfbIUAmc1KIOFVl5bITlOHaFo7TkGKJnwM32k3NZVfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885791; 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=gpifSbnjYPCdwCNzWIyzHdufTbFFRRTIJ6we5pSJcKY=; b=hrNQvrcir/SKm+jxz3a9Fz1XINhw7j82Nk7IqZ9Af5/nK+HPZEZetGVXtNy9W/L3kKA74Q9XNzKy7yxzmuYInglb5uwxEbYTCHq8Lv2yOiMl6f1yHYX1P0mtBlPErZoNpq8VbaAuNAjzL/3hIumwaNB4zYF2j3+tawoVdgUyZTQ= 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 1612885790829933.5189081135193; Tue, 9 Feb 2021 07:49:50 -0800 (PST) Received: from localhost ([::1]:38370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9VGv-0003fe-Ok for importer@patchew.org; Tue, 09 Feb 2021 10:49:49 -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 1l9V6J-0003kj-PM for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25529) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V6F-0008Kr-S8 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:51 -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-237-qwUDRcXxPt6kt1KNItsPIw-1; Tue, 09 Feb 2021 10:38:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E48A080197B; Tue, 9 Feb 2021 15:38:39 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8592760861; Tue, 9 Feb 2021 15:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885125; 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=gpifSbnjYPCdwCNzWIyzHdufTbFFRRTIJ6we5pSJcKY=; b=JdT5dXnJ1a+uV7llNmTxifklaXovoas3UiGx+rXTQnupOoobB6RZH7EbQtHvuPdGwAHh7N Rs+dKxhuOaBE1oi2qBqkizKxpA4XJmislneJnSNHvR7SVoHEtPeKuOYIdP3lrXoKyomrHk imQif8q4DEhmnusLjYvjHbxaxyyaet4= X-MC-Unique: qwUDRcXxPt6kt1KNItsPIw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 6/7] vhost: Route guest->host notification through shadow virtqueue Date: Tue, 9 Feb 2021 16:37:56 +0100 Message-Id: <20210209153757.1653598-7-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_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: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Shadow virtqueue notifications forwarding is disabled when vhost_dev stops. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-shadow-virtqueue.h | 7 ++ include/hw/virtio/vhost.h | 4 + hw/virtio/vhost-shadow-virtqueue.c | 97 ++++++++++++++++++- hw/virtio/vhost.c | 148 ++++++++++++++++++++++++++++- 4 files changed, 253 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-vi= rtqueue.h index 6cc18d6acb..c45035c4b7 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -17,6 +17,13 @@ =20 typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; =20 +bool vhost_shadow_vq_start_rcu(struct vhost_dev *dev, + unsigned idx, + VhostShadowVirtqueue *svq); +void vhost_shadow_vq_stop_rcu(struct vhost_dev *dev, + unsigned idx, + VhostShadowVirtqueue *svq); + VhostShadowVirtqueue *vhost_shadow_vq_new(struct vhost_dev *dev, int idx); =20 void vhost_shadow_vq_free(VhostShadowVirtqueue *vq); diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index ac963bf23d..884818b109 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -55,6 +55,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,7 +85,9 @@ struct vhost_dev { uint64_t backend_cap; bool started; bool log_enabled; + bool sw_lm_enabled; uint64_t log_size; + VhostShadowVirtqueue **shadow_vqs; Error *migration_blocker; const VhostOps *vhost_ops; void *opaque; diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index b5d2645ae0..01f282d434 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -8,9 +8,12 @@ */ =20 #include "hw/virtio/vhost-shadow-virtqueue.h" +#include "hw/virtio/vhost.h" + +#include "standard-headers/linux/vhost_types.h" =20 #include "qemu/error-report.h" -#include "qemu/event_notifier.h" +#include "qemu/main-loop.h" =20 /* Shadow virtqueue to relay notifications */ typedef struct VhostShadowVirtqueue { @@ -18,8 +21,95 @@ typedef struct VhostShadowVirtqueue { EventNotifier kick_notifier; /* Shadow call notifier, sent to vhost */ EventNotifier call_notifier; + + /* Borrowed virtqueue's guest to host notifier. */ + EventNotifier host_notifier; + + /* Virtio queue shadowing */ + VirtQueue *vq; } VhostShadowVirtqueue; =20 +/* Forward guest notifications */ +static void vhost_handle_guest_kick(EventNotifier *n) +{ + VhostShadowVirtqueue *svq =3D container_of(n, VhostShadowVirtqueue, + host_notifier); + + if (event_notifier_test_and_clear(n)) { + event_notifier_set(&svq->kick_notifier); + } +} + +/* + * Start shadow virtqueue operation. + * @dev vhost device + * @hidx vhost virtqueue index + * @svq Shadow Virtqueue + * + * Run in RCU context + */ +bool vhost_shadow_vq_start_rcu(struct vhost_dev *dev, + unsigned idx, + VhostShadowVirtqueue *svq) +{ + EventNotifier *vq_host_notifier =3D virtio_queue_get_host_notifier(svq= ->vq); + struct vhost_vring_file kick_file =3D { + .index =3D idx, + .fd =3D event_notifier_get_fd(&svq->kick_notifier), + }; + int r; + + /* Check that notifications are still going directly to vhost dev */ + assert(virtio_queue_host_notifier_status(svq->vq)); + + event_notifier_init_fd(&svq->host_notifier, + event_notifier_get_fd(vq_host_notifier)); + event_notifier_set_handler(&svq->host_notifier, vhost_handle_guest_kic= k); + + r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &kick_file); + if (unlikely(r !=3D 0)) { + error_report("Couldn't set kick fd: %s", strerror(errno)); + goto err_set_vring_kick; + } + + /* Check for pending notifications from the guest */ + vhost_handle_guest_kick(&svq->host_notifier); + + return true; + +err_set_vring_kick: + event_notifier_set_handler(&svq->host_notifier, NULL); + + return false; +} + +/* + * Stop shadow virtqueue operation. + * @dev vhost device + * @idx vhost queue index + * @svq Shadow Virtqueue + * + * Run in RCU context + */ +void vhost_shadow_vq_stop_rcu(struct vhost_dev *dev, + unsigned idx, + VhostShadowVirtqueue *svq) +{ + EventNotifier *vq_host_notifier =3D virtio_queue_get_host_notifier(svq= ->vq); + struct vhost_vring_file kick_file =3D { + .index =3D idx, + .fd =3D event_notifier_get_fd(vq_host_notifier), + }; + int r; + + /* Restore vhost kick */ + r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &kick_file); + /* Cannot do a lot of things */ + assert(r =3D=3D 0); + + event_notifier_set_handler(&svq->host_notifier, NULL); +} + /* * Creates vhost shadow virtqueue, and instruct vhost device to use the sh= adow * methods and file descriptors. @@ -27,8 +117,11 @@ typedef struct VhostShadowVirtqueue { VhostShadowVirtqueue *vhost_shadow_vq_new(struct vhost_dev *dev, int idx) { g_autofree VhostShadowVirtqueue *svq =3D g_new0(VhostShadowVirtqueue, = 1); + int vq_idx =3D dev->vq_index + idx; int r; =20 + svq->vq =3D virtio_get_queue(dev->vdev, vq_idx); + r =3D event_notifier_init(&svq->kick_notifier, 0); if (r !=3D 0) { error_report("Couldn't create kick event notifier: %s", @@ -43,7 +136,7 @@ VhostShadowVirtqueue *vhost_shadow_vq_new(struct vhost_d= ev *dev, int idx) goto err_init_call_notifier; } =20 - return svq; + return g_steal_pointer(&svq); =20 err_init_call_notifier: event_notifier_cleanup(&svq->kick_notifier); diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 8fbf14385e..9d4728e545 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -25,6 +25,7 @@ #include "exec/address-spaces.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" +#include "hw/virtio/vhost-shadow-virtqueue.h" #include "migration/blocker.h" #include "migration/qemu-file-types.h" #include "sysemu/dma.h" @@ -937,6 +938,84 @@ static void vhost_log_global_stop(MemoryListener *list= ener) } } =20 +static int vhost_sw_live_migration_stop(struct vhost_dev *dev) +{ + int idx; + + WITH_RCU_READ_LOCK_GUARD() { + dev->sw_lm_enabled =3D false; + + for (idx =3D 0; idx < dev->nvqs; ++idx) { + vhost_shadow_vq_stop_rcu(dev, idx, dev->shadow_vqs[idx]); + } + } + + for (idx =3D 0; idx < dev->nvqs; ++idx) { + vhost_shadow_vq_free(dev->shadow_vqs[idx]); + } + + g_free(dev->shadow_vqs); + dev->shadow_vqs =3D NULL; + return 0; +} + +static int vhost_sw_live_migration_start(struct vhost_dev *dev) +{ + int idx; + + dev->shadow_vqs =3D g_new0(VhostShadowVirtqueue *, dev->nvqs); + for (idx =3D 0; idx < dev->nvqs; ++idx) { + dev->shadow_vqs[idx] =3D vhost_shadow_vq_new(dev, idx); + if (unlikely(dev->shadow_vqs[idx] =3D=3D NULL)) { + goto err; + } + } + + WITH_RCU_READ_LOCK_GUARD() { + for (idx =3D 0; idx < dev->nvqs; ++idx) { + bool ok =3D vhost_shadow_vq_start_rcu(dev, idx, + dev->shadow_vqs[idx]); + + if (!ok) { + int stop_idx =3D idx; + + while (--stop_idx >=3D 0) { + vhost_shadow_vq_stop_rcu(dev, idx, + dev->shadow_vqs[stop_idx]); + } + + goto err; + } + } + } + + dev->sw_lm_enabled =3D true; + return 0; + +err: + for (; idx >=3D 0; --idx) { + vhost_shadow_vq_free(dev->shadow_vqs[idx]); + } + g_free(dev->shadow_vqs[idx]); + + return -1; +} + +static int vhost_sw_live_migration_enable(struct vhost_dev *dev, + bool enable_lm) +{ + int r; + + if (enable_lm =3D=3D dev->sw_lm_enabled) { + return 0; + } + + r =3D enable_lm ? vhost_sw_live_migration_start(dev) + : vhost_sw_live_migration_stop(dev); + + return r; +} + static void vhost_log_start(MemoryListener *listener, MemoryRegionSection *section, int old, int new) @@ -1381,6 +1460,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); @@ -1486,6 +1566,10 @@ 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) { + vhost_sw_live_migration_enable(hdev, false); + } + for (i =3D 0; i < hdev->nvqs; ++i) { r =3D virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_inde= x + i, false); @@ -1808,6 +1892,11 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODe= vice *vdev) hdev->vhost_ops->vhost_dev_start(hdev, false); } for (i =3D 0; i < hdev->nvqs; ++i) { + if (hdev->sw_lm_enabled) { + vhost_shadow_vq_stop_rcu(hdev, i, hdev->shadow_vqs[i]); + vhost_shadow_vq_free(hdev->shadow_vqs[i]); + } + vhost_virtqueue_stop(hdev, vdev, hdev->vqs + i, @@ -1821,6 +1910,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) memory_listener_unregister(&hdev->iommu_listener); } vhost_log_put(hdev, true); + g_free(hdev->shadow_vqs); + hdev->sw_lm_enabled =3D false; hdev->started =3D false; hdev->vdev =3D NULL; } @@ -1837,5 +1928,60 @@ int vhost_net_set_backend(struct vhost_dev *hdev, =20 void qmp_x_vhost_enable_shadow_vq(const char *name, bool enable, Error **e= rrp) { - error_setg(errp, "Shadow virtqueue still not implemented"); + struct vhost_dev *hdev, *hdev_err; + VirtIODevice *vdev; + const char *err_cause =3D NULL; + int r; + ErrorClass err_class =3D ERROR_CLASS_GENERIC_ERROR; + + QLIST_FOREACH(hdev, &vhost_devices, entry) { + if (hdev->vdev && 0 =3D=3D strcmp(hdev->vdev->name, name)) { + vdev =3D hdev->vdev; + break; + } + } + + if (!hdev) { + err_class =3D ERROR_CLASS_DEVICE_NOT_FOUND; + err_cause =3D "Device not found"; + goto not_found_err; + } + + for ( ; hdev; hdev =3D QLIST_NEXT(hdev, entry)) { + if (vdev !=3D hdev->vdev) { + continue; + } + + if (!hdev->started) { + err_cause =3D "Device is not started"; + goto err; + } + + r =3D vhost_sw_live_migration_enable(hdev, enable); + if (unlikely(r)) { + err_cause =3D "Error enabling (see monitor)"; + goto err; + } + } + + return; + +err: + QLIST_FOREACH(hdev_err, &vhost_devices, entry) { + if (hdev_err =3D=3D hdev) { + break; + } + + if (vdev !=3D hdev->vdev) { + continue; + } + + vhost_sw_live_migration_enable(hdev, !enable); + } + +not_found_err: + if (err_cause) { + error_set(errp, err_class, + "Can't enable shadow vq on %s: %s", name, err_cause); + } } --=20 2.27.0 From nobody Fri May 17 08:39:32 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=1612885422; cv=none; d=zohomail.com; s=zohoarc; b=fpckWSPSpvuubRQnF+twhudrEvYLcogGDs3mBa7zpJSPzo3+56gruS4A9JfBQgKjpvoHToXo8EHbi864Y1fqJP83ADbDbmQkowqI0iapb/5k10leD/okYixbJG9EaC0wBoAH8vQfkCu831a/TQrm3ljyq3wUQh4RBJ6Lm44Rjf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612885422; 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=uc4yMvSfmeIlRy1RwpEigPw1wLUvMBLfOUref+cp2/E=; b=Wan3Bw4Pw23ZVtSii7/uxe1fo5P/tnT/HfxrwNA0ALEtrDaNF8tz3vLqM2FVkhunCKAJa1t0Djk2mjTAP1A80YaIkGwN0KtYfeqdD6uAFZb9z3oPJ2ooWu5iMOD9P8MrnUn0NTlwr83VqQE8FP05lvwniGxXx8N//0XojY+q71A= 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 16128854223451.9977031265088954; Tue, 9 Feb 2021 07:43:42 -0800 (PST) Received: from localhost ([::1]:57506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9VAz-0007tA-7w for importer@patchew.org; Tue, 09 Feb 2021 10:43:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9V6P-0003q1-PB for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9V6I-0008Ly-Os for qemu-devel@nongnu.org; Tue, 09 Feb 2021 10:38: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-424-i2zUqz0OP66zkES_JqAQ0g-1; Tue, 09 Feb 2021 10:38:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51BA280402C; Tue, 9 Feb 2021 15:38:46 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4628660861; Tue, 9 Feb 2021 15:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612885129; 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=uc4yMvSfmeIlRy1RwpEigPw1wLUvMBLfOUref+cp2/E=; b=SHs1JKP2ua+9DQ4Dxh2DtsTZgHWO2cGjy+m7dlBLYVg1VNOoRtDHVU4fk/lji6iUPr/h5v jjuudIxAuOYTtHYS/z/DBzPGFftYqmYug/wv/AHvWkpNTocRNzPK6gsw4F3gHJGoTYCgR0 8f//uXRX7QQhO2VPTcOgHXdezf53mtw= X-MC-Unique: i2zUqz0OP66zkES_JqAQ0g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v2 7/7] vhost: Route host->guest notification through shadow virtqueue Date: Tue, 9 Feb 2021 16:37:57 +0100 Message-Id: <20210209153757.1653598-8-eperezma@redhat.com> In-Reply-To: <20210209153757.1653598-1-eperezma@redhat.com> References: <20210209153757.1653598-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Rob Miller , Michael Lilja , Jim Harford , Stefano Garzarella 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-shadow-virtqueue.h | 2 ++ hw/virtio/vhost-shadow-virtqueue.c | 49 ++++++++++++++++++++++++++++++ hw/virtio/vhost.c | 5 ++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-vi= rtqueue.h index c45035c4b7..210133434c 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -17,6 +17,8 @@ =20 typedef struct VhostShadowVirtqueue VhostShadowVirtqueue; =20 +EventNotifier *vhost_shadow_vq_get_call_notifier(VhostShadowVirtqueue *vq); + bool vhost_shadow_vq_start_rcu(struct vhost_dev *dev, unsigned idx, VhostShadowVirtqueue *svq); diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index 01f282d434..61d98ae652 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -24,6 +24,8 @@ typedef struct VhostShadowVirtqueue { =20 /* Borrowed virtqueue's guest to host notifier. */ EventNotifier host_notifier; + /* Host to guest notifier */ + EventNotifier *guest_notifier; =20 /* Virtio queue shadowing */ VirtQueue *vq; @@ -40,6 +42,26 @@ static void vhost_handle_guest_kick(EventNotifier *n) } } =20 +/* Forward vhost notifications */ +static void vhost_handle_call(EventNotifier *n) +{ + VhostShadowVirtqueue *svq =3D container_of(n, VhostShadowVirtqueue, + call_notifier); + + if (event_notifier_test_and_clear(n)) { + event_notifier_set(svq->guest_notifier); + } +} + +/* + * Get the vhost call notifier of the shadow vq + * @vq Shadow virtqueue + */ +EventNotifier *vhost_shadow_vq_get_call_notifier(VhostShadowVirtqueue *vq) +{ + return &vq->call_notifier; +} + /* * Start shadow virtqueue operation. * @dev vhost device @@ -57,6 +79,10 @@ bool vhost_shadow_vq_start_rcu(struct vhost_dev *dev, .index =3D idx, .fd =3D event_notifier_get_fd(&svq->kick_notifier), }; + struct vhost_vring_file call_file =3D { + .index =3D idx, + .fd =3D event_notifier_get_fd(&svq->call_notifier), + }; int r; =20 /* Check that notifications are still going directly to vhost dev */ @@ -66,6 +92,7 @@ bool vhost_shadow_vq_start_rcu(struct vhost_dev *dev, event_notifier_get_fd(vq_host_notifier)); event_notifier_set_handler(&svq->host_notifier, vhost_handle_guest_kic= k); =20 + svq->guest_notifier =3D virtio_queue_get_guest_notifier(svq->vq); r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &kick_file); if (unlikely(r !=3D 0)) { error_report("Couldn't set kick fd: %s", strerror(errno)); @@ -75,8 +102,19 @@ bool vhost_shadow_vq_start_rcu(struct vhost_dev *dev, /* Check for pending notifications from the guest */ vhost_handle_guest_kick(&svq->host_notifier); =20 + r =3D dev->vhost_ops->vhost_set_vring_call(dev, &call_file); + if (r !=3D 0) { + error_report("Couldn't set call fd: %s", strerror(errno)); + goto err_set_vring_call; + } + return true; =20 +err_set_vring_call: + kick_file.fd =3D event_notifier_get_fd(vq_host_notifier); + r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &kick_file); + assert(r =3D=3D 0); + err_set_vring_kick: event_notifier_set_handler(&svq->host_notifier, NULL); =20 @@ -108,6 +146,16 @@ void vhost_shadow_vq_stop_rcu(struct vhost_dev *dev, assert(r =3D=3D 0); =20 event_notifier_set_handler(&svq->host_notifier, NULL); + + if (!dev->vqs[idx].notifier_is_masked) { + EventNotifier *e =3D vhost_shadow_vq_get_call_notifier(svq); + + /* Restore vhost call */ + vhost_virtqueue_mask(dev, dev->vdev, dev->vq_index + idx, false); + + /* Check for pending calls */ + vhost_handle_call(e); + } } =20 /* @@ -136,6 +184,7 @@ VhostShadowVirtqueue *vhost_shadow_vq_new(struct vhost_= dev *dev, int idx) goto err_init_call_notifier; } =20 + event_notifier_set_handler(&svq->call_notifier, vhost_handle_call); return g_steal_pointer(&svq); =20 err_init_call_notifier: diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9d4728e545..0dc95679e9 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -975,7 +975,6 @@ static int vhost_sw_live_migration_start(struct vhost_d= ev *dev) for (idx =3D 0; idx < dev->nvqs; ++idx) { bool ok =3D vhost_shadow_vq_start_rcu(dev, idx, dev->shadow_vqs[idx]); - if (!ok) { int stop_idx =3D idx; =20 @@ -1608,6 +1607,10 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vi= rtIODevice *vdev, int n, if (mask) { assert(vdev->use_guest_notifier_mask); file.fd =3D event_notifier_get_fd(&hdev->vqs[index].masked_notifie= r); + } else if (hdev->sw_lm_enabled) { + VhostShadowVirtqueue *svq =3D hdev->shadow_vqs[n]; + EventNotifier *e =3D vhost_shadow_vq_get_call_notifier(svq); + file.fd =3D event_notifier_get_fd(e); } else { file.fd =3D event_notifier_get_fd(virtio_queue_get_guest_notifier(= vvq)); } --=20 2.27.0