From nobody Fri May 3 18:00:15 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=1660930185; cv=none; d=zohomail.com; s=zohoarc; b=GZzf/CmPMwEJXX+ZeNPF2OaYQXBRJwzwhDpisZGQfRgJd4TdkSUGAhxR6rnV2ajzg/99vQUUKgTt0oc5f/XQi7NphQnuQOS/mYKAU56DkG0ih58czK0LzxnGkCZlozpMp7MDUcMFMPQX3yHqthj7GJ5maR7CN+opxf8riHEe3/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930185; 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=ePAiifeAEgtGa3CuY33F5TCllgUEk+CcpiyFvOuPZVClV/HyvtLxSZy/X9QrDIAmzHUr+ZdsOpY7RI9xXB6lse2Mek3EN8UeXY6B/kj0rDn7ps7378QPJ54cETVpCizE7sh3osi8iiom7Q9vtHb8eSKwnyCBuqI6gtfuNrt8XQg= 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 1660930185736863.230180585723; Fri, 19 Aug 2022 10:29:45 -0700 (PDT) Received: from localhost ([::1]:43274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5oW-0000eo-M9 for importer@patchew.org; Fri, 19 Aug 2022 13:29:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mq-00080Z-LQ for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mn-0001tR-T1 for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:07 -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-41-kaKR5UK6PcKz7pc_ZUnRZg-1; Fri, 19 Aug 2022 13:01:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09300811E75; Fri, 19 Aug 2022 17:01:00 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F6CC40D2827; Fri, 19 Aug 2022 17:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928465; 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=WjitsBvGiH6sEBoSAs9hP1t9fyYL0l2XU8SPJkJTaq2SF7eZ8HRxZAy2d9Akp5siiNqLBf 4jx1jQ5JWSJYE7DSpeACF37giRU54fuinK999RAX7JwNchEebnS+WQxEUSVvdYGF2tIC4o UE/TqrXz6g6B+zb7qMqXjssuJr0fHVA= X-MC-Unique: kaKR5UK6PcKz7pc_ZUnRZg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Fri, 19 Aug 2022 19:00:37 +0200 Message-Id: <20220819170048.3593487-2-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930187147100003 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 Fri May 3 18:00:15 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=1660930061; cv=none; d=zohomail.com; s=zohoarc; b=Z+1vkkkXDPseOx1CWThiP72UoQOmzZbFhFn6M5r/I1UFVJIpDtWzE0NLH/j4eji6W170SxQBZ3tO1Tg5lkkmCPxC74cI8XS8n9poJ4g/82k+fpWziy+kmLTCUDkV++TIJDjonoGAryJ7QTWOGGt2pt79jCQuZ7aWnUhhl7PYXm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930061; 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=PkufGdDwVmwa6htTLVRMgD/Am5LkHyyMxUkUcAQ47/oKq1pLDPy0ofjizBShlZTtPFRzVhcz43LLW66r5ky8duojElsCKQ2tSfUW800Vmq+kf8gVqvyXkj1KZ/NagoV06h6SOfkgJDtozuu5N1/nFQ4TYasFaKqNWN2gva2StKA= 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 1660930061784250.69420296158432; Fri, 19 Aug 2022 10:27:41 -0700 (PDT) Received: from localhost ([::1]:57832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5mV-0004KF-J1 for importer@patchew.org; Fri, 19 Aug 2022 13:27:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mr-00080c-Up for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mq-0001tZ-Fl for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:09 -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-528-fzxZ9wHPMvWL5ZIn7NfQoA-1; Fri, 19 Aug 2022 13:01:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 254961824602; Fri, 19 Aug 2022 17:01:03 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B74740D2827; Fri, 19 Aug 2022 17:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928466; 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=EqsiQnucA+HYPslxSrC4OTjq4qV40VkbSjzfidoGewGrm31RerWY+ZmYYok4L8P4M0DmQ2 r07tDqnHRC9jrn2pJLjm0l6ELmHIZlMqTXc30DUSFkiYOIISLidiwmg4inWUvwOwS7qZHd mUgwvtUd3KUQHZOmZP4+j9oY9V8jdKc= X-MC-Unique: fzxZ9wHPMvWL5ZIn7NfQoA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation Date: Fri, 19 Aug 2022 19:00:38 +0200 Message-Id: <20220819170048.3593487-3-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930062881100001 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 Fri May 3 18:00:15 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=1660929527; cv=none; d=zohomail.com; s=zohoarc; b=S3GB5OUzzXLgyTDxcLRH4gzD0cQIoLppqEpTdPapOyzs5RU80vkRYJMsccWlnTYWqKoF0p/bgw+h5Tz2tcFIvIPVigEXzOyNEEalDbYJPoVknW/zH2YtNkkdxSqyw4NrKrLKkLI5iWiTW61BxX7XRtDXNf8eF3Q148/OECi32a4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660929527; 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=HU+4AbedANNF/mTpIYXeaQqhoe0cDMXS1fg4GRmVLmhgtmLvxyJ7gwT09fxKD906i5AHBsR16G6D4U4x+N5kY0iFMYvpUQ218fyAtxFAi3P19KfE6fClGaBV0zQlECMqUe6BdTK+SykAdx+2HxSDi7Hz72srPTMjBuPgQcc5kQY= 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 166092952787571.44471265855202; Fri, 19 Aug 2022 10:18:47 -0700 (PDT) Received: from localhost ([::1]:42796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5du-00072l-QY for importer@patchew.org; Fri, 19 Aug 2022 13:18:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mx-00080o-Pd for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mt-0001tu-Tq for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:14 -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-90-Xkcy1Zq6MCygSesJq9XjyA-1; Fri, 19 Aug 2022 13:01:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E2623C025BB; Fri, 19 Aug 2022 17:01:06 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 675BE40D2827; Fri, 19 Aug 2022 17:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928470; 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=YzDIuUbaJokHMkYA9oZTW2Gyq9iq0ClE4amCTvwflYuDJtzA/YrQC4ecs+V2vaaui5bFa0 Avu2qgKweTkuuECmSAMMGN5QOpiEI9nG2NwasPbG4046sR3D/Vot//ruy+40HPmw1yswll ZebXR49+KoiqMu3CC0LO4NjHbpIVY4o= X-MC-Unique: Xkcy1Zq6MCygSesJq9XjyA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 03/12] vhost: Delete useless read memory barrier Date: Fri, 19 Aug 2022 19:00:39 +0200 Message-Id: <20220819170048.3593487-4-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660929529454100001 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 Fri May 3 18:00:15 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=1660930205; cv=none; d=zohomail.com; s=zohoarc; b=RUOJsuTDgJBFtQdAwx6ib/PJ+PjQ/nYP7LxGZVKirIGIDZ37p9kfJi3ZSshloiC+AoMNTTlYLibrjWoCtJJEjZt/o3LPxepCDXWMzukW2/cGCJSJW2h6CltQHI5w5Sv3ReljjPQuSSEermc9iwxQG3bgDRi8HoMYcaURqQK0+CA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930205; 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=aqnVSQvImg6lxqt1L4XgS8xVWP0RcwULK6K3EWDjjhmUvdFgbinR7ZWJ1ztocbJH2t7piK6fQdaWvkRuVsyQRCvDa2aHaGGcIrWfA9un1OMNrFdjCzoAuW3IpZI5OAbCF3OYC4vQVu8AyZ39QN9fQupkPccrSmaMGfzj8RLW6Io= 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 1660930205093190.00103181375073; Fri, 19 Aug 2022 10:30:05 -0700 (PDT) Received: from localhost ([::1]:52794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5oq-0001ba-40 for importer@patchew.org; Fri, 19 Aug 2022 13:30:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5N2-00081q-0o for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5N0-0001uS-I2 for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:19 -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-28-GsyGPR5ZMbih6aHFUwx0dg-1; Fri, 19 Aug 2022 13:01:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8353B811E7A; Fri, 19 Aug 2022 17:01:09 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id B15EF40D2827; Fri, 19 Aug 2022 17:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928476; 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=IBRMUFzzGjS38+eXyDFumwc6sGazcvCX1ZuIGcPOPGD9QGNCOuztEUDtHpGtW0BfNLDrDC q6zrw5ELpzo7QIF8Tzz2aSiyiBjCOtvHGBTjjlub4PHveKBVY39b+CLk91wxWAeYivu4jT yKbh0j5NRiaCh/LmhQP8C9RBJztqF6c= X-MC-Unique: GsyGPR5ZMbih6aHFUwx0dg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush Date: Fri, 19 Aug 2022 19:00:40 +0200 Message-Id: <20220819170048.3593487-5-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930207206100001 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 Fri May 3 18:00:15 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=1660930495; cv=none; d=zohomail.com; s=zohoarc; b=NBNcOpsBhCftH9YyoZx9iVe0Wz1JVgFEW2GDiE0a3h/ZPI35wUQs8b1ViVplZBWhRSmUvegeWJwueRxgBw8xQ1t8WUdhYqNZYE6/a8cN4tGgV5QP00HV0Y6AziWCgA0+66hbHYliS/HuvhrMKZz6eVY4WAAYnwazt/2h/MOH+FI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930495; 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=adHbk3BU9W94w4SSQ4WuwSpTJ7pPRQRfc9aNsbmoOU8Ni0rV5WgqYg3nbnjBhsb73JsFc61JuS0nblPsSeziHuMXW9KThGljurjkdsY2Sti3TCweHA8hqh8TUBV9U4MLLF/+wvCowc4rS+sQYddW9eTtXUCXcJlb1pSvpvge348= 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 16609304953291006.8363695092961; Fri, 19 Aug 2022 10:34:55 -0700 (PDT) Received: from localhost ([::1]:42596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5tW-0007g7-4V for importer@patchew.org; Fri, 19 Aug 2022 13:34:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5N3-00083G-9b for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29977) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5Mz-0001uN-AH for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:19 -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-260-IEiGLLYqPN2_CmEI_tGetw-1; Fri, 19 Aug 2022 13:01:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E575101A589; Fri, 19 Aug 2022 17:01:14 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4E2640D2827; Fri, 19 Aug 2022 17:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928476; 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=NUhLhlPM+N5c7hO275IVSq3dHm2w1Bysfz04mdzzA45Nt8B0gVY6m1L+UNAyT9XW2cdmKW 5fZ5t9ToZ8WvCAUSpNF5g8Mhr+kRJ1etCjNbihtkiQNRs0nX9p5zXLuSedivim1MXSJKI5 /Bvbf3sVtkVJicg3gAGbZ7TYER0cQdE= X-MC-Unique: IEiGLLYqPN2_CmEI_tGetw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 05/12] vhost_net: Add NetClientInfo start callback Date: Fri, 19 Aug 2022 19:00:41 +0200 Message-Id: <20220819170048.3593487-6-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930497663100001 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 Fri May 3 18:00:15 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=1660929784; cv=none; d=zohomail.com; s=zohoarc; b=YCCuocNqR976Lormc8eVqOJxYx+c9xcxqNBjiY8PynbWwKv8Ru3X/IGq+eEMlqC9ugZu/Nvio6Hks9DFMhnMHeR5uQl4fFzsrU8VE5JaEq/zsom7Rpf6hLzLzBwFEdngSOSj6e6iJ6e4tKmBmhAcARPOVvUQK5vSLML0zN2CBU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660929784; 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=dWKgTQXS1BAAYfrymkwqqMYlR6pRDRAfUkmiroU9kxxur/PtiYyCKt1fK2k6/Ytpsvya0Q088kAxk0rAE6enNdnXO0tVviIrGEsY8YjyKQx8LPcxPLcKgwSwsgvG9j8h4/CBWUbo+eJCyieDvYg6OqBLGEPQyFJdBFpWoxHShHE= 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 1660929784701895.4919563823014; Fri, 19 Aug 2022 10:23:04 -0700 (PDT) Received: from localhost ([::1]:55488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5i3-0004iJ-KC for importer@patchew.org; Fri, 19 Aug 2022 13:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NH-0008Ax-Hq for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NG-0001wv-0O for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:35 -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-548-nwpSfxmGOdCXA-Ca7RQ98Q-1; Fri, 19 Aug 2022 13:01:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 31AAD3C1069B; Fri, 19 Aug 2022 17:01:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F62240D282E; Fri, 19 Aug 2022 17:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928493; 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=YMDPDN2DMVRZCDDSKUKD3HlhgmXlY8hd7PC9BkQ1StrruJOCIIHeA5Z1PFvNRmSGp0MPw/ MgtpuybWSXhDMYEFOCSYOyAdGg5nWcLYo8aZfv3Wr81FysBvETt20yxJZNtybHsWakldvX oCvnTJZ3cUk99sJ8dI3oDawKpf2dRAA= X-MC-Unique: nwpSfxmGOdCXA-Ca7RQ98Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 06/12] vhost_net: Add NetClientInfo stop callback Date: Fri, 19 Aug 2022 19:00:42 +0200 Message-Id: <20220819170048.3593487-7-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660929786389100001 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 Fri May 3 18:00:15 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=1660931061; cv=none; d=zohomail.com; s=zohoarc; b=jdJctoFN/FGqNJ/lKDca8gBJtElearwoVx8so6BE0MxbIk0Vh4KL9szacNwi63y1lvAFYpdX+s/1c5updG41egHVekPkwd4d9mwuMG8SnTvwPGOZU06Fj6Z4EFsBGjXuHf0II+XbetjnrzagpVPTMHZKFaafd6RGxW/bDY0GVnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660931061; 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=QWBg+Jg0ns5TqM0WSOfAEU6xoT09B+6DZce77401SYA=; b=fPl5KjJzIRK2EZ+AJFmpWghoNhAXmcbICE1gbuugaps2rHRbVZH4XjSUhxCR3Lay1JQt/CV4roNLhFL5o2a3wniIXpZ9VmiyrfNGnvXOya55fSayo/+yyHQsd98JH8QeyA7ZAXYJDl7Vacs71yoUFW/wQhbVRKBSXhHtSxW3IeM= 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 1660931061722293.72132560627574; Fri, 19 Aug 2022 10:44:21 -0700 (PDT) Received: from localhost ([::1]:41424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP62e-00084V-Kx for importer@patchew.org; Fri, 19 Aug 2022 13:44:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5N9-00084U-OV for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5N7-0001wE-KF for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:27 -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-50-bjNVmKB4OKKdVnlj0EpuvQ-1; Fri, 19 Aug 2022 13:01:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46BEC29324B0; Fri, 19 Aug 2022 17:01:20 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 733EF40D2827; Fri, 19 Aug 2022 17:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928485; 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=QWBg+Jg0ns5TqM0WSOfAEU6xoT09B+6DZce77401SYA=; b=b1uyFBQwdvt5bw7vTJoeQVupkB5eli/dAncbDSYP18lVpw+Fe6zMCHFUOmUxogl3Pqgmq1 Dscdawoh2amxNdwlpN1U7ay5m88nYQGJNJH8fmZG5WBUY9B+zkDW8bpVoQwdQYoHcJTdES tiX9+OIUoTe1bz6CTh5lqXpdl5GeTNg= X-MC-Unique: bjNVmKB4OKKdVnlj0EpuvQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo Date: Fri, 19 Aug 2022 19:00:43 +0200 Message-Id: <20220819170048.3593487-8-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660931063124100001 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 303447a68e..2cc1e64daf 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 Fri May 3 18:00:15 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=1660930469; cv=none; d=zohomail.com; s=zohoarc; b=agIQAF33ytkIN+boXtp5YNHRCxhJehDRTQhVkbwwKEXrLaxXOnDAY5eqXP/EdMK6KYXFtEKLeRst1ikWCrpMP2i8vEQr8Wp5FYAEik5afC+E3HqiOVmKaltchMcCqyEiNtPfZ47GgmhLKAh4fADYdURjIzoLuuCDB4VuI6EaPH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930469; 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=We36yaeF+TGeZVD+YZxV4tYPdknexSo8L33NQSVVG+c=; b=camMczc4I1q88o8Gs7qqP/IAQKYQAfGVrK/VUcJltivrUbP6bHR90zOb/XuejyC1bHpiY/SY0zAzRTdqegIHvdYLNJiX7f6D/YlMXWNIJ7jQUQj/xTcFIy60khMuvctnZd2H67eFXbzkhc1sT0bt6Ua19LPA8yGERG25pAuuZgc= 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 1660930469464682.6485980892738; Fri, 19 Aug 2022 10:34:29 -0700 (PDT) Received: from localhost ([::1]:52312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5t6-0006Tb-Cx for importer@patchew.org; Fri, 19 Aug 2022 13:34:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5ND-00087N-Ip for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NA-0001wR-OB for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:30 -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-301-BH7wjgvLN7qPoa-kUgYxwg-1; Fri, 19 Aug 2022 13:01:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60377101A586; Fri, 19 Aug 2022 17:01:23 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A45440D2827; Fri, 19 Aug 2022 17:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928487; 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=We36yaeF+TGeZVD+YZxV4tYPdknexSo8L33NQSVVG+c=; b=DYvDjsZeZ9GIsqIH7t57gUyXiqhCWVspxMFMCYj+rrsa0RFrYVu9gAEmg+twMQDqGmgqfu ac12trWBjNIxGl/i6AGOgCeQYu+nEpogyIKjoHdtc3vK2sieukt4wyPXPzkIqfuV+ACvlz Cg3qzwiwJK9vHjgtNBglVu9X2lAEipg= X-MC-Unique: BH7wjgvLN7qPoa-kUgYxwg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 08/12] vdpa: Move command buffers map to start of net device Date: Fri, 19 Aug 2022 19:00:44 +0200 Message-Id: <20220819170048.3593487-9-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930470929100001 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 --- 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 2cc1e64daf..9ca065dff6 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 Fri May 3 18:00:15 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=1660930940; cv=none; d=zohomail.com; s=zohoarc; b=IF0AwFCJKLxqXBfyfJh5DayoZiUqJbWXp4297bS/maGN+/ddWfuiPOlD90cyEo0ZlnP230dEOvRAR2GgVmtCnd5RbMSqZ6uQlonMlEcmMnjYHa17sUIxjecVAsVdDQyoKDWS/bXQifNxXoDK8CZVENnkT/+UsF1zCbGnxt8rFaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930940; 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=+7qrBoFlUnjV9GW/XNv1w9/N3wvYnRfouzNM80vEU3c=; b=Z17bBBia65zQha4hJn4qoQLkKdWY0PwCPgvIzRNSpwTWagHlM+n0mI8vA6mcocOX8xTlPXgP61Dhfma/slpUNCzpzzYnBU9Tjs6TWyb/BOeIkXO4nJeXbfCt9CX4XSPrhKj73l0paRj/B4F9cKtpNFWUQ5wi+s9UqutyWve/0MY= 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 1660930939997384.17858475935; Fri, 19 Aug 2022 10:42:19 -0700 (PDT) Received: from localhost ([::1]:48752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP60g-0004lw-Ra for importer@patchew.org; Fri, 19 Aug 2022 13:42:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NH-00089i-3E for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NF-0001wr-3n for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:34 -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-256-Z3nGEomZMq2GtJoC8_NU-A-1; Fri, 19 Aug 2022 13:01:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE8D41C08974; Fri, 19 Aug 2022 17:01:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A202E40D2827; Fri, 19 Aug 2022 17:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928492; 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=+7qrBoFlUnjV9GW/XNv1w9/N3wvYnRfouzNM80vEU3c=; b=HaoSG5ZLTdjaeCX5FwV1LqW5ocjS/YZ3B4r6K6k2jIz933l4HKk4if1jB1XcXCkcVZpj2E NMW03xXLj3gOMfXFew6E2xXGAXMql3rgyFuol9Oxdr67od/GPevR+UIqHK9kaks3tsEq0H Fc0FqBBZGnglsCs6tn1gzNXRAX18zCg= X-MC-Unique: Z3nGEomZMq2GtJoC8_NU-A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 09/12] vdpa: extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Fri, 19 Aug 2022 19:00:45 +0200 Message-Id: <20220819170048.3593487-10-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930940875100001 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 9ca065dff6..ebf76d1034 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 Fri May 3 18:00:15 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=1660929945; cv=none; d=zohomail.com; s=zohoarc; b=PcNNVVq+z3rq3GAm5aYphGsXPf39cE6qOuc261SZPAC5wDxYlBQdYyVmSFbDHqjOABpp6Bv/iQFkMzh/WV+0jI/RN9oPMZ5avukstZWUyy40P1vIjP3MtbeOglOBrOGNjhEWt+fFXptnpylFPN1n/CfBEFi2AMduLF4s86ywOzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660929945; 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=T6AHgYFuKd97dGMh7FLE5VKNhHJJc0bQUK5BejDaCELgkLZPDybQ2q0ZfhmIJW+QOdiHHogCUEiHyDEmg/uW+JfkPCp1YuVsGOUoPPQ+Lrm15TkJMiA8gZGzw/9lKcg2bdaPv1OnowoaUWm5LUlcCU/Xp0k2mQmMUGo6oxsh0C8= 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 1660929945101840.4316879161031; Fri, 19 Aug 2022 10:25:45 -0700 (PDT) Received: from localhost ([::1]:49592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5ke-0002NK-3f for importer@patchew.org; Fri, 19 Aug 2022 13:25:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NZ-0008Fy-Lb for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:02:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NJ-0001xF-8a for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01: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-249-HX5arSe3OHmMZbRbBZ4L9Q-1; Fri, 19 Aug 2022 13:01:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1C321C08977; Fri, 19 Aug 2022 17:01:32 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C0FA40D2827; Fri, 19 Aug 2022 17:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928496; 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=QBEwdz/seEGM+0XfuJbMs3b/x8ElfWzMmqPfUZu8tQj4cixbeT0KvMEDpFycZ7qnnyk+7a zaDI6600fKiQKo80/IRiihp+vk+Q1CFvdTpHDdJkeb3pHWtSPRxRu3kfwTdWGxeLaXtdLH SeAmKcw/VesYqRdWx4ET7khl1nZ55dc= X-MC-Unique: HX5arSe3OHmMZbRbBZ4L9Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 10/12] vhost_net: add NetClientState->load() callback Date: Fri, 19 Aug 2022 19:00:46 +0200 Message-Id: <20220819170048.3593487-11-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1660929947294100001 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 Fri May 3 18:00:15 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=1660930171; cv=none; d=zohomail.com; s=zohoarc; b=BUfUZU+SF/CYJEH+CTrqAoY7FI4hg81fQiXBTwF0jBpvzZDCcj0YOMLhz32R1eo6A5KqQarWC4RiF9bRRH9OTQg3ws6jelLmAQ312uhncbIASRKKCxn02/JVelSWdEQI9YKYYUhY8X8HU6Ojy7MgFTkICeEKuaD5TGEHTNG+dRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660930171; 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=lE37OUe80YU3vl4bIdaA1+zb2chy3UuHKhHQZk/vNVk=; b=J0E11onghHd00U4UNwDhrf8uH9jdwtkfflKntfdBdAY6Rbyh54NLnMnRXrLSOP2cH3xgauTn8DPIU+fpFTgwThXwbhbsyT+hRtrPChMA/5SBjp9YcMMFHvaCArMgHHWCo9k2CGiBjF6dUxBP7K8fCAx0+I8yE7QHdm6BYHQs6Yg= 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 1660930171699779.2652532941925; Fri, 19 Aug 2022 10:29:31 -0700 (PDT) Received: from localhost ([::1]:52500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP5oH-0008LG-8i for importer@patchew.org; Fri, 19 Aug 2022 13:29:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NP-0008Fe-LX for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:02:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NO-0001xS-0E for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:43 -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-516-eib21QcwNGCgS4c5SE40gg-1; Fri, 19 Aug 2022 13:01:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 010AD3C025B4; Fri, 19 Aug 2022 17:01:36 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E94D40D2827; Fri, 19 Aug 2022 17:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928500; 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=lE37OUe80YU3vl4bIdaA1+zb2chy3UuHKhHQZk/vNVk=; b=LJpl+R7uJ54RRQ8JYAiurVgzaZVYbIMMv0TVJ/v2q6IT5yG9ztlYvpl6SfHg45dakqQEJ9 GTWX0SshmF3NHQvl73A0+gmpADcBDpn8FRLXYmFkVc0d9VpKLTUDZlJic2WKfK7/hRnR19 30ktrqUioDUCSJG0xH9XTEoiGi4hZtA= X-MC-Unique: eib21QcwNGCgS4c5SE40gg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 11/12] vdpa: Add virtio-net mac address via CVQ at start Date: Fri, 19 Aug 2022 19:00:47 +0200 Message-Id: <20220819170048.3593487-12-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660930173437100001 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 ebf76d1034..8fad31a5fd 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 Fri May 3 18:00:15 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=1660931223; cv=none; d=zohomail.com; s=zohoarc; b=B/S61kGtsQ+ANbWDi2Op4q62o6TZOG/0/VCJdt2/ETTl0cD+pbptwrGBlGcAaRgeFDW+Kueqo04VAlF5fEwRLozdhKaZeQv9Tk/SBT2OkdEUFwZdVBImC0hOJlnI6egvLQWKgTLVajxW4RDSFdSpiUb1VYk8FOi5+6Abc9frPm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660931223; 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=W/yeH/UjfuIbGtW+AV3RgScwoLIeQFclMU79IZ4B+ds=; b=bHM5N+fTngkqnzDGQ0UKQ8EOalnJElGl+kWTCXILVTGT++Up0MKnBgkCCinqha1Bpd0GndoqjPvPJE60bh49uUhfzQUpZGiD4hfl7RfXIF6ztjWfWTCV1O2L9ub8zqf94Go8LGZW+B5EJOrrFXjcCEZyqd8qPOGRkfrNTIi1Ix8= 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 1660931223585938.7312302391798; Fri, 19 Aug 2022 10:47:03 -0700 (PDT) Received: from localhost ([::1]:54436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP65G-0002Lh-G9 for importer@patchew.org; Fri, 19 Aug 2022 13:47:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NU-0008Ft-MK for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:02:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP5NP-0001xc-9a for qemu-devel@nongnu.org; Fri, 19 Aug 2022 13:01:48 -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-640-YkK0qjU4OS6_hsArlKKrDQ-1; Fri, 19 Aug 2022 13:01:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1597A8032F6; Fri, 19 Aug 2022 17:01:39 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42EAC40D2827; Fri, 19 Aug 2022 17:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660928502; 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=W/yeH/UjfuIbGtW+AV3RgScwoLIeQFclMU79IZ4B+ds=; b=VV/+edqkyV+rrruGCXdSts4lomUgm8J0VoxfUAsyAlxcTSjZ/a/vSACzd4UX8NZI9sqeFW RqYJk8z26RK5Qs4SSTrL8wsje1i1X9PidVyNJV9lzeVeNMHVO2PnNwutHmjrWE9aZueA7V c/t3r5uu7xObWYo6gvB78ogbnP4VqxI= X-MC-Unique: YkK0qjU4OS6_hsArlKKrDQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Laurent Vivier , Cornelia Huck , Jason Wang , "Michael S. Tsirkin" , Markus Armbruster , Gautam Dawar , Stefan Hajnoczi , "Gonglei (Arei)" , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Eric Blake , Liuxiangdong , Cindy Lu , Parav Pandit , Paolo Bonzini Subject: [PATCH v9 12/12] vdpa: Delete CVQ migration blocker Date: Fri, 19 Aug 2022 19:00:48 +0200 Message-Id: <20220819170048.3593487-13-eperezma@redhat.com> In-Reply-To: <20220819170048.3593487-1-eperezma@redhat.com> References: <20220819170048.3593487-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.84 on 10.11.54.2 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: 1660931225171100001 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 45d6e86b45..15cb87223e 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1032,13 +1032,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); @@ -1081,10 +1074,6 @@ err: vhost_svq_stop(svq); } =20 - if (v->migration_blocker) { - migrate_del_blocker(v->migration_blocker); - } - return false; } =20 @@ -1100,10 +1089,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 8fad31a5fd..97b658f412 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