From nobody Sun Feb 8 15:30:52 2026 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=1658151481; cv=none; d=zohomail.com; s=zohoarc; b=G0RftxKo29ZP4Euuh6InLqZ/NdaUXqIq5pkUUdzqYP9W4zp0Wie2Q40zl70HaCnr63Y+TJbrU4rTWlnfYCYktVrX7/a4vwbNoF+siqfs0kJXafE8SBmIlhh2vlOKMYQOVBn/G/eqQ0ESq9d0bQZjBbXWf3+El/b6cE/tNTPMpvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658151481; 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=SY4uOSurJb50Ktur25r2lnR0+fQOyPTJr8+ul3XGsZo=; b=D6uXWs87G3sUaGTqFBJGynJu6yhjn3UtmM8LQaaGMQ1F5QwsXrHE1FvmjXwT64iX78rMzEjyFqfn4PqhLuHYA/Li8muzYzIcQ9lnr/Wz0xzRZOCl43SlTSMZUBp50CI8YDWzhxPgd/pKXJFzxzivowTbc83gppvVqiap/Lxzsa0= 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 1658151481483928.7684587290912; Mon, 18 Jul 2022 06:38:01 -0700 (PDT) Received: from localhost ([::1]:60640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDQwi-0005f5-74 for importer@patchew.org; Mon, 18 Jul 2022 09:38:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsU-0007Dp-CL for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsR-0007MW-2C for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:36 -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-449-KnYSRZ32MCajJYvniKiRIw-1; Mon, 18 Jul 2022 09:33:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 98BCE280F2AD; Mon, 18 Jul 2022 13:33:29 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDF582166B26; Mon, 18 Jul 2022 13:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658151214; 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=SY4uOSurJb50Ktur25r2lnR0+fQOyPTJr8+ul3XGsZo=; b=bhkwolT4yHVLMbuPYNJUr/b9+vbyCFSBpTIrY9uLEG+mn5iuhFr7ECEidJ2u9R4S+BRhD9 UZyDlx1PbsZtw/IvdaduPdxfgHvqmuceWNhlAyNdPJyziaJSBbcNLazBugnsAiEdCedDkU 0p6fpkqj/sQVnRREhwoVyQfvuBZdRT4= X-MC-Unique: KnYSRZ32MCajJYvniKiRIw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Harpreet Singh Anand , Gautam Dawar , "Gonglei (Arei)" , Stefan Hajnoczi , Liuxiangdong , "Michael S. Tsirkin" , Laurent Vivier , Eli Cohen , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Cornelia Huck , Jason Wang , Cindy Lu , Markus Armbruster , Eric Blake Subject: [PATCH 1/5] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Mon, 18 Jul 2022 15:33:17 +0200 Message-Id: <20220718133321.2902838-2-eperezma@redhat.com> In-Reply-To: <20220718133321.2902838-1-eperezma@redhat.com> References: <20220718133321.2902838-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.78 on 10.11.54.6 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: 1658151482819100001 It was easier to allow vhost_svq_add to handle the memory. Now that we will move SVQDesc to an opaque context, 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 1646d3cb40..1a50faceb7 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -233,9 +233,6 @@ static void vhost_svq_kick(VhostShadowVirtqueue *svq) /** * Add an element to a SVQ. * - * The caller must check that there is enough slots for the new element. It - * takes ownership of the element: In case of failure not ENOSPC, it is fr= ee. - * * Return -EINVAL if element is invalid, -ENOSPC if dev queue is full */ int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg, @@ -252,7 +249,6 @@ int vhost_svq_add(VhostShadowVirtqueue *svq, const stru= ct iovec *out_sg, =20 ok =3D vhost_svq_add_split(svq, out_sg, out_num, in_sg, in_num, &qemu_= head); if (unlikely(!ok)) { - g_free(elem); return -EINVAL; } =20 @@ -293,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueu= e *svq) virtio_queue_set_notification(svq->vq, false); =20 while (true) { - VirtQueueElement *elem; + g_autofree VirtQueueElement *elem; int r; =20 if (svq->next_guest_avail_elem) { @@ -324,12 +320,14 @@ static void vhost_handle_guest_kick(VhostShadowVirtqu= eue *svq) * queue the current guest descriptor and ignore kicks * until some elements are used. */ - svq->next_guest_avail_elem =3D elem; + svq->next_guest_avail_elem =3D g_steal_pointer(&elem); } =20 /* VQ is full or broken, just return and ignore kicks */ return; } + /* elem belongs to SVQ or external caller now */ + elem =3D NULL; } =20 virtio_queue_set_notification(svq->vq, true); --=20 2.31.1 From nobody Sun Feb 8 15:30:52 2026 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=1658151631; cv=none; d=zohomail.com; s=zohoarc; b=FqYPCYzexBYVq7O4d/P+vtN13J8Hvza2VjHfEJ7TzxZt1wBoGV4YzSkISbsBrFGqgqf28z/ult1Hpv6SZtX/jKrbCot7ApAEvPyWqUE09+japPDjTtpt9eZTHtMhdC0BcwV+uAoaaW9K7ON7hX4hbX4O3ZEdohGN6olPrXZvorQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658151631; 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=DMIvkXmmZaOxTsInH4pPo+aXPlzf2WfjoAcbktC0adY=; b=NfblKtDUBAhlk06Xye8B2fb2E8YwcA96LI3/nHQpLJoBfoteJzFAAWaAem+yBT0jNqaWcFw9SVd9d7qt42lHHc38UrDvCFJcigalTTu4O7TfiFq2O4eE6YMO4fZXr1W0K+KE7hSgVRCVqOMI1MXqtH5aB/gGUUyPYzAmIOtOeZE= 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 1658151631908701.6071442681172; Mon, 18 Jul 2022 06:40:31 -0700 (PDT) Received: from localhost ([::1]:39252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDQz8-0001o6-OR for importer@patchew.org; Mon, 18 Jul 2022 09:40:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsX-0007HM-5s for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsV-0007N3-Ir for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:40 -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-662-mT2z3pPSNvmPFAWxUbgLsw-1; Mon, 18 Jul 2022 09:33:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B147D3C0D189; Mon, 18 Jul 2022 13:33:32 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7DDD2166B26; Mon, 18 Jul 2022 13:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658151219; 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=DMIvkXmmZaOxTsInH4pPo+aXPlzf2WfjoAcbktC0adY=; b=ei1JZ5tQu11avabfUZajROx2Owr3o0gtTDZho4TXeiLUdI18FYRJIC3e698CPO8eeRp94U hTfx5Yg4GWagbCUM57Ab5F4tVaMJCv1PK+oRuS48KOHeDkI25WFPVthqm2L1k/6BbND9CJ dHF/n2Tg4urf0pAaFeB4Akrc8TGo/X8= X-MC-Unique: mT2z3pPSNvmPFAWxUbgLsw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Harpreet Singh Anand , Gautam Dawar , "Gonglei (Arei)" , Stefan Hajnoczi , Liuxiangdong , "Michael S. Tsirkin" , Laurent Vivier , Eli Cohen , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Cornelia Huck , Jason Wang , Cindy Lu , Markus Armbruster , Eric Blake Subject: [PATCH 2/5] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Mon, 18 Jul 2022 15:33:18 +0200 Message-Id: <20220718133321.2902838-3-eperezma@redhat.com> In-Reply-To: <20220718133321.2902838-1-eperezma@redhat.com> References: <20220718133321.2902838-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.78 on 10.11.54.6 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: 1658151634120100001 So we can reuse to inject state messages. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 71 ++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 986e6414b4..fa00928854 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -334,6 +334,43 @@ static bool vhost_vdpa_net_cvq_map_elem(VhostVDPAState= *s, return true; } =20 +static virtio_net_ctrl_ack vhost_vdpa_net_cvq_add(VhostShadowVirtqueue *sv= q, + const struct iovec *dev_buf= fers) +{ + /* in buffer used for device model */ + virtio_net_ctrl_ack status; + size_t dev_written; + int r; + void *unused =3D (void *)1; + + r =3D vhost_svq_add(svq, &dev_buffers[0], 1, &dev_buffers[1], 1, unuse= d); + 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 VIRTIO_NET_ERR; + } + + /* + * 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); + return VIRTIO_NET_ERR; + } + + memcpy(&status, dev_buffers[1].iov_base, sizeof(status)); + if (status !=3D VIRTIO_NET_OK) { + return VIRTIO_NET_ERR; + } + + return VIRTIO_NET_OK; +} + /** * 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. @@ -380,19 +417,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 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 }, }; - /* in buffer used for device model */ + /* in buffer seen by virtio-net device model */ const struct iovec in =3D { .iov_base =3D &status, .iov_len =3D sizeof(status), }; - int r; bool ok; =20 ok =3D vhost_vdpa_net_cvq_map_elem(s, elem, dev_buffers); @@ -405,35 +441,16 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShad= owVirtqueue *svq, goto out; } =20 - r =3D vhost_svq_add(svq, &dev_buffers[0], 1, &dev_buffers[1], 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__); - } - goto out; - } - - /* - * 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; - } - - memcpy(&status, dev_buffers[1].iov_base, sizeof(status)); + status =3D vhost_vdpa_net_cvq_add(svq, dev_buffers); 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); - if (status !=3D VIRTIO_NET_OK) { + in_len =3D virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, dev_buffers, = 1); + if (in_len !=3D sizeof(status) || status !=3D VIRTIO_NET_OK) { error_report("Bad CVQ processing in model"); + return VIRTIO_NET_ERR; } =20 out: @@ -450,7 +467,7 @@ out: if (dev_buffers[1].iov_base) { vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, dev_buffers[1].iov_base); } - return r; + return status =3D=3D VIRTIO_NET_OK ? 0 : 1; } =20 static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops =3D { --=20 2.31.1 From nobody Sun Feb 8 15:30:52 2026 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=1658151481; cv=none; d=zohomail.com; s=zohoarc; b=WtxmSwEy5+E6xQoWZnzvxGdQNKas7uX+OMFs5fkuVrzrJoCMts7a6Np5kG7oSBbg1Z/uDjsbemcO7z2BkrZHC3mxL/s6EKl9yATVCU6kG5sP3z1chku8DzoSedi4bK9OOxsGN/b3D1ZJqH5iJypzkbiBqPbvMWlz3R/DF4TH7TY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658151481; 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=lcrN7aXsZEzs0FCgTCcZPSOUEpZXVZqiS8xJ9VkuhDU=; b=kku7xzfa2p2Fzu1GoPskSM8rS7L6/rG98n0aFLKRRMrAPeO+xLloQEJPWeW1j0Z0c42DM1s1Zi8oNo/M4dSlimeLzvnIAIQqSr4utzE05Jm+CVK2uilQOOolwJLxhW+HR0XpYiEXp5oj+MrU+91ig3gRtngVfsc5p7Fd2GLJ4fo= 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 165815148197475.12359297606815; Mon, 18 Jul 2022 06:38:01 -0700 (PDT) Received: from localhost ([::1]:32818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDQwi-0005w9-Vl for importer@patchew.org; Mon, 18 Jul 2022 09:38:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsg-0007ME-QO for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsd-0007Nr-0R for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:49 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-r-xOITjHNx6BNWxhxzEw3A-1; Mon, 18 Jul 2022 09:33:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BDF9823F10; Mon, 18 Jul 2022 13:33:36 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 056462166B26; Mon, 18 Jul 2022 13:33:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658151226; 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=lcrN7aXsZEzs0FCgTCcZPSOUEpZXVZqiS8xJ9VkuhDU=; b=Wkif9UdqVYzDUTE0mu7HTqaE8KNQ2HWNNYqURCIU7tUdIbVdvRbljyauN7T3i0R+q8iGrM QNNuKORNUPB09dqxS7DapYskjgVmkaRIgTzLhvx0Otwy81xQZhYBCdw8glLLakUO5sCYJX g8xBbDTbA7/Qkvf+knRB26M1DnSPsSw= X-MC-Unique: r-xOITjHNx6BNWxhxzEw3A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Harpreet Singh Anand , Gautam Dawar , "Gonglei (Arei)" , Stefan Hajnoczi , Liuxiangdong , "Michael S. Tsirkin" , Laurent Vivier , Eli Cohen , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Cornelia Huck , Jason Wang , Cindy Lu , Markus Armbruster , Eric Blake Subject: [PATCH 3/5] vdpa: Make vhost_vdpa_net_cvq_map_elem accept any out sg Date: Mon, 18 Jul 2022 15:33:19 +0200 Message-Id: <20220718133321.2902838-4-eperezma@redhat.com> In-Reply-To: <20220718133321.2902838-1-eperezma@redhat.com> References: <20220718133321.2902838-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.78 on 10.11.54.6 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: 1658151482828100002 So its generic enough to accept any out sg buffer and we can inject NIC state messages. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index fa00928854..533bd9f680 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -302,35 +302,36 @@ dma_map_err: } =20 /** - * Copy the guest element into a dedicated buffer suitable to be sent to N= IC + * Maps out sg and in buffer into dedicated buffers suitable to be sent to= NIC * - * @iov: [0] is the out buffer, [1] is the in one + * @dev_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 bool vhost_vdpa_net_cvq_map_sg(VhostVDPAState *s, + const struct iovec *out, size_t out_= num, + struct iovec *dev_iov) { size_t in_copied; bool ok; =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); + dev_iov[0].iov_base =3D s->cvq_cmd_out_buffer; + ok =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, out, out_num, + vhost_vdpa_net_cvq_cmd_len(), + dev_iov[0].iov_base, &dev_iov[0].iov_len, + false); if (unlikely(!ok)) { return false; } =20 - iov[1].iov_base =3D s->cvq_cmd_in_buffer; + dev_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); + sizeof(virtio_net_ctrl_ack), + dev_iov[1].iov_base, &in_copied, true); if (unlikely(!ok)) { 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); + dev_iov[1].iov_len =3D sizeof(virtio_net_ctrl_ack); return true; } =20 @@ -431,7 +432,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadow= Virtqueue *svq, }; bool ok; =20 - ok =3D vhost_vdpa_net_cvq_map_elem(s, elem, dev_buffers); + ok =3D vhost_vdpa_net_cvq_map_sg(s, elem->out_sg, elem->out_num, dev_b= uffers); if (unlikely(!ok)) { goto out; } --=20 2.31.1 From nobody Sun Feb 8 15:30:52 2026 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=1658151329; cv=none; d=zohomail.com; s=zohoarc; b=InnKJB1PpmlB/YyYftZ0+F5bGAkFkbvKDR02XAX0lbaUkc2YDImKEJI40qBawLe5zdF40CgPMIO7JluD4YskiRvWJKO7FxCNQi6Tb3fw2eyhmHZ5D6YC+VNMkrfLlnTpl/wuTghkWH7zQaIzdOOjypxQC4h4N9O5sjyXCTYv8G0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658151329; 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=ryBjW7wwJ2lyg4XACQ3EZHs29EK9/HavUG+ow8PFrqU=; b=Uhe+bi0FiMVHs2LHVAmkFCkyGfWkIpTZDsBLHovwNj6pxX1Jp4c2I1niDr0zHTJMQYbbbh0FmR+sdkouopMHUT9c53UMlO6/XRLRKZMBWAYzX/00s4N3FP2Ru6wwzku/UUH/t09nvwIsTNXK4iDo62G2J2dkOckpYFMQTl4cg74= 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 1658151329892653.2810872734258; Mon, 18 Jul 2022 06:35:29 -0700 (PDT) Received: from localhost ([::1]:54046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDQuF-00012I-Rx for importer@patchew.org; Mon, 18 Jul 2022 09:35:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsd-0007KW-0Z for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsb-0007Ni-B1 for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:46 -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-537-YgXN2BAFMMaDld_LSsEL6Q-1; Mon, 18 Jul 2022 09:33:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 458A5185A7BA; Mon, 18 Jul 2022 13:33:39 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 651F82166B26; Mon, 18 Jul 2022 13:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658151224; 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=ryBjW7wwJ2lyg4XACQ3EZHs29EK9/HavUG+ow8PFrqU=; b=OWBOw3mvj+w0EnFFJkslGggUipsemAqurMCRa0Od4oOB9gQsq+XY2MRVe2vfF4ghfTNaBc N+gH9GK9lGRzcLffjCXnkk2HY7TFmMmx1nJoHKpzfPGBJE1tVC0LGrPHt9OlDA76Gc18T7 wWRyS4KGweQJ2oVBPAf9lIu0+fvDH1c= X-MC-Unique: YgXN2BAFMMaDld_LSsEL6Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Harpreet Singh Anand , Gautam Dawar , "Gonglei (Arei)" , Stefan Hajnoczi , Liuxiangdong , "Michael S. Tsirkin" , Laurent Vivier , Eli Cohen , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Cornelia Huck , Jason Wang , Cindy Lu , Markus Armbruster , Eric Blake Subject: [PATCH 4/5] vdpa: Add virtio-net mac address via CVQ at start Date: Mon, 18 Jul 2022 15:33:20 +0200 Message-Id: <20220718133321.2902838-5-eperezma@redhat.com> In-Reply-To: <20220718133321.2902838-1-eperezma@redhat.com> References: <20220718133321.2902838-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.78 on 10.11.54.6 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: 1658151331854100001 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 --- include/net/vhost-vdpa.h | 1 + hw/net/vhost_net.c | 8 ++++++ net/vhost-vdpa.c | 59 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/include/net/vhost-vdpa.h b/include/net/vhost-vdpa.h index b81f9a6f2a..38d65e845d 100644 --- a/include/net/vhost-vdpa.h +++ b/include/net/vhost-vdpa.h @@ -15,6 +15,7 @@ #define TYPE_VHOST_VDPA "vhost-vdpa" =20 struct vhost_net *vhost_vdpa_get_vhost_net(NetClientState *nc); +int vhost_vdpa_start(NetClientState *nc); =20 extern const int vdpa_feature_bits[]; =20 diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index ccac5b7a64..f9cebd9716 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -274,6 +274,13 @@ static int vhost_net_start_one(struct vhost_net *net, } } } + + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA) { + r =3D vhost_vdpa_start(net->nc); + if (r < 0) { + goto fail; + } + } return 0; fail: file.fd =3D -1; @@ -373,6 +380,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, r =3D vhost_net_start_one(get_vhost_net(peer), dev); =20 if (r < 0) { + vhost_net_stop_one(get_vhost_net(peer), dev); goto err_start; } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 533bd9f680..e03f026738 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -342,9 +342,12 @@ static virtio_net_ctrl_ack vhost_vdpa_net_cvq_add(Vhos= tShadowVirtqueue *svq, virtio_net_ctrl_ack status; size_t dev_written; int r; - void *unused =3D (void *)1; =20 - r =3D vhost_svq_add(svq, &dev_buffers[0], 1, &dev_buffers[1], 1, unuse= d); + /* + * Add a fake non-NULL VirtQueueElement since we'll remove before SVQ + * event loop can get it. + */ + r =3D vhost_svq_add(svq, &dev_buffers[0], 1, &dev_buffers[1], 1, (void= *)1); if (unlikely(r !=3D 0)) { if (unlikely(r =3D=3D -ENOSPC)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: No space on device queue\n= ", @@ -372,6 +375,58 @@ static virtio_net_ctrl_ack vhost_vdpa_net_cvq_add(Vhos= tShadowVirtqueue *svq, return VIRTIO_NET_OK; } =20 +int vhost_vdpa_start(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + VirtIONet *n =3D VIRTIO_NET(v->dev->vdev); + uint64_t features =3D v->dev->vdev->host_features; + VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, 0); + + if (v->dev->vq_index + v->dev->nvqs !=3D v->dev->vq_index_end) { + /* Only interested in CVQ */ + return 0; + } + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + 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, + }; + uint8_t mac[6]; + const struct iovec out[] =3D { + { + .iov_base =3D (void *)&ctrl, + .iov_len =3D sizeof(ctrl), + },{ + .iov_base =3D mac, + .iov_len =3D sizeof(mac), + }, + }; + struct iovec dev_buffers[2] =3D { + { .iov_base =3D s->cvq_cmd_out_buffer }, + { .iov_base =3D s->cvq_cmd_in_buffer }, + }; + bool ok; + virtio_net_ctrl_ack state; + + ok =3D vhost_vdpa_net_cvq_map_sg(s, out, ARRAY_SIZE(out), dev_buff= ers); + if (unlikely(!ok)) { + return -1; + } + + memcpy(mac, n->mac, sizeof(mac)); + state =3D vhost_vdpa_net_cvq_add(svq, dev_buffers); + vhost_vdpa_cvq_unmap_buf(v, dev_buffers[0].iov_base); + vhost_vdpa_cvq_unmap_buf(v, dev_buffers[1].iov_base); + return state =3D=3D VIRTIO_NET_OK ? 0 : 1; + } + + return 0; +} + /** * 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. --=20 2.31.1 From nobody Sun Feb 8 15:30:52 2026 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=1658151751; cv=none; d=zohomail.com; s=zohoarc; b=SKvNnrWpn/CBmE1mNPfHWHUjOBdhfpeTSjnrES8wvjX3MFNpzSBq8duksIzd24nhk5/o6/Pj2r5Kr+97j1GJXD4mNTZheGsQIZEOIkxmqsClpdc83xTXtU9OY6Zm2nRp97jH/80GPswqEaBiLXGMlzHB22M1Irk3zyGh2O0Me18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658151751; 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=6vEm/Wf0+FY+Lckc9c3Lx5BOBFUs270srqdXARP4/W8=; b=GaXrFYwu+ucoVrmEUQFvkkgybK8fwZ/g2pswydaBh+Z9CjZCx8975HAmBE++dOjAcfP9hUK2mvrAR/8H1if7giSnU9fAB87ZmbHff4mK8XbIdnEZaO1AVTVFC/11sTb6DjoIEfbjsKF4WNp9yp7mg7pDjhyg7YeWnn3e3GYBZkY= 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 165815175145033.65079970570605; Mon, 18 Jul 2022 06:42:31 -0700 (PDT) Received: from localhost ([::1]:44736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDR14-0005WZ-ET for importer@patchew.org; Mon, 18 Jul 2022 09:42:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQse-0007LW-UP for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDQsc-0007Nm-JR for qemu-devel@nongnu.org; Mon, 18 Jul 2022 09:33: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-271-7a3wkYm_PeK5vs2AE_iLlw-1; Mon, 18 Jul 2022 09:33:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68E8D1C04B53; Mon, 18 Jul 2022 13:33:42 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85D392166B26; Mon, 18 Jul 2022 13:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658151226; 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=6vEm/Wf0+FY+Lckc9c3Lx5BOBFUs270srqdXARP4/W8=; b=QUVmmxve/qw+5f+1ChUMWmYpnNzRsAtCg0ywPok6WpIa7pKWLa7VFl503KUugN8CEiE3uR W4GVDNQZzIHW1eXjOAm3aaraoyGLkkCgX1QVxSReKJn1DQQ35/z4OOFuIIxTU3bzUeeTQM nsOteSFnP19b36++5SzwkP9bpmCcKJk= X-MC-Unique: 7a3wkYm_PeK5vs2AE_iLlw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Harpreet Singh Anand , Gautam Dawar , "Gonglei (Arei)" , Stefan Hajnoczi , Liuxiangdong , "Michael S. Tsirkin" , Laurent Vivier , Eli Cohen , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Cornelia Huck , Jason Wang , Cindy Lu , Markus Armbruster , Eric Blake Subject: [PATCH 5/5] vdpa: Delete CVQ migration blocker Date: Mon, 18 Jul 2022 15:33:21 +0200 Message-Id: <20220718133321.2902838-6-eperezma@redhat.com> In-Reply-To: <20220718133321.2902838-1-eperezma@redhat.com> References: <20220718133321.2902838-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.78 on 10.11.54.6 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: 1658151752841100001 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 | 11 ----------- net/vhost-vdpa.c | 2 -- 3 files changed, 14 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 4458c8d23e..479151bd77 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1023,13 +1023,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)) { - goto err_migration_blocker; - } - } - 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); @@ -1072,7 +1065,6 @@ err: vhost_svq_stop(svq); } =20 -err_migration_blocker: error_reportf_err(err, "Cannot setup SVQ %u: ", i); =20 return false; @@ -1094,9 +1086,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 e03f026738..4a39dad47b 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -568,8 +568,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