From nobody Sun Apr 28 09:52:23 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=1660067018; cv=none; d=zohomail.com; s=zohoarc; b=GRwvSR4UyqNXrzqFqNZvEQ8xNljUOd5Q9vG8nvQu2vjRmf0tgX/DwTYwFPa0JedHAUVCMQEcWDUvRDC+5y0qyxfGszX/4DI0Ay/IpmJeYyWgYwMh7+XMopPC0TMKI9V835rvJMtCz9YhNVANRxRtY0DSjBXL4uyeGDH2fnikm5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067018; 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=UiEkzTLBHlIlayHtPSQQEVqXSiMKfeyvFgz/lNi8I5E=; b=Tx0wj/t6YQJomrNlG0e5Zde3VcCy754MTTmVYySwq3wupE+tssOHR4HXLICHgEzMtPXSoU0xdaFlDeRNkYoQzPLxc5i+6XpMxAm8ZK97ak/OBlp7U7nu0AYRMBXhuNqfbCyFyqYLFDvUq/rJZ9AK7hIaddedvGUg6Cw6YH1XtQg= 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 1660067018762905.4622652906155; Tue, 9 Aug 2022 10:43:38 -0700 (PDT) Received: from localhost ([::1]:50754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTGT-0006v9-PU for importer@patchew.org; Tue, 09 Aug 2022 13:43:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCf-0002qg-U1 for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCe-0007bq-6h for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:41 -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-659-FFrbZfxpMk2lrKIfynEcPw-1; Tue, 09 Aug 2022 13:39:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74FEC3815D4A; Tue, 9 Aug 2022 17:39:34 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8775D9457F; Tue, 9 Aug 2022 17:39:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066779; 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=UiEkzTLBHlIlayHtPSQQEVqXSiMKfeyvFgz/lNi8I5E=; b=Zp9UgVX8b4G1QraeQtGMvHEYQgmYjhOM5eG0sFtQmU6tkWTXu8CNqvYD4WowKFwjublqCC 0ym1Hr3LGkIPUkmsVh46IW4JGaPywzS3X7lqP81oGXCfaPAdmcCae7rXbHYiOtKM783wDR /CaqgJpJIUHNwzD7Q5AnfAk7lezWlNw= X-MC-Unique: FFrbZfxpMk2lrKIfynEcPw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Tue, 9 Aug 2022 19:39:15 +0200 Message-Id: <20220809173926.1695280-2-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067019115100001 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 e4956728dd..ffd2b2c972 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 Sun Apr 28 09:52:23 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=1660067453; cv=none; d=zohomail.com; s=zohoarc; b=R7dFjaoNirplykC5dLNvzghPFst/fCf4y8+7aRDWdykw8E8HuIVuM2zftj1XRrZMx89peojhuJNOTyAPDox8ZNv6ZKqAcDzLpOQ+EU9kEmEUICbrBKJ0xhLXZ9N6ZHsrdlIuYeEHKO65s8UQlV4i8lTNpSyeruxG+hBCVrgDVcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067453; 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=2GNJHf5Te3/VfdUyvrjfNPIFBElZxMjp71yPbl2P4CA=; b=mxyr3Q2XRdgy+wJbbqrrF3SZPakxxNkiadb2FMWv747p7SQyYRKB30hpszaV10/pRcDO/VmcL1vFVgGQehfl2u5dT8VWRXMBZ/0QXOHGA6PJb6MNplLVL6JK5c1B5Xojp7U8rWvDX/DzZI4utrV5eHqRKzWcF108pyO4SzibSdQ= 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 1660067453276858.4781092895001; Tue, 9 Aug 2022 10:50:53 -0700 (PDT) Received: from localhost ([::1]:36112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTNU-0007q3-0s for importer@patchew.org; Tue, 09 Aug 2022 13:50:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCk-0002uR-67 for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50334) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCg-0007by-3g for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39: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-477-6e1uwmuePTK24bqLmNCxJQ-1; Tue, 09 Aug 2022 13:39:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8F2829ABA1F; Tue, 9 Aug 2022 17:39:37 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD00D9459C; Tue, 9 Aug 2022 17:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066781; 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=2GNJHf5Te3/VfdUyvrjfNPIFBElZxMjp71yPbl2P4CA=; b=HyIgs/WnunSd06O0ipwojDeDxiKDB1HlURXJVWJOVQNcm+XTaPPA/k7QxsY31gV5B1cvVJ sxqiFj4YII2+fTZXv+IvUNFjRin+wUUUqkFWYRYJpQocWL2nbB+D1ou9iUsPJnhtBo+Pgp BSTxrm13kYj5brg7RhznEEVmLM68TK8= X-MC-Unique: 6e1uwmuePTK24bqLmNCxJQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation Date: Tue, 9 Aug 2022 19:39:16 +0200 Message-Id: <20220809173926.1695280-3-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067454812100001 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 ffd2b2c972..e6eebd0e8d 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 Sun Apr 28 09:52:23 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=1660067136; cv=none; d=zohomail.com; s=zohoarc; b=cLIJAMRlVX3h9MsSaEQWdK+bX5riAF9bqfeRXhZ+q4pzzQk44D2jVigJdnY4A5Orjzz+9nb+54hqz4aLYqCw8/AuIPIYoS2eenkdf0pvpyolfSgOmCrFUtm5eFZ6IU+NHh9cI/gMkP34xW60k5QWYq8O9C5bk+KMxw+2LrzO5eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067136; 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=rtQQb7EL+UeOalWd74A+WW+kXcjbWk4kkir2Mx3zMaI=; b=aKaVUe5LsB/mpxAwXjO24x94F8vXVy202As3HZ6U4b9+VECOeDwyOeHqEDmKgsaI8z+Udw9KS4uFa82gz3oi8owk1j0tMSmd7KHCC5EXoGmsnVAqBp9Z5alFk0JuTeyqoIx99WDZPuCRDXSMo792x6gpcXh20gVXrj99ZUIx930= 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 1660067136236129.0004973567011; Tue, 9 Aug 2022 10:45:36 -0700 (PDT) Received: from localhost ([::1]:55988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTIL-0001yl-VT for importer@patchew.org; Tue, 09 Aug 2022 13:45:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCi-0002vJ-Uq for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33243) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCh-0007c9-8t for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:44 -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-655-WJpsdX_1MGi4FEoz5CdrJA-1; Tue, 09 Aug 2022 13:39:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03CCB3815D34; Tue, 9 Aug 2022 17:39:41 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 085EF9457F; Tue, 9 Aug 2022 17:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066782; 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=rtQQb7EL+UeOalWd74A+WW+kXcjbWk4kkir2Mx3zMaI=; b=KVpNqrBlpkNSwobOWTaiLkF9vxv3z+PC81rjfaKPhFjAy0QrNpWPWB/CTNNQ4RjfiRzjkp SWR2APo+sJriVajauzZpnFHMAgDuNrJSmTGECzRPIShn+BFT5S3oEmWO7/krHl6ixr6bdY 452tf0xxhv9A/EEOZt8fnljpNx4RVNQ= X-MC-Unique: WJpsdX_1MGi4FEoz5CdrJA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 03/12] vhost: Delete useless read memory barrier Date: Tue, 9 Aug 2022 19:39:17 +0200 Message-Id: <20220809173926.1695280-4-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067136953100001 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 e6eebd0e8d..1b49bf54f2 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 Sun Apr 28 09:52:23 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=1660067240; cv=none; d=zohomail.com; s=zohoarc; b=HWmUTTZrKAR39609s5Zq5eOmLkSvNMxiu7LQUlhRmwAzLx7zXFXCHQty377Ioo+wN9BOulBk0pGCWJU5E/XXpN9//6xk1Fert3zUQIrnSFcekUj8lIe8Q9eCP2TDnwVcSJ1Nn7vpCYkdsfDM6aY1dXuoSaYhW4Ztil3+PNcow7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067240; 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=BH5pDxJtRQ5QlbPZfRaOErQEJelhMMFxeznntPVmMQQ=; b=XEW2SKvjf1ns6OdAed+9RO97C9YAagUY3p/sdXdKQFf1kxd4pqitN4sam5hlUyPTfob7ReeOkdo3xtgisRqvA/E5feCqZoiGWuFj5mfmKKbsq+kfhHUD1qjvWIxfvh2Zp3B3iPnFnudkGto6/elEMH5hgxp5Ub51kpEN6U7pnhE= 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 1660067240689858.7696505954336; Tue, 9 Aug 2022 10:47:20 -0700 (PDT) Received: from localhost ([::1]:59056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTK3-0004Ag-Ki for importer@patchew.org; Tue, 09 Aug 2022 13:47:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCp-0002yX-CS for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCn-0007dc-Uh for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:51 -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-94-M5vemoyiPN24E7_B_DDbDw-1; Tue, 09 Aug 2022 13:39:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 644EA101AA48; Tue, 9 Aug 2022 17:39:44 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50B2F9457F; Tue, 9 Aug 2022 17:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066788; 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=BH5pDxJtRQ5QlbPZfRaOErQEJelhMMFxeznntPVmMQQ=; b=h0FWz2vmjyJulZ13k6tcS1MkHmIaqmYkdVnxQaglz/ncBm2JtdogDwJ2ZFDnGc8Qwc6y5u 2ubkzB4UNrccNBNbhEcnCpACZHugzh9nR3LLXv8vFJmAcJXKCPbo6eVIFOE3te89P/L2YQ 46fzVJGjHdum1nxzoudEnOV1p6IQyws= X-MC-Unique: M5vemoyiPN24E7_B_DDbDw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush Date: Tue, 9 Aug 2022 19:39:18 +0200 Message-Id: <20220809173926.1695280-5-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067241566100003 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 1b49bf54f2..f863b08627 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 Sun Apr 28 09:52:23 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=1660067703; cv=none; d=zohomail.com; s=zohoarc; b=kR/KVMcebQqqHhV39PSjbT74rqRu+R408hkHiWJEVvPDTRUOJOC2cwzennKebOui9YfyvNEWx1zxr74OWICflCbF/+jnM3aFG+r7xxipKwOHKu3pBwcCVC4nRR6PiYH2rbmXet26/oB46vlTTtH8it/wotoYrFI0MN7rY1UXRUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067703; 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=/7zOiqPZaPv4TS6lXL74grj3MVH5YYJHUjh7m1dvizY=; b=Fc6H6lBS5zcao2QLs6jTJV4RXidjHXZN/uAwB63exG+9P/KLKGdMpLN61ZeSjdE2NCY/qHLTODCla6GwGI+fetA8xVf+0dFDiu9T1RRJMbZDjmYaERl9/lQKYDqVd6F6xe/cYR7KQeHvLxVom4udfkw6ZWeB742bPuW6nVtJeTI= 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 1660067703041279.1792051046875; Tue, 9 Aug 2022 10:55:03 -0700 (PDT) Received: from localhost ([::1]:44628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTRV-0005Qu-2a for importer@patchew.org; Tue, 09 Aug 2022 13:55:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCs-0002zY-5p for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCq-0007dn-2X for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39:53 -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-509-KrLLqxFxNo2HPgKaU_uzqA-1; Tue, 09 Aug 2022 13:39:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A12761824602; Tue, 9 Aug 2022 17:39:47 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD85418EB5; Tue, 9 Aug 2022 17:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066791; 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=/7zOiqPZaPv4TS6lXL74grj3MVH5YYJHUjh7m1dvizY=; b=RqpVGwaVTZciNYw561Hdz5hZ7fU9SmjX3bmi9vl4vGIYqNZ0HaVyGR90HKstzbx927xJLR Uq6DcZsSKd0bm9BvNPoIYLybYkf53GKZQCa0s8MfYkIh5Prx1hRwaej+2pB+XVjQxzMmzG tU4a+ehrP9ptqak/3uqtziBa++GKpZ0= X-MC-Unique: KrLLqxFxNo2HPgKaU_uzqA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 05/12] vhost_net: Add NetClientInfo prepare callback Date: Tue, 9 Aug 2022 19:39:19 +0200 Message-Id: <20220809173926.1695280-6-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067705150100001 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 --- 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 Sun Apr 28 09:52:23 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=1660066994; cv=none; d=zohomail.com; s=zohoarc; b=d8O+QzYPc+WDDX/tFRMJsOsG1TyIwj8IurdyrFC03FTHm67cDz84s+TSHoitKfIW8URVxGuIRHMsONx/aqS8aG9qwchsOIwg1cqZoFWHX7L9ma6sJW0ODh3QQ72XzhTLcrYD6D9WJJhP0YhevKA92CS68Lttr3boRisSYU5yMkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660066994; 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=aZQkX5qmt59YIxvHZtivTQrEMIMehuD9vbSFWbqgNHo=; b=hdTnUpQRWpZzvq81pdiOp9DvSeI7chOKRI89dSSS0qTRpkLX/ij3cBqiof+m/Qj3q10b8t3OhlP7iSIu54pF0l48ITs4ioisMUL6kCISGI6TEmXOqt+9OvMIliXVVbB6W3Imr1RP9IE/Mwi7k81QP6H4N1AR/9On8Q8a0OR3SGc= 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 166006699458534.587487228026134; Tue, 9 Aug 2022 10:43:14 -0700 (PDT) Received: from localhost ([::1]:49462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTG2-00062Q-44 for importer@patchew.org; Tue, 09 Aug 2022 13:43:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCz-000325-BK for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCw-0007eL-Uz for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:00 -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-562-AwvEPvQFP8yWTd2OIicUig-1; Tue, 09 Aug 2022 13:39:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B6B9F8037B3; Tue, 9 Aug 2022 17:39:50 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2303945D0; Tue, 9 Aug 2022 17:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066797; 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=aZQkX5qmt59YIxvHZtivTQrEMIMehuD9vbSFWbqgNHo=; b=W82bGsIBvem7keDOE74Y7zomLi9yKgXpEjak7GXeM3MOca4AfDGsT3xVfGqSb5Il7a0N8J 2zJjm9O7WLuPiH51NDKmYFKq4qpakygXQFHfP1XC5MQFnn6x8uAuB6l4WSsNinDTbK9yj2 qQlpIIFgdTWCPtLxyglpMGd0SGgjhbQ= X-MC-Unique: AwvEPvQFP8yWTd2OIicUig-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 06/12] vhost_net: Add NetClientInfo stop callback Date: Tue, 9 Aug 2022 19:39:20 +0200 Message-Id: <20220809173926.1695280-7-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660066994923100003 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 performend in prepare(). Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- 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 Sun Apr 28 09:52:23 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=1660067885; cv=none; d=zohomail.com; s=zohoarc; b=SljcHlqqB6PMfJcr69Y3vMoMws2QE+fRX2g2PVGkNBeH8A9xkBaSOs7UjoJVphy2o2tDiFP9B5GxjnE+8LuHa23f83mYQ6KjZFSB4G00+FqHKb2KHH31xv/hKCTUEKGpcBhiW5bdTgZqjDCpSk//Alonup2wttvAQ5kTLlS10Vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067885; 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=0YxI/0ZTCBCCZEzbzofzIBZ7fTOGvTQV1XF3Qc6vPOM=; b=TMhtPJK4f+7I8/bsT0mcgNt8DM4IKf7fVEDoHcZxvNRS4UNXHnui2ZgWdUuz8sxhaib32V2j8JzlCstsAKGY0rKBdyeE69X47gg1T0Vl7eFT9cSiB3eM0NOz5KH8OMOJ7f5SH/DhQSO2GA+RVHA4jEhzcMa9olGswBchJIuaDI8= 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 1660067885291928.7868306351475; Tue, 9 Aug 2022 10:58:05 -0700 (PDT) Received: from localhost ([::1]:52546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTUS-00036M-6p for importer@patchew.org; Tue, 09 Aug 2022 13:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCx-00031u-OX for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48234) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCu-0007e5-0r for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:39: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-652-_4b6if0iNPGB44j_tfCQNg-1; Tue, 09 Aug 2022 13:39:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CCE381019C8E; Tue, 9 Aug 2022 17:39:53 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 043019457F; Tue, 9 Aug 2022 17:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066795; 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=0YxI/0ZTCBCCZEzbzofzIBZ7fTOGvTQV1XF3Qc6vPOM=; b=Menq2CeAYlObKEJ28fAxKYxE4np1X/gxEJHWF63pqScQW9bgSD4DnJqhiQHXXtaOPd+GIv vbtuhaeXlw327SBSjpL/AGDOBuwVO6AfgVfN4KgXNl66GCqneZjcKOxbrstD7g1vlkSiZS hed4x82wVZPzBF+Y3rbTloxPQ8qHogI= X-MC-Unique: _4b6if0iNPGB44j_tfCQNg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo Date: Tue, 9 Aug 2022 19:39:21 +0200 Message-Id: <20220809173926.1695280-8-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067886283100001 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 ac1810723c..55e8a39a56 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 Sun Apr 28 09:52:23 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=1660068066; cv=none; d=zohomail.com; s=zohoarc; b=Y62mqZwaWda7hfBKYC0s4vPkOIhS9f5kTZbpCaAFWs+ELodICMBGhYQPGzBuMSC8idRwORkG6qYGOZ3xARj/REcxpUYHaSJx1ZcuvfIT9i+4zHMI52fCxoPgm/uK09Paj+4w+qn66s+CBNYSq3dHHL4YJb0SREmjobVW1/C9GjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660068066; 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=3FsjrR35VUICwni+eOo1fTEjzVIWIjo7tm34p2LxWDM=; b=JxXH+vPSF4g5U+JYa4V7fD4C9WKGhTQ1Mzax1Q9U8DUHKVhQdflu3/VRtARtRBozCrga5occWLyrZqwXIy8alnc8bUMsN3bIInM0cIjNRkeQqOtzGmjLsEZQL5uObCrDwj5S4a7NjvHDTXC1AvSf9/KylHETev73WxWVgzbG9/U= 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 1660068066942694.0801147192383; Tue, 9 Aug 2022 11:01:06 -0700 (PDT) Received: from localhost ([::1]:58104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTXN-00074G-9R for importer@patchew.org; Tue, 09 Aug 2022 14:01:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD1-00032w-Dw for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTCz-0007eh-9e for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:03 -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-270-C6z4qa8EObyNO1lDPdLKig-1; Tue, 09 Aug 2022 13:39:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E02201824602; Tue, 9 Aug 2022 17:39:56 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B2679457F; Tue, 9 Aug 2022 17:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066800; 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=3FsjrR35VUICwni+eOo1fTEjzVIWIjo7tm34p2LxWDM=; b=VoKDO8xvHTiaVm0/ih5jLbjVQcDAg1PEJI3yYHrAJHVCTkQHlDmMywYGTXN3oZtkbMzBPo HL+z3rirneUik/fGSrGd8zkolhz8vjFRZx57DRlK9bygeZyKeCh+XMS8cdL5GRGSvSbdtb DlTR9rvqj8PkcH7olEX4YoYXwNK8Oxg= X-MC-Unique: C6z4qa8EObyNO1lDPdLKig-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 08/12] vdpa: Move command buffers map to start of net device Date: Tue, 9 Aug 2022 19:39:22 +0200 Message-Id: <20220809173926.1695280-9-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660068068035100001 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 55e8a39a56..5254b58bdc 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 Sun Apr 28 09:52:23 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=1660067203; cv=none; d=zohomail.com; s=zohoarc; b=R5IcYZEZLPL6yWmQD3pVqcZDeFNfomvX+kIQ/sdKMPiMQg9fv9vMFkZBc4nt1OCySYq1GZunQfNLkIujgxc5NtZsQDyz5OsvYSQnJxVCYK+c/xGxtzs3UrZanNZQNgfKMa8oUEz6cgmeV/uD8Yzx1kQWj29VKHdcduHqj8TqfZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067203; 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=QR1U1armRTXVVHfH7veuah9Unlsvvlnz6Qv+TY9aGUc=; b=EGhVxfz/cb+iMMFUaCk6woqjHemNfk2W2bqgeJQZIfFLUDa3zGBkn+V/F8R3KW2Rsb3l9X+JPX21El5edXGUjdMRFeL3kMKTmC2YYpvgxgmrIJg/wjY+YTqO920pX+N10AGAs/OQpliFVRhhWmiUQN8Z1C3JWjbzOaB14cwr6eY= 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 1660067203499868.8476380564413; Tue, 9 Aug 2022 10:46:43 -0700 (PDT) Received: from localhost ([::1]:57782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTJS-0003Dt-BA for importer@patchew.org; Tue, 09 Aug 2022 13:46:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD2-000337-2r for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57012) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD0-0007f0-Az for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:03 -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-326-UsL3nAMpMrCcrjKxJ0njow-1; Tue, 09 Aug 2022 13:40:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 121963815D36; Tue, 9 Aug 2022 17:40:00 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F48818EB5; Tue, 9 Aug 2022 17:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066801; 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=QR1U1armRTXVVHfH7veuah9Unlsvvlnz6Qv+TY9aGUc=; b=dd7z2YcBBLddDv1/gy3nPLlGs58ctvg99y7LVI2u7/FCLEerZYhKecpi4m6MliLS2AvPDo msH6EaNcP5EulPd+Y9uren29uJ0gZOouzZUZ7jlJ2afiAn1VeVxr7Pb11IaEzS4I2m0cyo j7DCkjw/pVcgfV7cQyngLG59405ff+0= X-MC-Unique: UsL3nAMpMrCcrjKxJ0njow-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 09/12] vdpa: extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Tue, 9 Aug 2022 19:39:23 +0200 Message-Id: <20220809173926.1695280-10-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067205368100001 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 5254b58bdc..df85567cff 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 Sun Apr 28 09:52:23 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=1660067230; cv=none; d=zohomail.com; s=zohoarc; b=a5VAK/PDxP/YBZ9TYsVoe2DXj5jQgs1sn43r42fbdWEi+9FW3fAuNf95zbjd385WDvtfianXtKxd0jti1hEZrJtDoWNFE6Op23euq9Ps8uLtK4J0rQWJlLbjgg6hhFi0AD7gQ6q440wbF+nSUuhsulhOBwlRj3ZgcMBt9ByMWu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067230; 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=fVKNcUCud4Rn+/eE64g6UY4J13Lxx1ahKJKtYI7cMUc=; b=cwjrI8JCVE4fl8PEhMga+JgCSZ9M8LsZWmc0xCs4tw4EhR6semlMQ9rS1pVZQu5llg5qsNLSOACcswF+7m6tI0RsTpRQLPx3AOqhVqeKTcLCI/+lFB1DfMPD9e1kFNhv4txvlWPHz4oqqX9/Zmober+ajPse1XEzrQ/hYg8W2sM= 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 1660067230296676.0892454615094; Tue, 9 Aug 2022 10:47:10 -0700 (PDT) Received: from localhost ([::1]:58204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTJs-0003ZD-Bk for importer@patchew.org; Tue, 09 Aug 2022 13:47:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD6-00036M-Rd for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD5-0007qd-Ar for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:08 -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-76-yndjwKe6Md-072m24C2OWA-1; Tue, 09 Aug 2022 13:40:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEE621C06EDF; Tue, 9 Aug 2022 17:40:03 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62CAE9457F; Tue, 9 Aug 2022 17:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066806; 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=fVKNcUCud4Rn+/eE64g6UY4J13Lxx1ahKJKtYI7cMUc=; b=iWPEG1kG1cVIwBBuCUYzXeBQaC48wM2bO+4Rv3X0Gk+k1fQycxk+zXU1ZCes2naa3kUGOR 0pnRnDaMr1KGfeH9qMYqBI8ldwq15PgDIVdX+7x7QFuGlo76Arl2EF/Wh9k5o84c080wZ9 AWZMdQDpmZvSExpXwANKnwgFiPnXXG8= X-MC-Unique: yndjwKe6Md-072m24C2OWA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 10/12] vhost_net: add NetClientState->load() callback Date: Tue, 9 Aug 2022 19:39:24 +0200 Message-Id: <20220809173926.1695280-11-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067231552100001 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 Sun Apr 28 09:52:23 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=1660067526; cv=none; d=zohomail.com; s=zohoarc; b=N5zs63qM8BwsBDuyJRUjN2w6MhH99yH+MOGppvHKNHgUlAHG9ZTudZDEfMBpIt8pnQajL/cyjFajCq5qCE/vn3xghkt1a5uoJVfkefWo/O42hIKJyR+p1DodXFqLWJPp2RwYKfER8fIm9in1fkLrLa18glql+C0j6Pyzkq/mM+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660067526; 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=pphfNxEk7o6jaM4F2XgvKOuQ/WOcyw9zR8wszX/2tXg=; b=ikcAE9yiI+WFmw5YcZDAxuXNKuoxYLSpvfgmpw1/iATdPckJWMHuBNFZ3NBM0eUWF6r/KZxRBUh4BrgyaUaDfpun4Xa3FsGtlc7viCH/Pl5n3Zj/L7ywfQxxM+4L4ogn+y+lB0rQYHzrgRKa5hSgqJBGtuQ0/tKMP0k0uEXIKfQ= 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 1660067526263963.8218478174839; Tue, 9 Aug 2022 10:52:06 -0700 (PDT) Received: from localhost ([::1]:37904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTOe-0000fW-A2 for importer@patchew.org; Tue, 09 Aug 2022 13:52:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD9-00038a-QZ for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTD7-0007r0-U8 for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:11 -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-245-LieOX3ZpPLCfmlAK1qjWvA-1; Tue, 09 Aug 2022 13:40:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D7EB8037B3; Tue, 9 Aug 2022 17:40:07 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 225AD9457F; Tue, 9 Aug 2022 17:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066809; 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=pphfNxEk7o6jaM4F2XgvKOuQ/WOcyw9zR8wszX/2tXg=; b=FrttE3wv3kn1YRfOWEJf+QDwL375cGw+sB6qoeZlBH9JFTA2dJY2OiCv5VnbiwFyDX6C3V PSlmMf0xGZnVU/9C1GNMI2YxQw8AupZPKSosOn0mYenUL0junqDaQnBF7xVX0+HLvixjK+ bjrJZgZpxYRWnTM9lFLYFgoRQ1amtvs= X-MC-Unique: LieOX3ZpPLCfmlAK1qjWvA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 11/12] vdpa: Add virtio-net mac address via CVQ at start Date: Tue, 9 Aug 2022 19:39:25 +0200 Message-Id: <20220809173926.1695280-12-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1660067527171100001 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 --- 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 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index df85567cff..e775957952 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -363,11 +363,52 @@ 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); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + 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 v->dev->vdev->host_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)); + cursor +=3D 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 Sun Apr 28 09:52:23 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=1660068416; cv=none; d=zohomail.com; s=zohoarc; b=WzuTZI1eTRGXebyaUjUpgwZJ5MrVdO48khKq2w9p7bqLp8PCCc1H5aIqtVhh2GWeTCo1iTd8cfwWWDC4CQmSswkPyjj83OUYEVyShRIwv6gkotMOBDMskmdPkbKK4NqYG82IWXqQNSBAevot4SHjDhkOnDcebiqT6oQFKOstBRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660068416; 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=eXQcpKhvT7SYHys3w5s+wGMRHBRDqXCIVH2q1RoBkSc=; b=l3Lbm6tSQ3xQtmMrm1Mj8qTZWNg9GUQsOtPNXy0gkLpMEeVshEvyB0Hb+GhxHCGTBA5zuP/1lmSEjpcVFsxNWIlxH8pzcL3JkQZI9p7Sx5p+H9PAvqXn9eAjjEg05UHiAgEzTX/dRROQmVgrj2To179To0L2dIc6z4NHHC0SB/8= 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 1660068416644193.78620983822293; Tue, 9 Aug 2022 11:06:56 -0700 (PDT) Received: from localhost ([::1]:34564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLTd1-0002NX-6t for importer@patchew.org; Tue, 09 Aug 2022 14:06:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTDQ-0003Gf-Ch for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLTDK-0007ry-P0 for qemu-devel@nongnu.org; Tue, 09 Aug 2022 13:40:27 -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-477-RiJg5RniMH-q0e7_dG9ZQg-1; Tue, 09 Aug 2022 13:40:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF9FB811E81; Tue, 9 Aug 2022 17:40:10 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82DF618EB5; Tue, 9 Aug 2022 17:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660066822; 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=eXQcpKhvT7SYHys3w5s+wGMRHBRDqXCIVH2q1RoBkSc=; b=aBR1U/oGkihrAIrPUNNgURt1q3coCEUpNYPK/UuLrX3ddhaPgIAmtMyLE7nB3GR4jqP6Wc mspoiLbuZwzunIvDlIuBVu0Ij2NY2O0kYQkrLW3AnyE6afT/w4etRHK7cvXDmRQAWqCajy Cyh0aKceJH5DFv7RNwwKjYSYNFrqw5M= X-MC-Unique: RiJg5RniMH-q0e7_dG9ZQg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Harpreet Singh Anand , Gautam Dawar , Laurent Vivier , Liuxiangdong , Jason Wang , Cindy Lu , "Gonglei (Arei)" , Zhu Lingshan , Eric Blake , Cornelia Huck , Eli Cohen , Paolo Bonzini , Stefano Garzarella , Markus Armbruster , "Michael S. Tsirkin" , Stefan Hajnoczi , Parav Pandit Subject: [PATCH v8 12/12] vdpa: Delete CVQ migration blocker Date: Tue, 9 Aug 2022 19:39:26 +0200 Message-Id: <20220809173926.1695280-13-eperezma@redhat.com> In-Reply-To: <20220809173926.1695280-1-eperezma@redhat.com> References: <20220809173926.1695280-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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: 1660068417326100001 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 | 14 -------------- net/vhost-vdpa.c | 2 -- 3 files changed, 17 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 7e28d2f674..4b0cfc0f56 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 @@ -1105,9 +1094,6 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *de= v) } } =20 - if (v->migration_blocker) { - migrate_del_blocker(v->migration_blocker); - } return true; } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e775957952..188adb00b7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -556,8 +556,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