From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279834; cv=none; d=zohomail.com; s=zohoarc; b=Hf1lC2dZrvaQTYSvVNlYBs3UqCOqT9Nezfl1Z7w0iGYduqYVOCtZeZpZy/tj5FQlUgptWjjRUYFeWQgs50VWpzQPRA+TpBq65IuOnvnJBBBmRzu3Knqe/s3cpSO7ON1BCffGKTV65f3wGA4X/1Cda458WsWKRd4CxUfGgX611zI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279834; 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=VMsdJr7duFAO3hX3qElqE6PLwLdvPNCBCrY/1ibjTaw=; b=k2O7NZ18FXy8CGKg79DZw5pmPcDufzYAVz51nNa4F+Du9+q5TNbpWCLURa/jOnhEizm2Qlk0uStuxAFNTyMR+CoEIlz/62lEqHzAGXHU1ER/dCLlCdUia9WmWQB+dqXlCAtGnbgNp+x27qMD4W6SVgMSIWb0W7kOc8okHMUbcMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166127983445115.408784806869903; Tue, 23 Aug 2022 11:37:14 -0700 (PDT) Received: from localhost ([::1]:41998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYm1-0002pr-5g for importer@patchew.org; Tue, 23 Aug 2022 14:37:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYfx-0008Sa-N1 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:30:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYfu-0004TC-Df for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:30:57 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-308-PYut9KUZNJ-i9se3aJCfJg-1; Tue, 23 Aug 2022 14:30:49 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 02B751C0755D; Tue, 23 Aug 2022 18:30:49 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15F31C15BB3; Tue, 23 Aug 2022 18:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279453; 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=VMsdJr7duFAO3hX3qElqE6PLwLdvPNCBCrY/1ibjTaw=; b=hA8+BtwF4Zk7m8Vx/GvvneZt0+01Z+zmlnMKSMJf3qbBh56i5gLEKqfnZfvcFVVSdabRNc N5DkEiPbdoQdFNqjQN7scqZad2WBMu6H2AqxX2kCK+wSQEXGupbx1NGCZuOCvDOTqFGKBb L2ZiO10UAh4YMSqVsZDcv1CROVWfx2o= X-MC-Unique: PYut9KUZNJ-i9se3aJCfJg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Tue, 23 Aug 2022 20:30:26 +0200 Message-Id: <20220823183037.98470-2-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.133.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279836596100001 It was easier to allow vhost_svq_add to handle the memory. Now that we will allow qemu to add elements to a SVQ without the guest's knowledge, it's better to handle it in the caller. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index 82a784d250..a1261d4a0f 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -233,9 +233,6 @@ static void vhost_svq_kick(VhostShadowVirtqueue *svq) /** * Add an element to a SVQ. * - * The caller must check that there is enough slots for the new element. It - * takes ownership of the element: In case of failure not ENOSPC, it is fr= ee. - * * Return -EINVAL if element is invalid, -ENOSPC if dev queue is full */ int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg, @@ -252,7 +249,6 @@ int vhost_svq_add(VhostShadowVirtqueue *svq, const stru= ct iovec *out_sg, =20 ok =3D vhost_svq_add_split(svq, out_sg, out_num, in_sg, in_num, &qemu_= head); if (unlikely(!ok)) { - g_free(elem); return -EINVAL; } =20 @@ -293,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueu= e *svq) virtio_queue_set_notification(svq->vq, false); =20 while (true) { - VirtQueueElement *elem; + g_autofree VirtQueueElement *elem; int r; =20 if (svq->next_guest_avail_elem) { @@ -324,12 +320,14 @@ static void vhost_handle_guest_kick(VhostShadowVirtqu= eue *svq) * queue the current guest descriptor and ignore kicks * until some elements are used. */ - svq->next_guest_avail_elem =3D elem; + svq->next_guest_avail_elem =3D g_steal_pointer(&elem); } =20 /* VQ is full or broken, just return and ignore kicks */ return; } + /* elem belongs to SVQ or external caller now */ + elem =3D NULL; } =20 virtio_queue_set_notification(svq->vq, true); --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280271; cv=none; d=zohomail.com; s=zohoarc; b=SOS7K6Z+JEEvn6LjqLDtqQDuQFmr/H1ZGIxGV0eVKTF+Py2VoEUPGoeffuidSK1ZqHrxSKFerDdzyFG16/ht/FEOvocC9KLIjqycCpUiVaWVJv093rPYcz/PjIO42ZPaGL1+C/fv0m8fr2uavyzQ8+h+PEOKgKihBYLylSXS98U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280271; 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=xBYkQK+5KnaDY4xdQ9EaxvQiPSuC/SCuSWflnwBLb0A=; b=ZrE1pTk0/HlOyT71MgQvndYEzSxqxelh9iP88/N15T4xxBYTK2GnRRWn17wJZEEaRpnKN7lRCCIinxDWaMUWwfSanDiF0vmjH5D3GoXUoMFdxgSPAxjhFR3+u+CiLrS1NVcIONfmufy89AKaYtvX/zGksPK6IrPbvgbCaEbRUj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166128027144211.73820740761721; Tue, 23 Aug 2022 11:44:31 -0700 (PDT) Received: from localhost ([::1]:42902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYt4-0003pb-A1 for importer@patchew.org; Tue, 23 Aug 2022 14:44:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYfy-0008Sw-CW for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:30:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYfw-0004TH-Kq for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:30:58 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-326-_r8UkRMLNbqPeX0v0G9Few-1; Tue, 23 Aug 2022 14:30:52 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3DABB101E98C; Tue, 23 Aug 2022 18:30:52 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F792C15BBA; Tue, 23 Aug 2022 18:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279456; 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=xBYkQK+5KnaDY4xdQ9EaxvQiPSuC/SCuSWflnwBLb0A=; b=jBlwHlW3xeyxGZC5yqpLIiGaahP71tLaPQUvdCfSeaGR1KdVxMTwBykGoUnulRpsJ3Qosz RqD+f1sZxFcq0X0e/xLTRnEX87cLFM7RZJuK7H96gwcjW45wE5Pke4QtEK6abxZ2gqLjow Twf2uQJnoBTVHAOsvuxDf5EsTT/aiuM= X-MC-Unique: _r8UkRMLNbqPeX0v0G9Few-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation Date: Tue, 23 Aug 2022 20:30:27 +0200 Message-Id: <20220823183037.98470-3-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.133.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280272235100001 Since we're going to allow SVQ to add elements without the guest's knowledge and without its own VirtQueueElement, it's easier to check if an element is a valid head checking a different thing than the VirtQueueElement. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index a1261d4a0f..b35aeef4bd 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -414,7 +414,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowV= irtqueue *svq, return NULL; } =20 - if (unlikely(!svq->desc_state[used_elem.id].elem)) { + if (unlikely(!svq->desc_state[used_elem.id].ndescs)) { qemu_log_mask(LOG_GUEST_ERROR, "Device %s says index %u is used, but it was not available", svq->vdev->name, used_elem.id); @@ -422,6 +422,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowV= irtqueue *svq, } =20 num =3D svq->desc_state[used_elem.id].ndescs; + svq->desc_state[used_elem.id].ndescs =3D 0; last_used_chain =3D vhost_svq_last_desc_of_chain(svq, num, used_elem.i= d); svq->desc_next[last_used_chain] =3D svq->free_head; svq->free_head =3D used_elem.id; --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280185; cv=none; d=zohomail.com; s=zohoarc; b=RURTbDelhjjbEtHPfzijcJim1ONe5tGcdIKO20zadF2G2MoZDn1n64pfWcndbtN4LuyZ58Q6E82egdU+5P/uTohtiY2OJKJiwwvcM7BXBQr8Q+0h6NwCYu4OdX9KNRdIbXCfRVFnbowz9WHUF1uHSqKrwRyd9EAWD/gAeDwSX44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280185; 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=FW20BsWIUhWefUcFTeDNVHYjnA7vJloMbPjcRJb+kUY=; b=C+V9OqVW+iAMYavq/OtoggJM+xAwTuIAQAqAajOaISl0QOKMDdfThEH6ct/2Igthgiff+73WRAEWCofVrV1uv2qDsgK2u37AIrrJNgdzimb1FFml0LtPAXXW1lhW1Z43HuhCR00rdgryVOgMKVjAbfpFoJP4hQe8vVHHbTo8+i4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280185688981.7043603803274; Tue, 23 Aug 2022 11:43:05 -0700 (PDT) Received: from localhost ([::1]:51076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYrg-0000US-JX for importer@patchew.org; Tue, 23 Aug 2022 14:43:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYg3-00009R-3w for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYg1-0004TX-5c for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:02 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-483-Nzr_3OBKOV22AR1oQ3KCoQ-1; Tue, 23 Aug 2022 14:30:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48CA51010362; Tue, 23 Aug 2022 18:30:56 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C073C15BB3; Tue, 23 Aug 2022 18:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279460; 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=FW20BsWIUhWefUcFTeDNVHYjnA7vJloMbPjcRJb+kUY=; b=AiPiy0kMeINbl91l8Z0v8RaSuYyTRla1iAt8w3OypeEdcUhSBZam3iLTBZXdYVi5lrpjq9 Y0qqrEbIOnsPuw8fT6kkMcespnv0CBB1HvcN6zT0pIOcSAaGD01p6xJgbHMRAWcyJJkGVh /rDPoTGcIj5NH0HvHBtZGYyHct6QUTU= X-MC-Unique: Nzr_3OBKOV22AR1oQ3KCoQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 03/12] vhost: Delete useless read memory barrier Date: Tue, 23 Aug 2022 20:30:28 +0200 Message-Id: <20220823183037.98470-4-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280187971100001 As discussed in previous series [1], this memory barrier is useless with the atomic read of used idx at vhost_svq_more_used. Deleting it. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02616.html Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index b35aeef4bd..8df5296f24 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -509,9 +509,6 @@ size_t vhost_svq_poll(VhostShadowVirtqueue *svq) if (unlikely(g_get_monotonic_time() - start_us > 10e6)) { return 0; } - - /* Make sure we read new used_idx */ - smp_rmb(); } while (true); } =20 --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280407; cv=none; d=zohomail.com; s=zohoarc; b=BHGSv/Rbpy/4AgAaM6qB5eh8GlLBqcUCIvtvuLLoc+Uozso+d7jzyStBUEcmpZ57XDXYaG4UOHfV0akjb7WojbyDuNJF55Y7yNQwIN35QvnW4AeqszUyOqRnfLdNOFtkvSfFefy8/DIxyncNKgr3IP0jLr0TzEFltuRFxFA1nUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280407; 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=QWQ9YRdR82DD5uwHUvIfW+1twM0pNqdoLDuXgi2Jaew=; b=S2axFzVx03guiZqi1hjl2xTAcy3dEfCVMVPf//6UEy1Z42DdtmNv5DfaqFiibgO44UrxKb3HlktOPjkvu1aEkQpvikSRCPOZI7TBRbLzBT+oGZ/aetavlJe+NvTPUkvRQcyjMNLZyVVyCd01p+B1bIjUkGx1tPG13mYEq4sfjxI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280407735979.6046974366358; Tue, 23 Aug 2022 11:46:47 -0700 (PDT) Received: from localhost ([::1]:48346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYvF-0006X4-An for importer@patchew.org; Tue, 23 Aug 2022 14:46:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYg7-0000GW-O3 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27134) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYg6-0004Tn-3z for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:07 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-6WuywD5WME6gvY4nQCfNig-1; Tue, 23 Aug 2022 14:31:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C0D0380115E; Tue, 23 Aug 2022 18:31:00 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 936B2C15BB3; Tue, 23 Aug 2022 18:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279465; 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=QWQ9YRdR82DD5uwHUvIfW+1twM0pNqdoLDuXgi2Jaew=; b=gD8AdabUnVonpx7TLqK5PmvC/kzmBjaPklTi9k2HirtYJDkBIhHCY+uUSlcDErRrsMZhT1 ejimiJzlSI9d78WW55P4Wxqn1iemGK86nPuvCclMzV5wXuaqGdtp8e4GXVLnncWNj1w3ql yp6So5kq2km1sta7q/VZxL816Gtc8M0= X-MC-Unique: 6WuywD5WME6gvY4nQCfNig-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush Date: Tue, 23 Aug 2022 20:30:29 +0200 Message-Id: <20220823183037.98470-5-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280408928100001 Since QEMU will be able to inject new elements on CVQ to restore the state, we need not to depend on a VirtQueueElement to know if a new element has been used by the device or not. Instead of check that, check if there are new elements only using used idx on vhost_svq_flush. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v6: Change less from the previous function --- hw/virtio/vhost-shadow-virtqueue.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index 8df5296f24..e8e5bbc368 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -499,17 +499,20 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq, size_t vhost_svq_poll(VhostShadowVirtqueue *svq) { int64_t start_us =3D g_get_monotonic_time(); + uint32_t len; + do { - uint32_t len; - VirtQueueElement *elem =3D vhost_svq_get_buf(svq, &len); - if (elem) { - return len; + if (vhost_svq_more_used(svq)) { + break; } =20 if (unlikely(g_get_monotonic_time() - start_us > 10e6)) { return 0; } } while (true); + + vhost_svq_get_buf(svq, &len); + return len; } =20 /** --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279843; cv=none; d=zohomail.com; s=zohoarc; b=lxG3sCtaK8WGlYt606KHagoSv57idydPJnveHQC53e56zhXKi/+sOzS9v7dMMbV+8iWMzhHP6Xjysze2j3dl3KJnWmnL7BoG6+Meap8sg7zrjDIHSxosXK5olvQZQtAG0LHvpWWHaMdill/0QH+H7Vxw/qxnidWLarVlANg+dro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279843; 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=FRxq8ciCEMSnJTweqk0QLYXUY8mWdYiCDr7lk4zv7tU=; b=ht5/aEQUdbXTcUB4ZRmuvkAcWhgvtJWWdB9qWxh1tpRMySAesg6Xw4map2MxRCm5UZ7kF7IidWtw1bV1fA+VW63bSULMSjIx+/m/t/uA0E5Csa54HaUF86WvinH1MHvKbmU0ojX/PcVLZQL6v0mKy2aEKlzL51HFl+q/BgbliTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279843385975.6902802149684; Tue, 23 Aug 2022 11:37:23 -0700 (PDT) Received: from localhost ([::1]:54116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYm9-0003I8-Bs for importer@patchew.org; Tue, 23 Aug 2022 14:37:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgG-0000Jk-Fn for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgB-0004U2-I3 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:12 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-9-naAhz8acNga_5s9fQJELzw-1; Tue, 23 Aug 2022 14:31:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2B4285A589; Tue, 23 Aug 2022 18:31:03 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id D77DAC15BBA; Tue, 23 Aug 2022 18:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279470; 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=FRxq8ciCEMSnJTweqk0QLYXUY8mWdYiCDr7lk4zv7tU=; b=ECb36pRcDluT3K/V/m8H4KLJVxKDOQkV5O+JDHuPYhelhrZSInNspOzi8hjTimxFLsWU/X oc+xNJRybbA6F6roye8OteVShoYF85L/LvFzEQV4AVteBO0YpBX3ozQsUJ3b0LcF61aMZU K5E42OwKlCqT4cLuNH8hoz8MYxVjFcc= X-MC-Unique: naAhz8acNga_5s9fQJELzw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 05/12] vhost_net: Add NetClientInfo start callback Date: Tue, 23 Aug 2022 20:30:30 +0200 Message-Id: <20220823183037.98470-6-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279845858100002 This is used by the backend to perform actions before the device is started. In particular, vdpa net use it to map CVQ buffers to the device, so it can send control commands using them. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v9: Rename also in patch message v8: Rename NetClientInfo prepare callback to start, so it aligns with future "stop" --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 523136c7ac..ad9e80083a 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -44,6 +44,7 @@ typedef struct NICConf { =20 typedef void (NetPoll)(NetClientState *, bool enable); typedef bool (NetCanReceive)(NetClientState *); +typedef int (NetStart)(NetClientState *); typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, in= t); typedef void (NetCleanup) (NetClientState *); @@ -71,6 +72,7 @@ typedef struct NetClientInfo { NetReceive *receive_raw; NetReceiveIOV *receive_iov; NetCanReceive *can_receive; + NetStart *start; NetCleanup *cleanup; LinkStatusChanged *link_status_changed; QueryRxFilter *query_rx_filter; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index ccac5b7a64..2e0baeba26 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -244,6 +244,13 @@ static int vhost_net_start_one(struct vhost_net *net, struct vhost_vring_file file =3D { }; int r; =20 + if (net->nc->info->start) { + r =3D net->nc->info->start(net->nc); + if (r < 0) { + return r; + } + } + r =3D vhost_dev_enable_notifiers(&net->dev, dev); if (r < 0) { goto fail_notifiers; --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279843; cv=none; d=zohomail.com; s=zohoarc; b=G/5AD3DN4gB7/OL+Rgp2wXyDCYhpfgDDPpiqXhPegv0xarTfebLq9a4sWBeHrlDZNhhO7r5/NAG626XVFnNRcK+4zAnsrpWQLmtn9EUTrOL8TFPujMYcEZoUT9GsvOnaMPyg0BLCMyevRlTulytrnhhhF9VY0RimBEgmBcl5zZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279843; 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=WlpLoJjbF+OwV7CNK6PkYjMOGlAsT4R2CbMa+M7daEg=; b=A88WwlD2+nOr/WDNdbgzma2Wi7UDLsqcLWROB/+GLY15v/urzOaPH9fKxSQCqjwUFVqEQI2SQfed27i9jrm3i98iI4KxKwcPIXz5KEg/b0V9VT/0uMqdB3A/HGj2pnUGlbAwr9JbAL2HHl6lYfdUkrpbgbai+mAsMDo/E7DMRRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279843707127.63270379190203; Tue, 23 Aug 2022 11:37:23 -0700 (PDT) Received: from localhost ([::1]:54028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYmA-0003Cu-Nc for importer@patchew.org; Tue, 23 Aug 2022 14:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgK-0000Jq-8f for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgE-0004UA-HK for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:19 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-496-crfgc7fXN_-h95uhe3maQA-1; Tue, 23 Aug 2022 14:31:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71ED13806723; Tue, 23 Aug 2022 18:31:07 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10960C15BB3; Tue, 23 Aug 2022 18:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279472; 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=WlpLoJjbF+OwV7CNK6PkYjMOGlAsT4R2CbMa+M7daEg=; b=fCUHZfpv7GMsFfuswcYm8KXSsMgKSzuqcRWzs/H3nBs+eFZYJANmocodeMV+Y0lOQrWBTz uJbXQ8gKPPtJgL2qw/8F3Ia5UKXaoWGuTB3o+lzcFlj6lCnouBmwrYPNImQ+d2DKU4Cld/ G/kzvzWEKGJA3TO1HgGG2Q6RtkGubgI= X-MC-Unique: crfgc7fXN_-h95uhe3maQA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 06/12] vhost_net: Add NetClientInfo stop callback Date: Tue, 23 Aug 2022 20:30:31 +0200 Message-Id: <20220823183037.98470-7-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.133.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279845820100001 Used by the backend to perform actions after the device is stopped. In particular, vdpa net use it to unmap CVQ buffers to the device, cleaning the actions performed in prepare(). Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v9: Replace performend by performed in patch message --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index ad9e80083a..476ad45b9a 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -45,6 +45,7 @@ typedef struct NICConf { typedef void (NetPoll)(NetClientState *, bool enable); typedef bool (NetCanReceive)(NetClientState *); typedef int (NetStart)(NetClientState *); +typedef void (NetStop)(NetClientState *); typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, in= t); typedef void (NetCleanup) (NetClientState *); @@ -73,6 +74,7 @@ typedef struct NetClientInfo { NetReceiveIOV *receive_iov; NetCanReceive *can_receive; NetStart *start; + NetStop *stop; NetCleanup *cleanup; LinkStatusChanged *link_status_changed; QueryRxFilter *query_rx_filter; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 2e0baeba26..9d4b334453 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -320,6 +320,9 @@ static void vhost_net_stop_one(struct vhost_net *net, net->nc->info->poll(net->nc, true); } vhost_dev_stop(&net->dev, dev); + if (net->nc->info->stop) { + net->nc->info->stop(net->nc); + } vhost_dev_disable_notifiers(&net->dev, dev); } =20 --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280192; cv=none; d=zohomail.com; s=zohoarc; b=FR1geSlNaurFopqQDv7XvMGLfOAlX+X+yv2x/hgkSlj3rgpBbLmSvk1kOzvE20TximIW7uEPRlwuAQPE9sIUKvs7JB5t6BOFgbfY95KPLmXR94YtpRyqX3dMkYRYsGrMnjk5Anu54mfweC4xpicrmcyeOOD+OXAlkOGf/psydtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280192; 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=vUVC2aZB37d/pnkcpQ+saEdmfc9yBsesAmIjYuQKXUY=; b=WgGxNC6IdJZETG1+XfEWZflVkl+BVQclf/Q/P4yWkiNm9GxGG4+wFvAGKcAQ7qXXIVPuCpYTu2A4A78donP4yEe3gIIUu7hzO6qAYFTVAnwj65W87m2bd64bR16je0HC2fLoOgN3fLGIH4QBWuAAhnJ82JWAz1i8kVC/uSF8vNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280192858125.3551973433639; Tue, 23 Aug 2022 11:43:12 -0700 (PDT) Received: from localhost ([::1]:39024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYrm-0000zw-Qr for importer@patchew.org; Tue, 23 Aug 2022 14:43:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgl-0000Pb-Lh for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgH-0004UE-6P for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:20 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-SffNuKD2NzWNa8j3JMuKUg-1; Tue, 23 Aug 2022 14:31:11 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93DE029DD9AC; Tue, 23 Aug 2022 18:31:10 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5356C15BB3; Tue, 23 Aug 2022 18:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279473; 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=vUVC2aZB37d/pnkcpQ+saEdmfc9yBsesAmIjYuQKXUY=; b=chMLtZXbwMUmz9CFUcQuOlIw2lYr/IVSYfyKN1RkbvfHe0I1sd/fyKDOFyqLUF22Lh6W35 fFl7h+DEzgffiqX1UjKZjcwmyDaRc4qOVN6/rqi6i9jqf78pzFSI2RrHoolqU0NQcvUxgo hV/scvWqPThqoyNlUN1CZv0gvF727NQ= X-MC-Unique: SffNuKD2NzWNa8j3JMuKUg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo Date: Tue, 23 Aug 2022 20:30:32 +0200 Message-Id: <20220823183037.98470-8-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280193896100001 Next patches will add a new info callback to restore NIC status through CVQ. Since only the CVQ vhost device is needed, create it with a new NetClientInfo. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v5: Create a new NetClientInfo instead of reusing the dataplane one. --- net/vhost-vdpa.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a49e7e649d..1a597c2e92 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -334,6 +334,16 @@ static bool vhost_vdpa_net_cvq_map_elem(VhostVDPAState= *s, return true; } =20 +static NetClientInfo net_vhost_vdpa_cvq_info =3D { + .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, + .size =3D sizeof(VhostVDPAState), + .receive =3D vhost_vdpa_receive, + .cleanup =3D vhost_vdpa_cleanup, + .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, + .has_ufo =3D vhost_vdpa_has_ufo, + .check_peer_type =3D vhost_vdpa_check_peer_type, +}; + /** * Do not forward commands not supported by SVQ. Otherwise, the device cou= ld * accept it and qemu would not know how to update the device model. @@ -475,7 +485,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); } else { - nc =3D qemu_new_net_control_client(&net_vhost_vdpa_info, peer, + nc =3D qemu_new_net_control_client(&net_vhost_vdpa_cvq_info, peer, device, name); } snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280412; cv=none; d=zohomail.com; s=zohoarc; b=MrOGoR7AG1tZRsS1MjQ0sr+ELmfJZIj6ZLMj69EXzyTTvYdnT9uhJfkeuLvCdjwLvH04JSV1gTYx6/htjZoO0sCpC8cEdv6WPyQGC8jIsTqu1Dy2tH7NDl4m6d9L3pw142aQt7650ziC4+zseqeBG4RiKwZ/NjToK/QCFQX31hI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280412; 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=eKzxsPHGHvQAbY/8k5H9OzcMC/ApzkOWYeKME/8/iI8=; b=cU1hQ/6g+BgxVnVgi3Wl9/hlAq8vY8FcMBDY7goaVHLcpZwZyJFjfQgplz8XI10rosc+SFaOcIPW1H8ISJyynIrHfd67kgldKtwjsCMzwA9wBONavJdEfqpXVD9tFupn6L/sINI0mS8GY7Gw0TMoNeXDzoM4M1oX8TKO5NvY1rg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280412909105.46362871531062; Tue, 23 Aug 2022 11:46:52 -0700 (PDT) Received: from localhost ([::1]:46632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYvK-0006jh-M1 for importer@patchew.org; Tue, 23 Aug 2022 14:46:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgn-0000QH-E7 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgg-0004UV-0u for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:49 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-332-8IvfInLKObS2G4nc3MQPUQ-1; Tue, 23 Aug 2022 14:31:15 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C413C823F62; Tue, 23 Aug 2022 18:31:13 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3B9DC15BBA; Tue, 23 Aug 2022 18:31:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279480; 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=eKzxsPHGHvQAbY/8k5H9OzcMC/ApzkOWYeKME/8/iI8=; b=BYdPm/9GX8xuNfo0YzpRMmf8/b5ova4k5b6Gh/TrREFMPHiREc3DpVdh6/jPnK9vbz0G1g IP5T6/dfwnfJZbBeMt697OG2huWztqwe3GAZKY29o+V+1W0uh5KHkNGabNEQcPoNfm9+pF dVDBhhSfS+j1vXzEy1do/ccyYPZGL2g= X-MC-Unique: 8IvfInLKObS2G4nc3MQPUQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 08/12] vdpa: Move command buffers map to start of net device Date: Tue, 23 Aug 2022 20:30:33 +0200 Message-Id: <20220823183037.98470-9-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.133.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280415172100001 As this series will reuse them to restore the device state at the end of a migration (or a device start), let's allocate only once at the device start so we don't duplicate their map and unmap. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v10: Solve conflict on vhost_iova_tree_remove call by value --- net/vhost-vdpa.c | 123 ++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1a597c2e92..452d10ed93 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -263,29 +263,20 @@ static size_t vhost_vdpa_net_cvq_cmd_page_len(void) return ROUND_UP(vhost_vdpa_net_cvq_cmd_len(), qemu_real_host_page_size= ()); } =20 -/** Copy and map a guest buffer. */ -static bool vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, - const struct iovec *out_data, - size_t out_num, size_t data_len, void *= buf, - size_t *written, bool write) +/** Map CVQ buffer. */ +static int vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, void *buf, size_t = size, + bool write) { DMAMap map =3D {}; int r; =20 - if (unlikely(!data_len)) { - qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid legnth of %s buffer\n", - __func__, write ? "in" : "out"); - return false; - } - - *written =3D iov_to_buf(out_data, out_num, 0, buf, data_len); map.translated_addr =3D (hwaddr)(uintptr_t)buf; - map.size =3D vhost_vdpa_net_cvq_cmd_page_len() - 1; + map.size =3D size - 1; map.perm =3D write ? IOMMU_RW : IOMMU_RO, r =3D vhost_iova_tree_map_alloc(v->iova_tree, &map); if (unlikely(r !=3D IOVA_OK)) { error_report("Cannot map injected element"); - return false; + return r; } =20 r =3D vhost_vdpa_dma_map(v, map.iova, vhost_vdpa_net_cvq_cmd_page_len(= ), buf, @@ -294,50 +285,58 @@ static bool vhost_vdpa_cvq_map_buf(struct vhost_vdpa = *v, goto dma_map_err; } =20 - return true; + return 0; =20 dma_map_err: vhost_iova_tree_remove(v->iova_tree, map); - return false; + return r; } =20 -/** - * Copy the guest element into a dedicated buffer suitable to be sent to N= IC - * - * @iov: [0] is the out buffer, [1] is the in one - */ -static bool vhost_vdpa_net_cvq_map_elem(VhostVDPAState *s, - VirtQueueElement *elem, - struct iovec *iov) +static int vhost_vdpa_net_cvq_start(NetClientState *nc) { - size_t in_copied; - bool ok; + VhostVDPAState *s; + int r; =20 - iov[0].iov_base =3D s->cvq_cmd_out_buffer; - ok =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, elem->out_sg, elem->out_= num, - vhost_vdpa_net_cvq_cmd_len(), iov[0].iov_b= ase, - &iov[0].iov_len, false); - if (unlikely(!ok)) { - return false; + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + s =3D DO_UPCAST(VhostVDPAState, nc, nc); + if (!s->vhost_vdpa.shadow_vqs_enabled) { + return 0; } =20 - iov[1].iov_base =3D s->cvq_cmd_in_buffer; - ok =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, NULL, 0, - sizeof(virtio_net_ctrl_ack), iov[1].iov_ba= se, - &in_copied, true); - if (unlikely(!ok)) { + r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer, + vhost_vdpa_net_cvq_cmd_page_len(), false); + if (unlikely(r < 0)) { + return r; + } + + r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer, + vhost_vdpa_net_cvq_cmd_page_len(), true); + if (unlikely(r < 0)) { vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); - return false; } =20 - iov[1].iov_len =3D sizeof(virtio_net_ctrl_ack); - return true; + return r; +} + +static void vhost_vdpa_net_cvq_stop(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + if (s->vhost_vdpa.shadow_vqs_enabled) { + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer); + } } =20 static NetClientInfo net_vhost_vdpa_cvq_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), .receive =3D vhost_vdpa_receive, + .start =3D vhost_vdpa_net_cvq_start, + .stop =3D vhost_vdpa_net_cvq_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, .has_ufo =3D vhost_vdpa_has_ufo, @@ -348,19 +347,17 @@ static NetClientInfo net_vhost_vdpa_cvq_info =3D { * Do not forward commands not supported by SVQ. Otherwise, the device cou= ld * accept it and qemu would not know how to update the device model. */ -static bool vhost_vdpa_net_cvq_validate_cmd(const struct iovec *out, - size_t out_num) +static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t le= n) { struct virtio_net_ctrl_hdr ctrl; - size_t n; =20 - n =3D iov_to_buf(out, out_num, 0, &ctrl, sizeof(ctrl)); - if (unlikely(n < sizeof(ctrl))) { + if (unlikely(len < sizeof(ctrl))) { qemu_log_mask(LOG_GUEST_ERROR, - "%s: invalid legnth of out buffer %zu\n", __func__, = n); + "%s: invalid legnth of out buffer %zu\n", __func__, = len); return false; } =20 + memcpy(&ctrl, out_buf, sizeof(ctrl)); switch (ctrl.class) { case VIRTIO_NET_CTRL_MAC: switch (ctrl.cmd) { @@ -392,10 +389,14 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, VhostVDPAState *s =3D opaque; size_t in_len, dev_written; virtio_net_ctrl_ack status =3D VIRTIO_NET_ERR; - /* out and in buffers sent to the device */ - struct iovec dev_buffers[2] =3D { - { .iov_base =3D s->cvq_cmd_out_buffer }, - { .iov_base =3D s->cvq_cmd_in_buffer }, + /* Out buffer sent to both the vdpa device and the device model */ + struct iovec out =3D { + .iov_base =3D s->cvq_cmd_out_buffer, + }; + /* In buffer sent to the device */ + const struct iovec dev_in =3D { + .iov_base =3D s->cvq_cmd_in_buffer, + .iov_len =3D sizeof(virtio_net_ctrl_ack), }; /* in buffer used for device model */ const struct iovec in =3D { @@ -405,17 +406,15 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, int r =3D -EINVAL; bool ok; =20 - ok =3D vhost_vdpa_net_cvq_map_elem(s, elem, dev_buffers); - if (unlikely(!ok)) { - goto out; - } - - ok =3D vhost_vdpa_net_cvq_validate_cmd(&dev_buffers[0], 1); + out.iov_len =3D iov_to_buf(elem->out_sg, elem->out_num, 0, + s->cvq_cmd_out_buffer, + vhost_vdpa_net_cvq_cmd_len()); + ok =3D vhost_vdpa_net_cvq_validate_cmd(s->cvq_cmd_out_buffer, out.iov_= len); if (unlikely(!ok)) { goto out; } =20 - r =3D vhost_svq_add(svq, &dev_buffers[0], 1, &dev_buffers[1], 1, elem); + r =3D vhost_svq_add(svq, &out, 1, &dev_in, 1, elem); if (unlikely(r !=3D 0)) { if (unlikely(r =3D=3D -ENOSPC)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n= ", @@ -435,13 +434,13 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, goto out; } =20 - memcpy(&status, dev_buffers[1].iov_base, sizeof(status)); + memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status)); if (status !=3D VIRTIO_NET_OK) { goto out; } =20 status =3D VIRTIO_NET_ERR; - virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, dev_buffers, 1); + virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1); if (status !=3D VIRTIO_NET_OK) { error_report("Bad CVQ processing in model"); } @@ -454,12 +453,6 @@ out: } vhost_svq_push_elem(svq, elem, MIN(in_len, sizeof(status))); g_free(elem); - if (dev_buffers[0].iov_base) { - vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, dev_buffers[0].iov_base); - } - if (dev_buffers[1].iov_base) { - vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, dev_buffers[1].iov_base); - } return r; } =20 --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280788; cv=none; d=zohomail.com; s=zohoarc; b=CWJWgqRrEe3jz2VOOErvAPx6C1PyfhyDDVzWT7F4snH9VU6oonDpiJdYh8eSub0YapMp1hI1Esm8gROnT8euXKHthN4mdQiOrjcyAeyBiR6lMAojCkokSw6HQTna41WR+R8mvLR7yJf55q50teEm+pjEQLgKBqe1LO7r2L+w390= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280788; 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=xG5CT0lUMxZf0HeT0TRljoOHN+I5Ro7r7pr28EyK1bM=; b=e+GP2/FbaHd4PnQglRoiQQMPJt36SXmW9v01L0rJOISYD2E8NRpxMk+EQNf3sNiaxY65F0wYGU+RiblmPgkXa+GgFCc2rl463CyZXbUBd66fACSvEIfIdMIqVFOuOLq5Am9fDJTHqzcEnpemc2drREkWUs4G9rA/ZGiAZqmt2K4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280788822297.0809787931007; Tue, 23 Aug 2022 11:53:08 -0700 (PDT) Received: from localhost ([::1]:50628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQZ1O-00047c-PG for importer@patchew.org; Tue, 23 Aug 2022 14:53:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgp-0000QL-89 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgl-0004UZ-UY for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-WCJv3V54OliOsX-hUBHAvg-1; Tue, 23 Aug 2022 14:31:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6DEB5811E90; Tue, 23 Aug 2022 18:31:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DD1AC15BB3; Tue, 23 Aug 2022 18:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279480; 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=xG5CT0lUMxZf0HeT0TRljoOHN+I5Ro7r7pr28EyK1bM=; b=dXc9ostul1WhLb2ra3tmSXNgeLM7nmPUPZWC4oIvAI0PszoErQjduNlOFAoGu4iWNCFJ8F YYtFWOhdQzNwXzM9MnjhzLsvt1UbqomywOhemw1LrVeLqNGCmIDAOAwdUBrY4r8vdPw7TR qu+g0FZ2tSXJRaPLVrK6S1uEP4fsBKM= X-MC-Unique: WCJv3V54OliOsX-hUBHAvg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 09/12] vdpa: extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Tue, 23 Aug 2022 20:30:34 +0200 Message-Id: <20220823183037.98470-10-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280790717100001 So we can reuse it to inject state messages. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang -- v7: * Remove double free error v6: * Do not assume in buffer sent to the device is sizeof(virtio_net_ctrl_ack) v5: * Do not use an artificial !NULL VirtQueueElement * Use only out size instead of iovec dev_buffers for these functions. --- net/vhost-vdpa.c | 59 +++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 452d10ed93..3575bf64ee 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -331,6 +331,38 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) } } =20 +static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len, + size_t in_len) +{ + /* Buffers for the device */ + const struct iovec out =3D { + .iov_base =3D s->cvq_cmd_out_buffer, + .iov_len =3D out_len, + }; + const struct iovec in =3D { + .iov_base =3D s->cvq_cmd_in_buffer, + .iov_len =3D sizeof(virtio_net_ctrl_ack), + }; + VhostShadowVirtqueue *svq =3D g_ptr_array_index(s->vhost_vdpa.shadow_v= qs, 0); + int r; + + r =3D vhost_svq_add(svq, &out, 1, &in, 1, NULL); + if (unlikely(r !=3D 0)) { + if (unlikely(r =3D=3D -ENOSPC)) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n= ", + __func__); + } + return r; + } + + /* + * We can poll here since we've had BQL from the time we sent the + * descriptor. Also, we need to take the answer before SVQ pulls by it= self, + * when BQL is released + */ + return vhost_svq_poll(svq); +} + static NetClientInfo net_vhost_vdpa_cvq_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), @@ -387,23 +419,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, void *opaque) { VhostVDPAState *s =3D opaque; - size_t in_len, dev_written; + size_t in_len; virtio_net_ctrl_ack status =3D VIRTIO_NET_ERR; /* Out buffer sent to both the vdpa device and the device model */ struct iovec out =3D { .iov_base =3D s->cvq_cmd_out_buffer, }; - /* In buffer sent to the device */ - const struct iovec dev_in =3D { - .iov_base =3D s->cvq_cmd_in_buffer, - .iov_len =3D sizeof(virtio_net_ctrl_ack), - }; /* in buffer used for device model */ const struct iovec in =3D { .iov_base =3D &status, .iov_len =3D sizeof(status), }; - int r =3D -EINVAL; + ssize_t dev_written =3D -EINVAL; bool ok; =20 out.iov_len =3D iov_to_buf(elem->out_sg, elem->out_num, 0, @@ -414,21 +441,11 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, goto out; } =20 - r =3D vhost_svq_add(svq, &out, 1, &dev_in, 1, elem); - if (unlikely(r !=3D 0)) { - if (unlikely(r =3D=3D -ENOSPC)) { - qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n= ", - __func__); - } + dev_written =3D vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status)); + if (unlikely(dev_written < 0)) { goto out; } =20 - /* - * We can poll here since we've had BQL from the time we sent the - * descriptor. Also, we need to take the answer before SVQ pulls by it= self, - * when BQL is released - */ - dev_written =3D vhost_svq_poll(svq); if (unlikely(dev_written < sizeof(status))) { error_report("Insufficient written data (%zu)", dev_written); goto out; @@ -436,7 +453,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadow= Virtqueue *svq, =20 memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status)); if (status !=3D VIRTIO_NET_OK) { - goto out; + return VIRTIO_NET_ERR; } =20 status =3D VIRTIO_NET_ERR; @@ -453,7 +470,7 @@ out: } vhost_svq_push_elem(svq, elem, MIN(in_len, sizeof(status))); g_free(elem); - return r; + return dev_written < 0 ? dev_written : 0; } =20 static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops =3D { --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280660; cv=none; d=zohomail.com; s=zohoarc; b=Vb/qVVcWDcm07TTgQnH6hsARG93m1R+67enQxTrOhDphwrGtFM/5b9UtW68OyYLJimUV9SJy5nd3kU7XrCrnqKdqh2EgC3w4cXLyNzZYh1C52At/kaj48N6aXMZ5u7SY0bQP407TxbpDeeU3F1rzI7Ti4ZjHjtYQMRPubsvChqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280660; 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=PdIb3W14cumQFNdhDPoV8yUwQEomsAtIsjTleyRBfc4=; b=l6iv8cLd0fnSMAuF2AXxtUkafHP6gMFwuU6ojnL+duWdERidVmcbHlmMXFZ8pEE5hivaCnfoM2FiiBAw/UW1Ju7BekCk9Y6akneOpxIvFs09Ay06JiflHA5kWWvIR9f4qSG+P7yJMEepipD2RDChD4tI80sr85lNRyFaTA4vAjk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280660426124.96945185807692; Tue, 23 Aug 2022 11:51:00 -0700 (PDT) Received: from localhost ([::1]:53438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYzJ-00019v-Pq for importer@patchew.org; Tue, 23 Aug 2022 14:50:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgo-0000QJ-Qa for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgl-0004Ug-E4 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-271-SDdNlk0HO7ebAdIUEjtzeQ-1; Tue, 23 Aug 2022 14:31:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FCB88037B7; Tue, 23 Aug 2022 18:31:21 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFE41C15BB3; Tue, 23 Aug 2022 18:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279485; 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=PdIb3W14cumQFNdhDPoV8yUwQEomsAtIsjTleyRBfc4=; b=NuGkoMwipbb2SXw/iworDvRqFqCYAn3xnbbWXQe1YjGCt/U7QCHgI7XHuip7ZOz1XjrkAC QXgAxI+oeWRN+o9VYJ7PbJ+miTVgWmddFaZQwW+bjLFhajHTejYSgezlTljp4FtfpGJQLG SSOWf9yk4ty2J9riuGcnl9VuoUNz4Vc= X-MC-Unique: SDdNlk0HO7ebAdIUEjtzeQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 10/12] vhost_net: add NetClientState->load() callback Date: Tue, 23 Aug 2022 20:30:35 +0200 Message-Id: <20220823183037.98470-11-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280660908100001 It allows per-net client operations right after device's successful start. In particular, to load the device status. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v5: Rename start / load, naming it more specifically. --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 476ad45b9a..81d0b21def 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -45,6 +45,7 @@ typedef struct NICConf { typedef void (NetPoll)(NetClientState *, bool enable); typedef bool (NetCanReceive)(NetClientState *); typedef int (NetStart)(NetClientState *); +typedef int (NetLoad)(NetClientState *); typedef void (NetStop)(NetClientState *); typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, in= t); @@ -74,6 +75,7 @@ typedef struct NetClientInfo { NetReceiveIOV *receive_iov; NetCanReceive *can_receive; NetStart *start; + NetLoad *load; NetStop *stop; NetCleanup *cleanup; LinkStatusChanged *link_status_changed; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 9d4b334453..d28f8b974b 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -281,6 +281,13 @@ static int vhost_net_start_one(struct vhost_net *net, } } } + + if (net->nc->info->load) { + r =3D net->nc->info->load(net->nc); + if (r < 0) { + goto fail; + } + } return 0; fail: file.fd =3D -1; --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661280958; cv=none; d=zohomail.com; s=zohoarc; b=GHblXifT/KjodX8IZHT3O37rePWZHEixlZ+cu4t/AvIq23SHSnFnVAuzbuSpUUj5Xr2DJlcv6WTc3BPiL+ICULnC0AkHaaHnga6FvlyTXMrT1rIl06EBrz5IalPFutVEjEH9L6NFyBQbAt7oDsU5zKNGFNIKLDW85hpxKllZ06I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661280958; 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=qjWgUgP1z6U909pxvnBqHeZBZLakankBVQWj1wVAMTg=; b=PgUQg1i4yhwQGycdYBEn1gMWI1iQDJu1KdulWZgx0pL8FzFDiP8CbIYXqGHScLv4c0iV2eaK6wJU4uNajQIn2tosJ++aNzDPZmd33oJqpiue21FTXzGMbSQg9vjvosgihUBGOCQw69qC5+qodH1QosIlTgss+uthnNAHzZCIroo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661280958352407.3938933366944; Tue, 23 Aug 2022 11:55:58 -0700 (PDT) Received: from localhost ([::1]:53916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQZ47-0000S3-Iz for importer@patchew.org; Tue, 23 Aug 2022 14:55:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgp-0000QM-9r for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47251) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgl-0004Us-Uq for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:51 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-FZV8NG29NPWTK6Cestuukw-1; Tue, 23 Aug 2022 14:31:25 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E23B294EDC6; Tue, 23 Aug 2022 18:31:24 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83F9EC15BB3; Tue, 23 Aug 2022 18:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279489; 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=qjWgUgP1z6U909pxvnBqHeZBZLakankBVQWj1wVAMTg=; b=D1Kip9W3Jl24kdE+I/b2G93N5mv81wFQ5vLFnEk4LvCS1yPkQ/COk+qLveAaldUaROfpal 5xZs/uFksiwyhyeeWb6KpF2oZY6/r1ima+CUGN3aBsQseTZjgfTBQjXqoHFsHnU3abawtY VfnPKY4D/VaPGH4edsYVO1Mm3cdc65U= X-MC-Unique: FZV8NG29NPWTK6Cestuukw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 11/12] vdpa: Add virtio-net mac address via CVQ at start Date: Tue, 23 Aug 2022 20:30:36 +0200 Message-Id: <20220823183037.98470-12-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661280959077100001 This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- v9: * Use guest acked features instead of device's. * Constify vhost_vdpa and VirtIONet variables. * Delete unneeded increment of cursor. v8: * Delete unneeded copy from device's in buffer. v6: * Map and unmap command buffers at the start and end of device usage. v5: * Rename s/start/load/ * Use independent NetClientInfo to only add load callback on cvq. --- net/vhost-vdpa.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3575bf64ee..640434d1ea 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -363,11 +363,51 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState = *s, size_t out_len, return vhost_svq_poll(svq); } =20 +static int vhost_vdpa_net_load(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + const struct vhost_vdpa *v =3D &s->vhost_vdpa; + const VirtIONet *n; + uint64_t features; + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + if (!v->shadow_vqs_enabled) { + return 0; + } + + n =3D VIRTIO_NET(v->dev->vdev); + features =3D n->parent_obj.guest_features; + if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) { + const struct virtio_net_ctrl_hdr ctrl =3D { + .class =3D VIRTIO_NET_CTRL_MAC, + .cmd =3D VIRTIO_NET_CTRL_MAC_ADDR_SET, + }; + char *cursor =3D s->cvq_cmd_out_buffer; + ssize_t dev_written; + + memcpy(cursor, &ctrl, sizeof(ctrl)); + cursor +=3D sizeof(ctrl); + memcpy(cursor, n->mac, sizeof(n->mac)); + + dev_written =3D vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + sizeof(n-= >mac), + sizeof(virtio_net_ctrl_ack)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) !=3D VIRTIO_= NET_OK; + } + + return 0; +} + static NetClientInfo net_vhost_vdpa_cvq_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), .receive =3D vhost_vdpa_receive, .start =3D vhost_vdpa_net_cvq_start, + .load =3D vhost_vdpa_net_load, .stop =3D vhost_vdpa_net_cvq_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, --=20 2.31.1 From nobody Thu May 9 22:30:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661281056; cv=none; d=zohomail.com; s=zohoarc; b=NgyE208shKtUmKXpTd61qzaXSbF35CXxKpA8SyV7xknH6agHDevajuSr1MrWMfAKSY3uoUspShb/VXVDLGPhX/dGqY2V3cuSDIhn/1bWb8IpbQdIfBhA4awxPiH8OwIx+C9zSiCNfM6Cfvzrtv/iHcm2wACshY9wGnmlw3ZaU6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661281056; 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=H6UNOTTwjb9/JGAV61+drQA/RK8go9Kptgh7fY2TS9c=; b=Q8PbxwMNUyYlorV4+IRZhxokfzSDx12ZwLqdS+aR+KquND8L3r2uUbrXYtr7zUgl4sNKWk8elBzhVVqN5JpxmqnsxI2bV2TEYWLMRJUjtRq8huFXHHkGD3cYsim8bclsTIpqyFqiUNGcbiovQOCor6LwRmfSEg5cODF0raLL0fc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661281056179146.59998679706177; Tue, 23 Aug 2022 11:57:36 -0700 (PDT) Received: from localhost ([::1]:52074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQZ5j-0004KN-2o for importer@patchew.org; Tue, 23 Aug 2022 14:57:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgq-0000QK-3c for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYgl-0004WC-U2 for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:31:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-397-H2uAHNXfN8uRzvn8xJoaKw-1; Tue, 23 Aug 2022 14:31:30 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D9D988039CF; Tue, 23 Aug 2022 18:31:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5096C15BB3; Tue, 23 Aug 2022 18:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661279494; 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=H6UNOTTwjb9/JGAV61+drQA/RK8go9Kptgh7fY2TS9c=; b=XxjCYzRY40uj4Sj3n5TR3eXVo5GyPPQysLLAxHh+oUvK1x8UQVurUdjauFmiK/WaDHiEZa L/13Pet4dhWTP5NbV2V74r1Iq4X08Ih73sXfQ5vRjrowEAVHDUzpjPTCoKEXnorH45AyWD xPAPW4bs5hIF6FwJKrIKxuEN+tub/78= X-MC-Unique: H2uAHNXfN8uRzvn8xJoaKw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Parav Pandit , Liuxiangdong , Markus Armbruster , Stefan Hajnoczi , Eric Blake , Zhu Lingshan , Paolo Bonzini , "Gonglei (Arei)" , Eli Cohen , Cornelia Huck , Gautam Dawar , Jason Wang , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand , Cindy Lu Subject: [PATCH v10 12/12] vdpa: Delete CVQ migration blocker Date: Tue, 23 Aug 2022 20:30:37 +0200 Message-Id: <20220823183037.98470-13-eperezma@redhat.com> In-Reply-To: <20220823183037.98470-1-eperezma@redhat.com> References: <20220823183037.98470-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.85 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661281058314100001 We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- include/hw/virtio/vhost-vdpa.h | 1 - hw/virtio/vhost-vdpa.c | 15 --------------- net/vhost-vdpa.c | 2 -- 3 files changed, 18 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index d10a89303e..1111d85643 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -35,7 +35,6 @@ typedef struct vhost_vdpa { bool shadow_vqs_enabled; /* IOVA mapping used by the Shadow Virtqueue */ VhostIOVATree *iova_tree; - Error *migration_blocker; GPtrArray *shadow_vqs; const VhostShadowVirtqueueOps *shadow_vq_ops; void *shadow_vq_ops_opaque; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 23ae5ef48b..7468e44b87 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1033,13 +1033,6 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *= dev) return true; } =20 - if (v->migration_blocker) { - int r =3D migrate_add_blocker(v->migration_blocker, &err); - if (unlikely(r < 0)) { - return false; - } - } - for (i =3D 0; i < v->shadow_vqs->len; ++i) { VirtQueue *vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); @@ -1082,10 +1075,6 @@ err: vhost_svq_stop(svq); } =20 - if (v->migration_blocker) { - migrate_del_blocker(v->migration_blocker); - } - return false; } =20 @@ -1101,10 +1090,6 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *d= ev) VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); vhost_vdpa_svq_unmap_rings(dev, svq); } - - if (v->migration_blocker) { - migrate_del_blocker(v->migration_blocker); - } } =20 static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 640434d1ea..6ce68fcd3f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -555,8 +555,6 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, =20 s->vhost_vdpa.shadow_vq_ops =3D &vhost_vdpa_net_svq_ops; s->vhost_vdpa.shadow_vq_ops_opaque =3D s; - error_setg(&s->vhost_vdpa.migration_blocker, - "Migration disabled: vhost-vdpa uses CVQ."); } ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, n= vqs); if (ret) { --=20 2.31.1