From nobody Fri Apr 26 19:15:42 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=1659637319; cv=none; d=zohomail.com; s=zohoarc; b=gvNN75sZe7VdPj93vvcljA48jSStZ9Sq9H3rhqIYRk7W1WicFJpVs36KsbqHqjHgsBVQI1pGs5BTLLW/lEb+H7Hg8zvAq28yExyPYNf4zFxrUrA8WxH94XbIH/l9/EWP8k5scr+9dQY9mJdWffWhg3patW7JKN0Eonv1KThRjgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637319; 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=ZJjoWNgiO9pSxFfxgEXPumFynQaR4e570fIWsLS9YCg=; b=XYTFhks4Iu32MCSEa3CK+IaVSNDRYLErAgGIxZdw22tHMGkBNNWZDejNT1Y1ogHp9w0QqLH81doE2CaTm3qYwfWCy/JawfM6IXJqwbdsvlQuC71KlJyp3RMogW9VBPN3dkFAQ7rMTgIfBUeFBG2D6Meo8YggcDY6Cz7J6ZzssC0= 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 1659637319792744.9690069084646; Thu, 4 Aug 2022 11:21:59 -0700 (PDT) Received: from localhost ([::1]:56310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfTq-0001DX-P3 for importer@patchew.org; Thu, 04 Aug 2022 14:21:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPu-0005yW-QL for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPr-0001Ei-QL for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:54 -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-544-4zXFXU4CMx6tSiYqmq2GQQ-1; Thu, 04 Aug 2022 14:17:47 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7CB6818B53EB; Thu, 4 Aug 2022 18:17:31 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FFB8492C3B; Thu, 4 Aug 2022 18:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637071; 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=ZJjoWNgiO9pSxFfxgEXPumFynQaR4e570fIWsLS9YCg=; b=Nv7dQgo9IBDKRdHrkEQ8Fu3FMnJagx8kXt1iU0gzeHT9aYBMEkaj1AfzNxWg6au++9dZfV joZ1VoY4+CJijJibYJ5fVjfgkVrLDGpaKyahnrbl4wa8mr/CMKTCVApeiC1R6SYbBxsagS 8d0utcHX8jpVrX7JUYq/AC6KuO0ChgY= X-MC-Unique: 4zXFXU4CMx6tSiYqmq2GQQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Thu, 4 Aug 2022 20:17:11 +0200 Message-Id: <20220804181722.701067-2-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637321528100003 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 --- 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 Fri Apr 26 19:15:42 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=1659637495; cv=none; d=zohomail.com; s=zohoarc; b=hEiLNLA/Zei8eYfsUJx17+k/qwXrIbeypYBeYd9NwJl3dLi9jHySs4zsHYDSQtOk2MQ3QLV8QrRtMq5RAUXlwFm+OvVBDhdkaSZXW/jgfKQbK5b7A5Y7u/4hdh/p3e42PbPUK5GW8j0IQneuE1xHcrtSJpSTSJRZxqQ023Hl55U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637495; 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=mFcSWUZrd/1meZg3dITq3TzQyarfrxoNesnu+w7BZmQ=; b=XntchhIS5DeV6dUvCDIuJjQqpyTlgCN2S9G1h9euY13DbBPBD2YR9AK64ZYBUDmKU4ecxEtwVk386uOg5W8fYgo2k2MAPekZsTH8xzzJt4WdWkux840ie/9tqFWTkXj0gIfOzlj5fHFOTXpO6LycsYt6G+EGXTPd7bkIIEjB8fY= 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 1659637495451200.97089580613954; Thu, 4 Aug 2022 11:24:55 -0700 (PDT) Received: from localhost ([::1]:35954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfWa-0006iW-Up for importer@patchew.org; Thu, 04 Aug 2022 14:24:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPu-0005yG-Nf for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPr-0001EO-7p for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17: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-35-4ybmrivsN8Cw15iNeI7m3g-1; Thu, 04 Aug 2022 14:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC856800DBE; Thu, 4 Aug 2022 18:17:34 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id C42B2492C3B; Thu, 4 Aug 2022 18:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637070; 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=mFcSWUZrd/1meZg3dITq3TzQyarfrxoNesnu+w7BZmQ=; b=W+2tf65PxDJVcxrkGfwNaEG8clYD/cZDE+1BPns33u76WZZLgSP1yaeTUxfe9vZgfKRx1S w+egZKZwdrYSULbgTzd6So3+bDSycUKdhENUgydGQiomzY11T+f6wsED0gBmhm8qLibM9e 5O77VaoxWB4WS2JCPlEStfvOccRmQ28= X-MC-Unique: 4ybmrivsN8Cw15iNeI7m3g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation Date: Thu, 4 Aug 2022 20:17:12 +0200 Message-Id: <20220804181722.701067-3-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637495724100001 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 --- 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 Fri Apr 26 19:15:42 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=1659637513; cv=none; d=zohomail.com; s=zohoarc; b=CXCEI8903jAB4acp/A/3LV7rqKcmBq9f2c+z+EDFUVBRntNeRttjl+Gd5X8ULCsZF8hhb8S1W+q6KLEyq7+VsxaEzI60ebhw8c8tfXPQBLiDZtY8GeUFp7Ef8qjMl8tk4XT8bMpG5EiqGJZW3CZnro4pORcZTQgvN1xc7fZIhVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637513; 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=buucNH6UPudgudlKQDxV5Skj8xgGaEiYKwfKh+0154k=; b=GOenYnkBmVnjfpYtcmZvwLB6ZgdlJMJpoq/9cv+Dth9+/exKIXbVR30xymlY8GHD8dyM/gjEQMsgYrcSyrTt1xvAMXS0RaQiyvA8fxlxai8iu69KUlbU3M/qz7ojNdFxQ74Dxg9boifgVj5wfhMpFfLxzae/zhpwo7OZ901dkjE= 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 1659637513119914.1242787373933; Thu, 4 Aug 2022 11:25:13 -0700 (PDT) Received: from localhost ([::1]:36664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfWx-0007Dv-3V for importer@patchew.org; Thu, 04 Aug 2022 14:25:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPv-0005zJ-4l for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPs-0001Eq-3c for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:54 -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-132-uBiaOGByPP20Y8RgoGCBNQ-1; Thu, 04 Aug 2022 14:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 348A48057B9; Thu, 4 Aug 2022 18:17:38 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E7B9492C3B; Thu, 4 Aug 2022 18:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637071; 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=buucNH6UPudgudlKQDxV5Skj8xgGaEiYKwfKh+0154k=; b=OS60kcMnGYfaecKqEoL03tytjWcw/3u1FKEsuJy6LaoaKBZhqhNbW0eVB4OWRnxZdOCLEX zFWqSYNfVvt07C5exia8uXomBevlH4ta5MHwzNpRLU9qNb6FzTfN+hIP91XWnqOEXeWCjy eehBXzuhJLepXb9HXYC7sN4nBKJpdw8= X-MC-Unique: uBiaOGByPP20Y8RgoGCBNQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 03/12] vhost: Delete useless read memory barrier Date: Thu, 4 Aug 2022 20:17:13 +0200 Message-Id: <20220804181722.701067-4-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637513841100001 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 --- 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 Fri Apr 26 19:15:42 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=1659637951; cv=none; d=zohomail.com; s=zohoarc; b=TJfPbkuHzAUfy0UMp/kcG6zn+Xg6u8SNgff1JK3lHroy8+eUyIgAgJyOL2PVPIWL81OHHcY9DX5ZZOjbtiUEb+/ouE2FwhEbZVaU6vklrwzs+/8Jp5NdM1tvdxDPwxKuen9q4DHbXGm5ftMUBpG2wQ89e/9pXBOnBJpAfQvE8oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637951; 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=0B8KI4/fnEok6w2Efz5xLoWx7wcqHk6mQq7G+EE1gok=; b=cac0H23zU/V/3RKIyE6OmmM51Gq+sMG1QDHimFVV/hSWq2xOrrp6XMAATJfCQ8zXFq0fNaw+62Ds+hkb43IVbY4uUb4tX3p8GfwXyaJEo5aNwkGwLK1/B26W4fcUmuqk6jKmD76jtzNtxl+GUSr2Bjs71gIrNlTP1MALE3RQ7M8= 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 165963795144934.527863906072184; Thu, 4 Aug 2022 11:32:31 -0700 (PDT) Received: from localhost ([::1]:52808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfe1-0002XG-Hg for importer@patchew.org; Thu, 04 Aug 2022 14:32:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPv-0005zL-4b for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPs-0001Eu-If for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:54 -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-149-g_EtLKGPOfCG1pxft7bN3Q-1; Thu, 04 Aug 2022 14:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 882EB8039AE; Thu, 4 Aug 2022 18:17:41 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82EB6492C3B; Thu, 4 Aug 2022 18:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637072; 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=0B8KI4/fnEok6w2Efz5xLoWx7wcqHk6mQq7G+EE1gok=; b=gyGKROFTgC+bhrxNJ4GgcYjP1zrJjwixyF8IUxrRRqtLqNz/F9Z+74BoF/aW7cpHPntAcH 2vRqNIUGebM0N7FI0ZEW5u3OLlsmEjdwCeIOuBoU2aaf9q9f68OVefKrIRmxZaMsMF4aOU VMD9E5vxkqVxbjGPdDhiGI1MHLl6vMU= X-MC-Unique: g_EtLKGPOfCG1pxft7bN3Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush Date: Thu, 4 Aug 2022 20:17:14 +0200 Message-Id: <20220804181722.701067-5-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637953690100001 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 --- 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 Fri Apr 26 19:15:42 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=1659637296; cv=none; d=zohomail.com; s=zohoarc; b=N0If78zoYzEllGoXJBaaD1KKmB2y9BhYWfETFC9HZGRJKOjDMNxASpPzMY4SPAzsWnsj8iKxKAsJI0J8hhKrCPZ8brb17NkgtAq1qXDi/y+qn6b6voxaMg69PsI0G2LN6xflbR7lWzlrfO9fcDG3cCge9v/gW3j+oiw+9Tvr7EE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637296; 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=pSOYJFmCUIy0mfnEqXO1DVzB+00pvt/ixLKLNmEb53A=; b=KN+GKb9uQD1kZBMPRFeD5/Y/cJf6Tg3jkpuyquqlUnzjRa0Tv7Fmbz/3I0/+DMjj4RtYGQ5gGIQwV+ChOt4LD8K8Nd5+PyRsnG8o9wDCHh6niOJA0W9+5LSZww6QmCsXykc+YuCz9lxZmeGjuxtVcF4GCphCIFpSwQK9HpjhKFM= 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 16596372961736.915663929387506; Thu, 4 Aug 2022 11:21:36 -0700 (PDT) Received: from localhost ([::1]:55502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfTR-0000dp-Q4 for importer@patchew.org; Thu, 04 Aug 2022 14:21:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPw-0005zY-R5 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPv-0001FS-Ao for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:56 -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-113-NydWgWClM32tq-KzrWtq-Q-1; Thu, 04 Aug 2022 14:17:48 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D867810AF63C; Thu, 4 Aug 2022 18:17:44 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4E40492C3B; Thu, 4 Aug 2022 18:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637074; 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=pSOYJFmCUIy0mfnEqXO1DVzB+00pvt/ixLKLNmEb53A=; b=YcUB0LD24Xx/gyAQq7MMrCMXpKEJVyxQY3brz1/VQZxeaSjr3WJewjvTHIfm9yGfuB5juj LF2CMAKD3ntofwhaIK0ptaS3W2aqSsWkx1ciNP9a6Pl6pNXss29pUMK74HbY5n7s+WLCGE H/T+RDLuTLtAhlAlcStXLx1uvp1fvI4= X-MC-Unique: NydWgWClM32tq-KzrWtq-Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 05/12] vhost_net: Add NetClientInfo prepare callback Date: Thu, 4 Aug 2022 20:17:15 +0200 Message-Id: <20220804181722.701067-6-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637297455100001 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 --- 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..3416bb3d46 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 (NetPrepare)(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; + NetPrepare *prepare; 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..e1150d7532 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->prepare) { + r =3D net->nc->info->prepare(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 Apr 26 19:15:42 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=1659637661; cv=none; d=zohomail.com; s=zohoarc; b=Sxl2ElfEo6dELzdZQ2E3MskJzmZClYaHPkELMcXtBGD1eI50rG4F+Tyf4lSNKAaqwaymo8J8ppifzBzUPTFTPFQdrolZdoBVzxuK6Cc2Id+A3ryWQ1TH923keYP/tsWGZ+ib4bgj0C0eaAguVFPqi5SEbZ0LnLVor/uU4TJJJQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637661; 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=BSRnyzTJnZsFHFDCrpPS135y1ud3kS4PVdpPYIF/UdY=; b=IGpX9zM7E6RJHE6n3jrH9jLGqM/svqzMpfc6JajGeqi1dx0UDGJq8DHyBDz5/qdcUsjhThgfGxC2oq01LUeWXpJEMCtvBp60F/7EWcqLh343sZEhSNYbAHEmBTE0OcWEeiwyC8xWRDYgpgRsoD1Sf6DWGbTGtENzZwty9odDQsE= 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 1659637661573572.3817536147532; Thu, 4 Aug 2022 11:27:41 -0700 (PDT) Received: from localhost ([::1]:44592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfZL-0004UR-9S for importer@patchew.org; Thu, 04 Aug 2022 14:27:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPv-0005zX-Vf for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPu-0001FD-Bo for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:55 -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-_-BOvVVrPsqRC6VGeSbJPg-1; Thu, 04 Aug 2022 14:17:49 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DA5394EF84; Thu, 4 Aug 2022 18:17:48 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A182492C3B; Thu, 4 Aug 2022 18:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637073; 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=BSRnyzTJnZsFHFDCrpPS135y1ud3kS4PVdpPYIF/UdY=; b=Vs483XQPrgqbsGK7NyibSBcAfW2dyLjOsQnDykXb6CwjxvmroAkptnqbTCfOV0KjmD+ru8 X/3g+zfsTuMcrGXB3fFNmjsZT/w1EHhK+hTwDH1+v295Yc7IxUewF+HSI4zv2lk2L4IZt7 5naTZvBygh6ssYtXiOyAGo4CD1o+YjE= X-MC-Unique: _-BOvVVrPsqRC6VGeSbJPg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 06/12] vhost_net: Add NetClientInfo stop callback Date: Thu, 4 Aug 2022 20:17:16 +0200 Message-Id: <20220804181722.701067-7-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637663169100001 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 --- 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 3416bb3d46..7aa1ec0974 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 (NetPrepare)(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; NetPrepare *prepare; + 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 e1150d7532..10bca15446 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 Apr 26 19:15:42 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=1659638374; cv=none; d=zohomail.com; s=zohoarc; b=Zy+1S5U83yYyan5+jNSx7886Fs7X5EbZsSmPzZFyFJgy9fO/E0SmyQUBZutzspuE9b10NOYSwbNGKXEzde1wSAQip5It2CDuuqqLNkfagOVaer3HLTleHK4w4oGJnZ8IoqcTTiBzYy/9mOm+TctwhbVrCw2ms+9olV0Az9kNTDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638374; 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=GGa+tP6mUDNHJ4vxe6ePEJ4/v1JndnsIHK729mNkGWQCDbdzqMA/lN1fjlUNgTkDyAGsHTmj0H6WZCVLZVPZ0VjkbJ4cnhs0i+v9vF0K2tzF8bSibLQveqPxDWM2ZL9KB/Kji5r0ZHCmkgoQ5W+cJZRAQCfuRT1GpE9blTeKEcQ= 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 1659638374876430.3788153570961; Thu, 4 Aug 2022 11:39:34 -0700 (PDT) Received: from localhost ([::1]:60756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfkr-0001Yl-Gx for importer@patchew.org; Thu, 04 Aug 2022 14:39:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPw-0005zW-7T for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPu-0001FA-33 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:17:55 -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-83-pH5NxgfqN6qdb87ixJEqhg-1; Thu, 04 Aug 2022 14:17:52 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA4AD85A584; Thu, 4 Aug 2022 18:17:51 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1309492C3B; Thu, 4 Aug 2022 18:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637073; 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=Wgxo1DykkC3VbwqJfp5MCFe3zJ5H2UiGz7gqXimK7tlabaXbh2/UTNmBzTKMhabLJ98G9b BxGLPi+ojtCeCbXawezsJ9mUgJnpVdcoEOvMuBelDVOfj6QmETO6yIbxgOm3ouQfJzY8+n WcY9NQdM0j8kty4L/NQzbaZTsZmM+tU= X-MC-Unique: pH5NxgfqN6qdb87ixJEqhg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo Date: Thu, 4 Aug 2022 20:17:17 +0200 Message-Id: <20220804181722.701067-8-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659638377075100001 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 --- 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 Fri Apr 26 19:15:42 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=1659637669; cv=none; d=zohomail.com; s=zohoarc; b=njaflX2nhyhmTqbnbvg8UBBmokYKPaT1UNdxelR4Vz6/f0oFr4am7yu9qG5DFOwijuFwagiIxnDlpaF5avPJi0OzRRtEGNFUn8RaXCkMLbFSYea2Vf8nZM4LcAXtgN4u3kDdU4jvCVbcceG6I86arhzWNetypS2u29Dfp1iTNxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637669; 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=CxXOKA/Fw5lDrXBqL8eBVuEh61tj8tNUT0uOYD2kVDA=; b=EPHj79qHeVQnfVIqUSjREAleQZLB1PaOdgsEU/pgFmtUP61P25UuvUY7RQjHhpw9ukI5UhhZWV6EZw2T4eWLLpxw9BrT0hm0X9cyQoD8tU4rB1A2a+tKXxvAJJVlcdts5pnY9+3Toa1djdabTycpwDWJMQqwigkxvlIvxf/Jbwc= 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 1659637669677675.7835263593365; Thu, 4 Aug 2022 11:27:49 -0700 (PDT) Received: from localhost ([::1]:45036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfZU-0004me-8L for importer@patchew.org; Thu, 04 Aug 2022 14:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQ1-00061z-Mt for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfPz-0001G4-Ow for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:01 -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-13-l7Nhhv_EPVejjZGqJ4HB5A-1; Thu, 04 Aug 2022 14:17:55 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3BAF0280400A; Thu, 4 Aug 2022 18:17:55 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D33E492CA5; Thu, 4 Aug 2022 18:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637079; 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=CxXOKA/Fw5lDrXBqL8eBVuEh61tj8tNUT0uOYD2kVDA=; b=R+UV9vLVHYis9DG47Jxi+IyhmeFghCm/u43l6E5BKs8GkNPhJiTNHv+G3jFpFUnZhYjRCj nV0abdQB1cHWOB4ftg4etOSNagmMoPD8BOmXD76lNRNWDqyr/8VLDaNS/k8pPM3fi6hDN1 kOcARDc8Xol06NRqGHz8GXACKhn7y0I= X-MC-Unique: l7Nhhv_EPVejjZGqJ4HB5A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 08/12] vdpa: Move command buffers map to start of net device Date: Thu, 4 Aug 2022 20:17:18 +0200 Message-Id: <20220804181722.701067-9-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637671032100001 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 --- 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..2c6a26cca0 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_prepare(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, + .prepare =3D vhost_vdpa_net_cvq_prepare, + .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 Apr 26 19:15:42 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=1659638453; cv=none; d=zohomail.com; s=zohoarc; b=bD0MSNFUBSviDqFaZPuh76xqaS8jn8m+IDREUdnKPiT63Xfsm35gAKWYUwezWX7T/xj/3PRElhtpHtkqmrohi63QC1MUKHRXCX9+NWlbZ0gGIDHySK6PzbVpqZJef9crVaK8GJ2r95raT9/1PCvaPD+dzN654k9xNzk4S1ArSag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638453; 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=lcWJZ7r7rDSBaq7/c5DlnatQGIShGzZfiLVLuXOlGmI=; b=Jzzv5lPgsPCHY9GDZg4a+6Ica9dttO0PLKythjxGzdAILiPGEG7v2gRDWCgXf1mkjDalLY/qaFsRibKuwLIoDkw0NOgewacxorX6h7il/rIcUYWNEqGXDYTmvdoyNA7JsLFQfd+hoSfKg7BMtb5zWgjin66E4o4MqXNmCeaTJUw= 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 1659638453765773.6380274581257; Thu, 4 Aug 2022 11:40:53 -0700 (PDT) Received: from localhost ([::1]:33490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfm8-0002Du-NH for importer@patchew.org; Thu, 04 Aug 2022 14:40:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQK-00063M-Jv for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQ8-0001Hc-Bv for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:18 -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-589-ms1bUeo4NxSNzCxDJcedvg-1; Thu, 04 Aug 2022 14:17:59 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 149BA2804007; Thu, 4 Aug 2022 18:17:59 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EF6A492C3B; Thu, 4 Aug 2022 18:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637082; 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=lcWJZ7r7rDSBaq7/c5DlnatQGIShGzZfiLVLuXOlGmI=; b=XyB3U3cRvZWyWDsuOKDelGiPbOIbSb0o4QDgirqzwAxIH+D60WNQ3AbbaQqVoJDKXLmUOR 6DIZwd6Nvr4SgOJLfcRBxiq39mK8XLF+dnot7UpWgpX8U7nlFOY7XIlUFA8mjf+qQRC8MR sxx9rTt/L/FXtjPujXYuOU9XID10LVA= X-MC-Unique: ms1bUeo4NxSNzCxDJcedvg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 09/12] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Thu, 4 Aug 2022 20:17:19 +0200 Message-Id: <20220804181722.701067-10-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659638455595100001 So we can reuse it to inject state messages. Signed-off-by: Eugenio P=C3=A9rez -- 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 2c6a26cca0..a3ca6af69f 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 MAX(dev_written, 0); } =20 static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops =3D { --=20 2.31.1 From nobody Fri Apr 26 19:15:42 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=1659637982; cv=none; d=zohomail.com; s=zohoarc; b=JCiDXN5AcR/Uxvdrjng9ksE0idOF3gHigiTVijbRMYp63UBB1oUlKNhfTDIq0bHt4qTpwM/0+cHXBPsHO2T04sDxMKYn65QAUAUoF/Xeso+Wv+aO29pAjEfmbX0sWaonyB8FDdauwRPwSTo2DsNI0Lr9k/7fKu+gF/wum5T81jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637982; 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=B4ZrLRDwhepJQ17mV/bK0uaEPIPpjZawGXOV8Rt2wjM=; b=aiZ3CHdWOxq9r4SBgZugAIdCb+npxi5yikNMbxDec23aWWLEiKKzxyLHesEipvGPKP1WOnb+j96GD3tMQMWMyY8RYxHpnMdruJ44s6YBSgOrz4YHHt9nq+qGHySijY9JnoVl/i6XBt5P96nnlKQzhzKGwCwldXw7eVe/ca24oi4= 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 1659637982322134.59883546735125; Thu, 4 Aug 2022 11:33:02 -0700 (PDT) Received: from localhost ([::1]:53408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfeX-00037x-9I for importer@patchew.org; Thu, 04 Aug 2022 14:33:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQK-00063N-KK for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQH-0001Ho-E8 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:20 -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-248-_VEJrczlPEuTWUzOsUI9eg-1; Thu, 04 Aug 2022 14:18:06 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9F1285A588; Thu, 4 Aug 2022 18:18:02 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 592DB492C3B; Thu, 4 Aug 2022 18:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637089; 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=B4ZrLRDwhepJQ17mV/bK0uaEPIPpjZawGXOV8Rt2wjM=; b=PgwidoqZmyT8/3wD5arUgZJZpTVDUWktev31fonEHZbG9oxVwmVFsD2ZLqVW9Pyxww+/WO FTFyFe6kR7qW6qaCj3GG3eSF+IKoOxehrX43dcXXEkW3dvVALiCjS71R5EoXgbETWgT21o +hzh6dTzzFtZcMu48b6c1MEHV6N3I/Q= X-MC-Unique: _VEJrczlPEuTWUzOsUI9eg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 10/12] vhost_net: add NetClientState->load() callback Date: Thu, 4 Aug 2022 20:17:20 +0200 Message-Id: <20220804181722.701067-11-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637983616100001 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 --- 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 7aa1ec0974..356e682ab6 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 (NetPrepare)(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; NetPrepare *prepare; + 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 10bca15446..6b83d5503f 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 Apr 26 19:15:42 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=1659638649; cv=none; d=zohomail.com; s=zohoarc; b=oESOag7N4e3UZ0eaE0Rv97wv92aJjmST2mA5Ypvzsnckrg4flLjmUeQSrDfdNQUhMDcWViEotdlJSxPO6aV2+UPSBBJLMK1Z5qEUw5Sky6MHHCdMIEc8LfF7NkiLLvbPUsradl73ed1m+TGXfH4YnhLMHxt2UkKTrPGFauuCm68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638649; 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=F3tadPuSrBqodjKYPy0q2EEHu/LjR7giDgt+48GrVZs=; b=ZDqNWaalU8s6GF+c6k/XF9F4Zm+QdtcQDEi8RbwzTk10Iq/Jph7wiOEIQAbMlS5TQ+r0xGR/N9pnZE5QytOTCyETwhz6+KYDNqnFH1ah0uuHP66j7PdZky6WkChxmIpldURDkpoI2qE2EZFZ48cB4J9Ygq8ehUK+V2I1GrDHs/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 1659638649892656.0095528943924; Thu, 4 Aug 2022 11:44:09 -0700 (PDT) Received: from localhost ([::1]:42046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfpI-0008HC-SC for importer@patchew.org; Thu, 04 Aug 2022 14:44:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQK-00063J-JH for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQH-0001Hx-EC for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:18 -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-418-SwyLWpHPOc6sMRdWVuEQ5g-1; Thu, 04 Aug 2022 14:18:06 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C2A685A585; Thu, 4 Aug 2022 18:18:06 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20D6A492C3B; Thu, 4 Aug 2022 18:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637090; 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=F3tadPuSrBqodjKYPy0q2EEHu/LjR7giDgt+48GrVZs=; b=Ba55iWEjCvH4+waGWL3DekxDBFHj4e06QtVLKR3Y6cFUw1fICWy+Qv8ZUCIQupVaGybABd 5fwIiHEmW5EiH7uyOh9uyPYxeMKHmRHja2ePxlGPdjvZAuNysZoT+U2rBNzElRHlONpmF2 vyMgEi39k2zl0d6AOLAYVj0jxOdh170= X-MC-Unique: SwyLWpHPOc6sMRdWVuEQ5g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 11/12] vdpa: Add virtio-net mac address via CVQ at start Date: Thu, 4 Aug 2022 20:17:21 +0200 Message-Id: <20220804181722.701067-12-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659638650694100002 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 --- 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 | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a3ca6af69f..7a50d46dae 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -363,11 +363,54 @@ 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; + virtio_net_ctrl_ack state; + + 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(state)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + memcpy(&state, s->cvq_cmd_in_buffer, sizeof(state)); + return state =3D=3D VIRTIO_NET_OK ? 0 : -1; + } + + 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, .prepare =3D vhost_vdpa_net_cvq_prepare, + .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 Apr 26 19:15:42 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=1659637295; cv=none; d=zohomail.com; s=zohoarc; b=cXKPHVH7rFzFRrGaRtsHHEj8h8tPKXHyEFMZIvL3TfhcLdL1HpLgDzNPnAmTr+xByALxqD7rdwQUGRuI1elksE4oLVIDQGOavHzsTG5zutnLphHbX7kkEhjUwvx2HtYut7DXBFRqCGEGZKYSXGxMXY2XpEvzyWudf/ECXGRaR4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659637295; 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=iu0w8mrva1JwCjiySaxBWZ1T7+21/ldqKukYwsnWfUM=; b=fx87ocYIvY3xgjBQPlwoH9P8TyTSXYeN7hXDYmRQBuJv4Q3BVtIbZA86fcRd/rantCGHn9CLBQoF8ovC4/B4P2an24ayfKI3opvTTJLg8En5imJ2e9+U3OO5r/CtRGNoJ/SUVm4pvL8hS640LclFyCNg3ck9EzZ3impkgrtiZRs= 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 1659637295933714.3103139659974; Thu, 4 Aug 2022 11:21:35 -0700 (PDT) Received: from localhost ([::1]:55618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfTS-0000il-Oq for importer@patchew.org; Thu, 04 Aug 2022 14:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQL-00063Z-GN for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfQH-0001I1-KI for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:18:21 -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-554-5QNCKa_fOcy1z64SYDxY2A-1; Thu, 04 Aug 2022 14:18:11 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DA0F3803900; Thu, 4 Aug 2022 18:18:09 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9310B492C3B; Thu, 4 Aug 2022 18:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637092; 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=iu0w8mrva1JwCjiySaxBWZ1T7+21/ldqKukYwsnWfUM=; b=Hhe2ubSInCQnxSGwMImKVWP4ulD9BcBtk/BXm+mIjJuMwnNuKIIbAup5iV80ywb9AMp8v0 1A18jv7wmql40j2wb21L7JPvP2GqmlBw1A4g2nZKz0adsn+8RvZhpfHMVDG3aln5cpnTwV pYN+z+vG8JnOavyxVUa/j9+c0CYaPvE= X-MC-Unique: 5QNCKa_fOcy1z64SYDxY2A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , "Gonglei (Arei)" , Cornelia Huck , Liuxiangdong , "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Laurent Vivier , Eli Cohen , Zhu Lingshan , Cindy Lu , Stefan Hajnoczi , Parav Pandit , Paolo Bonzini , Harpreet Singh Anand , Eric Blake , Markus Armbruster Subject: [PATCH v6 12/12] vdpa: Delete CVQ migration blocker Date: Thu, 4 Aug 2022 20:17:22 +0200 Message-Id: <20220804181722.701067-13-eperezma@redhat.com> In-Reply-To: <20220804181722.701067-1-eperezma@redhat.com> References: <20220804181722.701067-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1659637297458100002 We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio P=C3=A9rez --- 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 7a50d46dae..b70fdb49f5 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -558,8 +558,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