From nobody Fri Apr 19 16:00:50 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=1659638557; cv=none; d=zohomail.com; s=zohoarc; b=GNG277i9z5NQlCtPJF+OcqE3jN92HWitfA6BDm64t4lIGc73zX/UTMChgJ0ETb9rl2x4c6U2lnjJ4ODXmp1O9C44ZxRvZVK7VZoU9V3KfNDKHKUfIAjWYqvVyP0D7T8fMf1IAPnh5SJKHodZGM6ZpCXPJAD238wtfw/nepFcazg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638557; 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=JlrQATaWj4/I+cn4VgWKG1BbhIO7HwuSIgnqdviwPUv71w9+qF2ZqjPrwRjPcEBcZhF3e/WW4bHzDkymQSCV0vFlSvLcoxbHYLy1OQkaBtnhx1YlUHFTIMFjmSvj/pLaG7hdCaCIJiiYtNj4JDe/ayVAkwoBf9habrpeTLNJr7Y= 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 165963855795163.946603340509796; Thu, 4 Aug 2022 11:42:37 -0700 (PDT) Received: from localhost ([::1]:38978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfno-00065z-Pm for importer@patchew.org; Thu, 04 Aug 2022 14:42:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfb1-0008Dj-Ly for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfay-00034A-Hn for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:21 -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-500-X4ImEGu5MwGQ_nLFMhYnkA-1; Thu, 04 Aug 2022 14:29:02 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C42BE811E75; Thu, 4 Aug 2022 18:29:01 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7441492C3B; Thu, 4 Aug 2022 18:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637751; 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=EtpPguNqKMTAm0RbwsTzf3VNt1wLsurPB/UPurn/u4ReSf/5rC0b8s7p0wPcsNRvJJ1gpe 9ZvDpVGK2d/nyhNUhGQ7mdPbLQp0+KP9kyMT92i6p1ALYfgQ1Xv0T6GssAnG+zz11gq+C4 mPS2esWqNLOZ/SDhbE+PACTcq6OU5kY= X-MC-Unique: X4ImEGu5MwGQ_nLFMhYnkA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Thu, 4 Aug 2022 20:28:41 +0200 Message-Id: <20220804182852.703398-2-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659638560093100001 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 Fri Apr 19 16:00:50 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=1659638449; cv=none; d=zohomail.com; s=zohoarc; b=b5ob6CizH5FDeSF+fl6e6cKcgeZPK28v7Wb1tDLO0B4B1VFEoP2nMTFvekmWyLqLf2R2oHHJjmvRZ+J0sVArx2sjy5C+ghpvNtrFHPlBysEUVfZh5ns2eZ+fPGDNetcOrxNUOCujIBy09X+TO2peSGFOatDYrVQRBokdbfQkDyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638449; 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=HaVWptiQeouRlRg1k9PshxKQv0gTsoR9wqz/I1zw6xuNEVWDlkPW4pGF9h6Mqi2Upp5JTdgK+VZ2mdrtnb0hDa4uIigsPQZmJ11FWmcOVdDIor5Xni06tOMpkCFybDma7TYqVF+yskfHqNIygKDzSt4rODYjelOxKh66eodf6/A= 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 1659638449839687.5853722966392; Thu, 4 Aug 2022 11:40:49 -0700 (PDT) Received: from localhost ([::1]:33494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfm2-0002E1-U2 for importer@patchew.org; Thu, 04 Aug 2022 14:40:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfaz-0008Di-UA for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfas-00033s-95 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:21 -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-446-Pocj7rV2PYShsW16l8-8UQ-1; Thu, 04 Aug 2022 14:29:05 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F187E101A589; Thu, 4 Aug 2022 18:29:04 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1098C492C3B; Thu, 4 Aug 2022 18:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637746; 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=PJGfQSvP4eEZSRUA8a6g35whmMzeOQ5pLLwAAO11pRsJVSUNDxMoyKARoS+EfgfuAIQl8D iZE7gEn8R1n2uYfRwbmWsqtj6VidFJuhgeBbt9kFvDre5DVJfQCsdBpxezzLurYmWWTuDc lsDEHCkUfol69FsYKsMRcw/CbXj+Q/o= X-MC-Unique: Pocj7rV2PYShsW16l8-8UQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation Date: Thu, 4 Aug 2022 20:28:42 +0200 Message-Id: <20220804182852.703398-3-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659638451676100001 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 Fri Apr 19 16:00:50 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=1659638271; cv=none; d=zohomail.com; s=zohoarc; b=Igfy5YtT1n8yMZv9v46+L/iDv+zEsyK7LWQBf1UnL3wHuc1HwByTNFX4yQL//A3rr5Ve5xnObcmiOwqesLSpcAMVi9aaGbqXiIaV1Cm7zwDlPeSJBefIgD7NIqfxbeQaLnGskMWQOiexetPftwLQN/0fJSkbh0AlYwRBpO/N5Hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638271; 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=VbTWC0evPn1i9Vb7syE8CozR8bniC5oh9jdF2SRiVKDy2p9OWMLMhgYw0A6ktVysSQ/tAuBIMkwwr6Lp99jjWLhBw8xIfNidxcHYPtfsM8weqRe1gPrgi4lOTCRCrsuAVQovH4eXmc/E8G1CNOyKDbRIA9wuI4c8a26YD0JqFbI= 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 1659638271108179.10344831730959; Thu, 4 Aug 2022 11:37:51 -0700 (PDT) Received: from localhost ([::1]:58648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfjB-0007v1-IP for importer@patchew.org; Thu, 04 Aug 2022 14:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfb1-0008F8-Bo for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfay-00034G-JU for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:23 -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-427-nuQN8Na3Nuq__q-aF9DJ_g-1; Thu, 04 Aug 2022 14:29:09 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A108C2802281; Thu, 4 Aug 2022 18:29:08 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42DE8492C3B; Thu, 4 Aug 2022 18:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637752; 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=RQq1weoeFHALmw+xkZGVCPY6+4VhYpVCb+a0Las9GSDL/R5ijuhQiinJn/HPChMSSbAXbG aBOssQv4oobjzj9gGYaulHrdKY+sKzQ2AUlLRhBkYJxJiQ6FnLjijl2aBGEb9xoxJuGKNK DdVzQ9IcYKHEPoHS7TIpE14eR/EJGjE= X-MC-Unique: nuQN8Na3Nuq__q-aF9DJ_g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 03/12] vhost: Delete useless read memory barrier Date: Thu, 4 Aug 2022 20:28:43 +0200 Message-Id: <20220804182852.703398-4-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659638271739100001 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 Fri Apr 19 16:00:50 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=LAanY1PBBU5G0I/jswTdAzGiTseZpUbBxAOdV/KeHOY5sSEsW2Wz7E/VN4mAtRbglWuNSD6fb6zPbTri4jk8QTZCFDJnqggm01vGpIesbU68hK1cj0dI1x75SdxdxFz9g00N1xfzfrEEt9Ow6iTk5H8UVr/cNoXvD1ZnbQKRPWg= 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=0B8KI4/fnEok6w2Efz5xLoWx7wcqHk6mQq7G+EE1gok=; b=fBCKHsUlabAE7FWgSCqfn/yPM1UvXQA9+3QLekK5He1j5gs/scUd/7sy4uarWXc1S2zkDMsuwm3eCBF+W8t/gtzcmPUorc+xTzVx+/mp5LdpCDYGO6gGlqh2onpe1P3mdXf9cyQugyoJ56l3KZtY1rmc159VixLBJeDyYi+8bPY= 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 1659638649864764.8852208784986; Thu, 4 Aug 2022 11:44:09 -0700 (PDT) Received: from localhost ([::1]:42022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfpI-0008GN-S6 for importer@patchew.org; Thu, 04 Aug 2022 14:44:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfb1-0008F7-3z for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfay-00034M-Hv for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:22 -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-634-LUJY8N6dOHir5wgRuLQLNA-1; Thu, 04 Aug 2022 14:29:13 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A54F811E80; Thu, 4 Aug 2022 18:29:13 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08DFB492C3B; Thu, 4 Aug 2022 18:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637756; 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=VTNRp5r3wdRfnnOnYTa3g48rJuUz+xVnvQGGr1O2kHO1BjrJvblKvUPgTz4mygcdvpk2hj xt5ftA12HsAHtcMU+3QpMJjJwxd0RjxUxMnQWd35yHeomuiPdGBJHf90wUKIRzsyLVf0Dx 8YB/z2DkzO2kOLEUJGdT1RNemMf6ElU= X-MC-Unique: LUJY8N6dOHir5wgRuLQLNA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush Date: Thu, 4 Aug 2022 20:28:44 +0200 Message-Id: <20220804182852.703398-5-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659638650688100001 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 Fri Apr 19 16:00:50 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=1659638905; cv=none; d=zohomail.com; s=zohoarc; b=MuGY3JJi34WtR7Zcu/K96296/rYIn4+rqKzUVn9Azj9D/SaJNnoxCUAr9jggdflWAqReV4Xh3kio0ssMvGk9ydHv8PIseDQW++UkuiDT+L2tMSm1eELGiTPUUFsoGxfI90ounbB8gud/tRzzblpogfFEgfnPb5YVs6aLx80F6p4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638905; 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=bfjEJ4q1dbPEMI6cXYJ0+iOw4OfXd0Twwqu/yXibLSjzzIHFyg6ARHcHMis/s+Cwwr+dLON++UGOTpzu56Wsw8KBkWGkVgt+dLbpfWy++M3JMjiOuAwlO+8JiwKXrbdNjHjKE1yQl6GSkAkV3zOB2PKDlmRDpE6w2kG2KlYmDek= 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 1659638905167592.0151672254442; Thu, 4 Aug 2022 11:48:25 -0700 (PDT) Received: from localhost ([::1]:50380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJftO-0005eZ-2V for importer@patchew.org; Thu, 04 Aug 2022 14:48:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfb1-0008FA-LR for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfaz-00034S-6Z for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:23 -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-586-iRtr7gYuOa--xs6nwfxMKA-1; Thu, 04 Aug 2022 14:29:17 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5420A3C35F03; Thu, 4 Aug 2022 18:29:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id B30A0492C3B; Thu, 4 Aug 2022 18:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637760; 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=DyIVH6y3orTF9PXotGfXermgExofvzGVSf4aFZZj1maEpGm2dyEiSXV5TuxQ953UpSExGE uhqxkp3mYZGV0HvdPxTeg5Z1eS2H2GyrDS9++tQpQSgvakMU5/ErDKdwrTtw2yHbYHNHAs OH+SFZ2Mwg7oYk2Bj4U7UJUW16iyvlY= X-MC-Unique: iRtr7gYuOa--xs6nwfxMKA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 05/12] vhost_net: Add NetClientInfo prepare callback Date: Thu, 4 Aug 2022 20:28:45 +0200 Message-Id: <20220804182852.703398-6-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659638906640100001 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 19 16:00:50 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=1659639351; cv=none; d=zohomail.com; s=zohoarc; b=G+rpwV/cbnHEpLdNFl2tdEKDMucztvprNyp+B2r2L6h/25KkXnHur7ApWvRE9+DQIQKWt5jsPA5mc6s6KnaCGmd8ExdZ9dD0egMb0oRF1YcRSbxb2t9ISS1cZMLwgU381gtjFAwes72ttu6NHQBnM4uohX78Nh1CCj1xpfkkrio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659639351; 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=dKL+h7zATc1YtIY1b91nUVArYS/wGNHrvS1LzDaaLPRCeTQV8ksiFgpoJ8UK7Z9N1IIBhKW7qW1EyepLTAu30Wpy2Oiv7CAgFclq4hjgbIBXCLUHwQJ82+6msSFMI4mR6kvlV5lCOfhbKV5ghhjnXaeYabgrc1gJ81WMy+IWtm8= 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 165963935138722.347020966474815; Thu, 4 Aug 2022 11:55:51 -0700 (PDT) Received: from localhost ([::1]:37358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJg0b-0008QB-AS for importer@patchew.org; Thu, 04 Aug 2022 14:55:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbB-0008JR-TW for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38223) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfb9-00035U-Oh for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:32 -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-164--SIhPTAnPwSMfRZshneFVQ-1; Thu, 04 Aug 2022 14:29:22 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6289618E5340; Thu, 4 Aug 2022 18:29:21 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0983492C3B; Thu, 4 Aug 2022 18:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637766; 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=f3H8EZHPb8LvY8qz0H6y/413LcimZf5pGlQhkc+Pkk8N39pTQVZLi+9dPX2wQ7ZzGo5Dvi T2kRV9Hei/rw39sK21Z8VtaTzb1qEx1UY2wfP/Frk7hdHfsQb8/nQ/9/rk/3Z/JS9MKquJ L4JWu96plJjyt7+wfyJZRZ8H2qIlWoc= X-MC-Unique: -SIhPTAnPwSMfRZshneFVQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 06/12] vhost_net: Add NetClientInfo stop callback Date: Thu, 4 Aug 2022 20:28:46 +0200 Message-Id: <20220804182852.703398-7-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659639352385100001 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 19 16:00:50 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=1659639145; cv=none; d=zohomail.com; s=zohoarc; b=Ci2WgzTHCLns1+LVTOlKefUXHwCZ25sNIYgDFjPeQkaX8L0InUbvjLnN58KHH0fkYGf0JK2cE/QLewySuXAMP2AHZ9W7nG6nCPpQst+8ClUBc8+wKjzQLD/P7qp1NuhIBdjCRz2g6IxQ2OmZdOktZVbK7pb8lUFiv0WN0QNzlTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659639145; 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=U/BZNLomJ2HehZswngKMm7pO3wHimh+mde+FrwHm/GSPw08Q88m9lEqcvU+5hlGYRPyxrQE1z+duX81hHi3ydvKfYRCk8Mcs1Fm002rIjhCIWMesuKaneXfHmkcUeTOk3SwOelyhCiOH8GCmuFHQO6/KYjIefHUleef/oGrB0M0= 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 1659639145479808.1139122600608; Thu, 4 Aug 2022 11:52:25 -0700 (PDT) Received: from localhost ([::1]:58258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfxI-0003Gm-4i for importer@patchew.org; Thu, 04 Aug 2022 14:52:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbB-0008JS-Tv for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfb9-00035Z-Ow for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:32 -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-184-ouAeM04_Mw6MSxE0XnTWqg-1; Thu, 04 Aug 2022 14:29:26 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 61A828041BE; Thu, 4 Aug 2022 18:29:25 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id B17F3492C3B; Thu, 4 Aug 2022 18:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637769; 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=ieGqutNj2Ld1nHqnyUcb0YZATuHkawXHv9Xl8tDeAEBhwTkcCHI06qluOB5xnnhL+pymt3 5xaWcf1xEiZLsBEw45o+GRtcNRNzQ1zOqnSan7OhW2640HB6/oRzlCq0ZyQY40CH02oHK7 gGESD3udTDw2gvp0ucJzO0x1M3nSo6A= X-MC-Unique: ouAeM04_Mw6MSxE0XnTWqg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo Date: Thu, 4 Aug 2022 20:28:47 +0200 Message-Id: <20220804182852.703398-8-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659639147691100001 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 19 16:00:50 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=1659638762; cv=none; d=zohomail.com; s=zohoarc; b=RbQAEOWNppn0duAQSrugg9q8F4fZTKPvd06+mMY5KziLOg03Z5wHh8vSp4uRsFFCSqg9jaIU+abwTwf5Wq05Q5VhWmFFPvPWhKj+NlEpVHLNW1eDhoTmExzfuZ0d28ksvqfyNI5gYeXZOL9u6qcYcY0Eb83BN3ZLlc6eY9c9tLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659638762; 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=Feje2AqiaoUXS+ANLLHU5JGsNKI+7WrZJ5XAScDO5bsu7k0pRBN6Xx2IFlCmj56f0eDnwEHWX4yyorAspVotgUQfUHIj16Pgr4XtWEhNr0DC5dCzyQ5WiMhPWQScHFYLAQQsx1kZZ+utQhdgUABTuKw3qoayKNMREsfNNBshk8Y= 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 1659638762398634.2816696436823; Thu, 4 Aug 2022 11:46:02 -0700 (PDT) Received: from localhost ([::1]:47302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfr7-0003U5-8Q for importer@patchew.org; Thu, 04 Aug 2022 14:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbD-0008M3-SY for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbC-00036I-31 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:35 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-hfUwflanNnqnTYSkLtBQOA-1; Thu, 04 Aug 2022 14:29:30 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1D1838217E2; Thu, 4 Aug 2022 18:29:29 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBFE4492C3B; Thu, 4 Aug 2022 18:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637773; 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=LnrIHpUR+1H8GF0Tvk4axlwNK/CSqNZ2LDTc9D0DhK4PjYHG3fSQzRmIgtK2Xf6vaBw+zR CF+DSCTsmZcRHFKzjnVyvjAHOy9ReJEZpVWCl4GviBdCJ6mTqvZJhoy3cbYhhKJ/nLE2kQ sFim1JuE53L3oW/cKwEmZxjLx5S7RLE= X-MC-Unique: hfUwflanNnqnTYSkLtBQOA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 08/12] vdpa: Move command buffers map to start of net device Date: Thu, 4 Aug 2022 20:28:48 +0200 Message-Id: <20220804182852.703398-9-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659638763734100001 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 19 16:00:50 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=1659639441; cv=none; d=zohomail.com; s=zohoarc; b=TayCGUZK+Vk0MUsPh9Z4J9tlYTlGu9qCMlbIuSPrNKIbPgAxO6GuyTW4DK9HsBHYiHAe+Luy/jTdukYl3/EFWpW1VxBkEUbRwmTMEOzfIgx6r0jStAxOJ3IeqLo4H7nBvjmJNGdHTVEY+fYo0k8o94zdN4QHimPXLeosnlDdfBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659639441; 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=5pZdk6LydEoN8PZNnq49NicAup5NQbx65HQ8/IEV9hY=; b=ZJduKvOS84PPrrN7wFczxuFWV2Ck1nfMDIyjVqAg56lioGxymoavJzoj9+CpsP4uhMbNFj0rrZaC76k9i398Qq95+d3WRmEK3XZkUQPg0tCcIyAPNEFPpYZakWu0dNz8HLkVkekXqN/PFxcLIQVDMBfdjzs4JL6niHG4TMGkXC0= 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 1659639441350171.9296070950411; Thu, 4 Aug 2022 11:57:21 -0700 (PDT) Received: from localhost ([::1]:42598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJg24-0003s8-Bt for importer@patchew.org; Thu, 04 Aug 2022 14:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbU-0000V3-Re for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbS-00037d-0j for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:52 -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-98-FkUJ9pBVOBSzpdj9u-heWA-1; Thu, 04 Aug 2022 14:29:38 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B57885A58B; Thu, 4 Aug 2022 18:29:34 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60DC2492C3B; Thu, 4 Aug 2022 18:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637789; 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=5pZdk6LydEoN8PZNnq49NicAup5NQbx65HQ8/IEV9hY=; b=BoQxCqyWWJ4i2teo+AlHM53ej0JL+eaKw/RkzJzHeb1Z9i1Pv/dqLYPbH9cHzKpS8CQyca YTsQcU2V2oq5+/CIETrcwIp0p4xdNoVtL8QtApdD3uKNeHQiDkVblvvcq+pbo4e7/86PqZ 5o1PnFYwk86sLNAIK+bveXbRBRwCM7I= X-MC-Unique: FkUJ9pBVOBSzpdj9u-heWA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 09/12] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Thu, 4 Aug 2022 20:28:49 +0200 Message-Id: <20220804182852.703398-10-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659639443089100001 So we can reuse it to inject state messages. Signed-off-by: Eugenio P=C3=A9rez -- 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. Acked-by: Jason Wang --- 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..10843e6d97 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -331,6 +331,38 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) } } =20 +static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len, + size_t in_len) +{ + /* Buffers for the device */ + const struct iovec out =3D { + .iov_base =3D s->cvq_cmd_out_buffer, + .iov_len =3D out_len, + }; + const struct iovec in =3D { + .iov_base =3D s->cvq_cmd_in_buffer, + .iov_len =3D sizeof(virtio_net_ctrl_ack), + }; + VhostShadowVirtqueue *svq =3D g_ptr_array_index(s->vhost_vdpa.shadow_v= qs, 0); + int r; + + r =3D vhost_svq_add(svq, &out, 1, &in, 1, NULL); + if (unlikely(r !=3D 0)) { + if (unlikely(r =3D=3D -ENOSPC)) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n= ", + __func__); + } + return r; + } + + /* + * We can poll here since we've had BQL from the time we sent the + * descriptor. Also, we need to take the answer before SVQ pulls by it= self, + * when BQL is released + */ + return vhost_svq_poll(svq); +} + static NetClientInfo net_vhost_vdpa_cvq_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), @@ -387,23 +419,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, void *opaque) { VhostVDPAState *s =3D opaque; - size_t in_len, dev_written; + size_t in_len; virtio_net_ctrl_ack status =3D VIRTIO_NET_ERR; /* Out buffer sent to both the vdpa device and the device model */ struct iovec out =3D { .iov_base =3D s->cvq_cmd_out_buffer, }; - /* In buffer sent to the device */ - const struct iovec dev_in =3D { - .iov_base =3D s->cvq_cmd_in_buffer, - .iov_len =3D sizeof(virtio_net_ctrl_ack), - }; /* in buffer used for device model */ const struct iovec in =3D { .iov_base =3D &status, .iov_len =3D sizeof(status), }; - int r =3D -EINVAL; + ssize_t dev_written =3D -EINVAL; bool ok; =20 out.iov_len =3D iov_to_buf(elem->out_sg, elem->out_num, 0, @@ -414,21 +441,11 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, goto out; } =20 - r =3D vhost_svq_add(svq, &out, 1, &dev_in, 1, elem); - if (unlikely(r !=3D 0)) { - if (unlikely(r =3D=3D -ENOSPC)) { - qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n= ", - __func__); - } + dev_written =3D vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status)); + if (unlikely(dev_written < 0)) { goto out; } =20 - /* - * We can poll here since we've had BQL from the time we sent the - * descriptor. Also, we need to take the answer before SVQ pulls by it= self, - * when BQL is released - */ - dev_written =3D vhost_svq_poll(svq); if (unlikely(dev_written < sizeof(status))) { error_report("Insufficient written data (%zu)", dev_written); goto out; @@ -436,7 +453,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadow= Virtqueue *svq, =20 memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status)); if (status !=3D VIRTIO_NET_OK) { - goto out; + return VIRTIO_NET_ERR; } =20 status =3D VIRTIO_NET_ERR; @@ -453,7 +470,7 @@ out: } vhost_svq_push_elem(svq, elem, MIN(in_len, sizeof(status))); g_free(elem); - return r; + return dev_written < 0 ? dev_written : 0; } =20 static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops =3D { --=20 2.31.1 From nobody Fri Apr 19 16:00:50 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=1659639239; cv=none; d=zohomail.com; s=zohoarc; b=bIW5yLFTLwJMHm6UuZPzX56Py8mblRgr8aEX03lJzyL0/Bx4wB9OdEHZQmDYRtNUsNOGaLYK0fhr/H8s3PuIX9XOrfFwDHN+yfSsQEz0usWZcKUBank2QICZMYYPibjMeN2Sy8HYqFANlwmOg0Xrb7ZigoTCiWEM/H71FDb3LiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659639239; 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=bDX4VMIxfrOZzJYqZ1NVdTFPMAnFac/rRKwmk9LZNJGDUbEC0v0oFBs3PRPvLMoyBPObUNkSbT9/JszRKH7t0hwuk28YY0x3rbP8HmFe7jxkOXnq/8lKk2LvI+8d6iME+SDA9dqmtDbBKlDyvXrzfE4dLcjyHuSKrAeHRfm8PYE= 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 1659639239884471.861864771519; Thu, 4 Aug 2022 11:53:59 -0700 (PDT) Received: from localhost ([::1]:33392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfyo-0005f1-QV for importer@patchew.org; Thu, 04 Aug 2022 14:53:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbP-0000Dw-M0 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbN-00037L-IJ for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:47 -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-647-3XYWr0k9PLSTJ_46NYSyxA-1; Thu, 04 Aug 2022 14:29:39 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7942B38217EB; Thu, 4 Aug 2022 18:29:38 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id E91DE492C3B; Thu, 4 Aug 2022 18:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637785; 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=dhwcVcd5Lw7g/zpxrz+OpFZw0JjUhsDD0cgpXJ1OHV/fm3aBXACxQzU3zeZ2FIZDsN0ZD4 3oWcOzkYYW5BL0VkHG8O+gx3ntVJlxjLhh+oVkVENxbjjjS/d2W/nW/EylbMNz41CU8thZ 4YFSAWDi8fd2bcslLEWzGQ5fHv2z6S0= X-MC-Unique: 3XYWr0k9PLSTJ_46NYSyxA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 10/12] vhost_net: add NetClientState->load() callback Date: Thu, 4 Aug 2022 20:28:50 +0200 Message-Id: <20220804182852.703398-11-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659639241626100001 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 19 16:00:50 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=1659639302; cv=none; d=zohomail.com; s=zohoarc; b=Z17G2XgpPZvd6HsBFHWcZ/BOalszpLkLsTaQE0BHN6JRFUpDxGU/vUDGqTirRprxz3sMV3EicNhgMtRSd+kUT48Yuz0PMOlK/OqXMloulMaO0O6K0GXXO4+e3lLJ/kjA9BVUYA27dkP8JNThvewyz1ybYrQLtWxaXXpG5licRuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659639302; 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=pNFj6oMvgOD67iAH0IaaMBH44uwo8/iYjbqy8skw2eY=; b=eFcQZ/+XhmoqoWqvJFTzEV+a/FB5VakFQ84qPS1aWN1/TJwq2Hu/1QKP2mbG9JCeEi8iSDiNbQtvjnC5UPtrAP9wk4jIMEHqH2oxr5GBsf/ZCUPiqhp+pflagO4rrpYl5mXwL/ecgJ6N7LmGjBpTMudPEMc2bUbDAxZhtKOHzEs= 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 1659639302361580.1289218327448; Thu, 4 Aug 2022 11:55:02 -0700 (PDT) Received: from localhost ([::1]:36466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJfzo-0007oQ-GG for importer@patchew.org; Thu, 04 Aug 2022 14:55:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbP-0000Cw-GA for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbM-00037G-SH for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:47 -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-212-yjr0nKUIOAyBzNM8edS_KA-1; Thu, 04 Aug 2022 14:29:43 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A89A5185A79C; Thu, 4 Aug 2022 18:29:42 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0EEB492C3B; Thu, 4 Aug 2022 18:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637784; 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=pNFj6oMvgOD67iAH0IaaMBH44uwo8/iYjbqy8skw2eY=; b=g0xRFEX9HgzFRMbscCYqujL/598QyxSHJUbn1MO1d/G/cxJCED1LSMNW4AK/gwunmSkGNa jKRJnmN/bvxyyRRNHjEojB8fdMF8fcajFuKB+jb46BeQIyqDj6U8/02Hav4VYGncTULEPz T9sNVwk3j9BoJswGHfoKC1oYxF5x0Kk= X-MC-Unique: yjr0nKUIOAyBzNM8edS_KA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 11/12] vdpa: Add virtio-net mac address via CVQ at start Date: Thu, 4 Aug 2022 20:28:51 +0200 Message-Id: <20220804182852.703398-12-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659639303972100001 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 10843e6d97..4f1524c2e9 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 19 16:00:50 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=1659639397; cv=none; d=zohomail.com; s=zohoarc; b=g4B/EsIdH5NdJMhdKGuJVvFOMJfweGYIOPGGJCp9zSH2ljktADcba6czD5oZKARkPs6gVVdI6H2+3gnUvJ0liw5X0WAzvBUY8BVRkTjdR9Ycg8JJwKC4i7UJZuqI9W9kjriaRoI5X1pVnkZFBy7NBby3ljQmwahBc5ocQE/1fSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659639397; 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=AyVpOpcBqShcr0HdWILIr+nUPv4LqmtbwcLeKqfGY58=; b=m69X/RGD8Fc1d67Z/CTyCWnv9iYOKBXXbZNkoe3Yiv3bqIRXzMWRaWFP+F3VZXV5IipUeTwu35yMypV2Q5jR6zWvK2agXwuSTiIqeUne8HE55rLezEmiz0qoWfu5VY0Z0hnTevUmzp2WTGwXp0mmuNJVkZvocDUxJ4a6lVKEeEk= 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 165963939729571.95106649774948; Thu, 4 Aug 2022 11:56:37 -0700 (PDT) Received: from localhost ([::1]:39912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJg1M-0001um-40 for importer@patchew.org; Thu, 04 Aug 2022 14:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbV-0000XX-MV for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJfbU-00037h-2u for qemu-devel@nongnu.org; Thu, 04 Aug 2022 14:29:53 -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-428-kAo1-TbaMACR-KKU25COpg-1; Thu, 04 Aug 2022 14:29:47 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2264F1C01B2F; Thu, 4 Aug 2022 18:29:47 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 135FD492C3B; Thu, 4 Aug 2022 18:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659637791; 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=AyVpOpcBqShcr0HdWILIr+nUPv4LqmtbwcLeKqfGY58=; b=T8W2tp2B8/LmWnimMATPt2qr9gex3WKpgl/gRCdFkwRC2lrmpMmWJ7rduZ9F+HG8kHV6bX PyV/8CHI8iuT96JPsx7dVvBJ2RC/mxIBODUNeu+aZ6AiV+ypcEvzsRsMa6OtPWUItnI80E +LsdfqO89PqoSoaHvlCUZj/cRjhVWXk= X-MC-Unique: kAo1-TbaMACR-KKU25COpg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Gonglei (Arei)" , Stefano Garzarella , Parav Pandit , Eric Blake , Gautam Dawar , Markus Armbruster , Paolo Bonzini , Laurent Vivier , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Liuxiangdong , Eli Cohen , Cornelia Huck , Zhu Lingshan Subject: [PATCH v7 12/12] vdpa: Delete CVQ migration blocker Date: Thu, 4 Aug 2022 20:28:52 +0200 Message-Id: <20220804182852.703398-13-eperezma@redhat.com> In-Reply-To: <20220804182852.703398-1-eperezma@redhat.com> References: <20220804182852.703398-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.10 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: 1659639398717100001 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 4f1524c2e9..7c0d600aea 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