From nobody Mon Feb 9 01:22:12 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=1658161972; cv=none; d=zohomail.com; s=zohoarc; b=dMzf9liNfWkhOfUNN3R7HGm9PcCD8SgUqZllQdjD2hC8plDsnyjLSm8JR3Dklgy64k3OpG7wSBk1wcFQMrlKEcS0nPy4/ciFMeS+HjdLQiSIRKLo6ytWwX9eB8Q7FNvIEtiE6bxNt07NjgF7Smdi7foUFL3Ftg4mKwThy3dAQUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658161972; 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=ZP1Nla0uV4KjhqMv7Wx1x1xz2wqGnXZB+nnJLX408RDEKqqmFE8Ym8LKd4GOvpCSgd3ZTG5cSvxxdnBerCPf0ZUD1uwGLSIob0kmypNntyNwsJA6WY9mOI3cwLYICYBVGDuxWTLhkc63SaPffyV/5dE98BdZsPgtAsbssFv1oWg= 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 1658161972414349.35165047181795; Mon, 18 Jul 2022 09:32:52 -0700 (PDT) Received: from localhost ([::1]:38226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDTft-0003rL-Mz for importer@patchew.org; Mon, 18 Jul 2022 12:32:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTd6-0001Ua-CS for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:29:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTd3-0001l0-3h for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:29:54 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-mWLSrRgVPLW4-2EO8JJUmw-1; Mon, 18 Jul 2022 12:29:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B51741019C9D; Mon, 18 Jul 2022 16:29:48 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01C0540D2962; Mon, 18 Jul 2022 16:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658161792; 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=bCO7SYvwFmiz3JLjPYPrTiAqePqHFPxtqz60yYAfGMQg9SW3DhW+fuf9MeTqp6kul1sAYU KtL6vDG3DFiP+jsyt5mc6N0btuEpx2RBfLfme9PV6i9sS2Ryab/VpCB6DaWX49AEMsPmI+ /CdkvyPK0ZZLJStIA9D7f30oIf+5R60= X-MC-Unique: mWLSrRgVPLW4-2EO8JJUmw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Michael S. Tsirkin" , Markus Armbruster , Laurent Vivier , Liuxiangdong , Eric Blake , Paolo Bonzini , Cornelia Huck , Stefan Hajnoczi , Gautam Dawar , "Gonglei (Arei)" , Zhu Lingshan , Parav Pandit , Stefano Garzarella , Eli Cohen , Jason Wang Subject: [PATCH v2 1/5] vhost: stop transfer elem ownership in vhost_handle_guest_kick Date: Mon, 18 Jul 2022 18:29:34 +0200 Message-Id: <20220718162938.2938783-2-eperezma@redhat.com> In-Reply-To: <20220718162938.2938783-1-eperezma@redhat.com> References: <20220718162938.2938783-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658161974863100001 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 Mon Feb 9 01:22:12 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=1658161972; cv=none; d=zohomail.com; s=zohoarc; b=FvXgo9zfGHxiP/lqA1WiRJAIbbC/zq1D5dyLZQfCwsLe46Bv/vpIfU7qznRfbu8e2FsuLHZhKE+F0YiN7FPzqEecVPO4NvdfQzjA6K37UaRCu/xFx/q2diIXapabLIcLUxsWTJRmqb7YfPxbwpmBQm1IWLqcicnKQNHsj1/J/Rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658161972; 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=jKdzzhfrttll7fXLvA9jfcqcIIe8A9QSj7Kbbj5AJ59bnQh8e6N8mnWSGawIjtH3hkIXfkbzwK7Z9pHV/Dj61cPT4g8xoh4rv+Bh8lJRKStR/2ezlv4a2xyv3/s4/vj7jezWmspqIIjhKnopXFP5/ieVZDzqfPO2iKBggdJwyM0= 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 1658161972385615.6146513352991; Mon, 18 Jul 2022 09:32:52 -0700 (PDT) Received: from localhost ([::1]:38188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDTft-0003pj-NS for importer@patchew.org; Mon, 18 Jul 2022 12:32:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTdB-0001YR-0N for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54244) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTd9-0001m5-G3 for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:00 -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-628-Ra42eaD1PSeV_xG5bk3ucA-1; Mon, 18 Jul 2022 12:29:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3A183804529; Mon, 18 Jul 2022 16:29:52 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1062440E80E0; Mon, 18 Jul 2022 16:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658161798; 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=d9DehMEIj9yH/W4qpsUbquaVXEMq1BAc36zvh3A26hp58j259oXvhm+K1ft9gWUGrCaYbI gqz0PqkqO+Uab7dABVWu4jfy0jzB9Wm56xItPiBN/ylqNhCTibtEhjuofmDTDmhfDHhMFN B/w7VM1XS1zVeIH2h2+PIrUfHDIZ5R8= X-MC-Unique: Ra42eaD1PSeV_xG5bk3ucA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Michael S. Tsirkin" , Markus Armbruster , Laurent Vivier , Liuxiangdong , Eric Blake , Paolo Bonzini , Cornelia Huck , Stefan Hajnoczi , Gautam Dawar , "Gonglei (Arei)" , Zhu Lingshan , Parav Pandit , Stefano Garzarella , Eli Cohen , Jason Wang Subject: [PATCH v2 2/5] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail Date: Mon, 18 Jul 2022 18:29:35 +0200 Message-Id: <20220718162938.2938783-3-eperezma@redhat.com> In-Reply-To: <20220718162938.2938783-1-eperezma@redhat.com> References: <20220718162938.2938783-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658161974866100002 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 Mon Feb 9 01:22:12 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=1658162175; cv=none; d=zohomail.com; s=zohoarc; b=fyph4VuvBmSEaTqnfyUoJbT7trHYiTZCvi0BeV/lqzxD546NYsNS5tskiwybtoseYvhJmGefd70Wfda3tfoIzQ1dBJuFEkVubqPwJSXmLiuCbTcYXxYGumrPwMFi9ojz58o5sEQvzmx+CfA3eGUEg9PxlqsKB5OU+onghvfrU5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658162175; 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=Jb0Wq8zKbzkT1oU2qiZkEvT2hHJWeSiSXe9KjiAHCtOeamzBT38wVI4ylYah/uztLY5GU/H1VCwFtm6uiXjSC7S1o7nGm3vLnLhLkEq6PDgaf+JXMnSTqTzoozvai+YT81ZmBFjqL/87UkIwNuqhU0a5s3hllmEe3TR9vL90zbY= 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 16581621753181012.2944725751951; Mon, 18 Jul 2022 09:36:15 -0700 (PDT) Received: from localhost ([::1]:44660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDTjC-0008PE-6t for importer@patchew.org; Mon, 18 Jul 2022 12:36:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTdB-0001YS-13 for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTd9-0001m4-HB for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:00 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-aH5XHLtKMm-9SkRBvZajeQ-1; Mon, 18 Jul 2022 12:29:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6DE51C16B41; Mon, 18 Jul 2022 16:29:56 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30F9640D2962; Mon, 18 Jul 2022 16:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658161798; 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=ThFK78mp9VDCQBd8xxd7ItBeUFrOPkEQpLh9jwFYYMlMovA1QsbP2r7yeDx/qubmU0Dj/B j6Sfnr5FI74Aw3Ogt+NjjP19VZMBv4g9OO6O3jiI0iH+bWNCpZQHSLyFJn4CMrLWee27S4 YfEzRe154uDfpct5VE21nYcq4AQ7LE8= X-MC-Unique: aH5XHLtKMm-9SkRBvZajeQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Michael S. Tsirkin" , Markus Armbruster , Laurent Vivier , Liuxiangdong , Eric Blake , Paolo Bonzini , Cornelia Huck , Stefan Hajnoczi , Gautam Dawar , "Gonglei (Arei)" , Zhu Lingshan , Parav Pandit , Stefano Garzarella , Eli Cohen , Jason Wang Subject: [PATCH v2 3/5] vdpa: Make vhost_vdpa_net_cvq_map_elem accept any out sg Date: Mon, 18 Jul 2022 18:29:36 +0200 Message-Id: <20220718162938.2938783-4-eperezma@redhat.com> In-Reply-To: <20220718162938.2938783-1-eperezma@redhat.com> References: <20220718162938.2938783-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658162176307100001 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 Mon Feb 9 01:22:12 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=1658162176; cv=none; d=zohomail.com; s=zohoarc; b=dOV4GEcmeKANSGBVkJMplZ+u33CC237CiLb8QVqLVij8hLT2jHs52lhd+Amdkxx2Kpr2q9tH7K08WIOCaeZRkudQTF26ZWCrq9fUdduX47//XEoup2G/APlVCaopfqUi6qKltb38keW+Aj7J6caSzCRnuaSBM/gzZQVqcVfR4tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658162176; 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=0s+V/WeCdrTwXKGRjvxrCDJPS1vqq8doXBYc6mmab4w=; b=ZDkc8cutcqwSjIoQOGeBT4vs+3de6SAEdk2VgieKXndxEBlUmf6QUWg4UBQ4IudLLT1j7T1YiKLhKr4t0aGzz3ZFM7mI3t7N8v8FkueJUJNd22GKND1dGPn0EscKnqKTFGpTyaz/sxl6mkBMz0D/99BMtCm7g+IS6CWO+v7lP0E= 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 16581621766216.067698358285952; Mon, 18 Jul 2022 09:36:16 -0700 (PDT) Received: from localhost ([::1]:44708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDTjD-0008Ts-Jz for importer@patchew.org; Mon, 18 Jul 2022 12:36:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTdG-0001bk-Do for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTdE-0001yZ-MQ for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:06 -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-441-BgYxd58rP-afRczTGfvxlA-1; Mon, 18 Jul 2022 12:30:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 049F38032F0; Mon, 18 Jul 2022 16:30:00 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBDE840E80E0; Mon, 18 Jul 2022 16:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658161803; 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=0s+V/WeCdrTwXKGRjvxrCDJPS1vqq8doXBYc6mmab4w=; b=MP+57GipHUgm23zwGOKasq1LEDGiiVmzyAj36s9XjUS0vy9iJoz0D3W9Sg/mEh3Sy11bem sEh33iTOIgFud4azCW00f48y+5bkVsX5BeSY+3gDwJ1l+LCJ4vqOKpsj2fSezkXKDWbqGZ 5Mc4n1XmV+DNMahejjvkh+3Ag92BTLQ= X-MC-Unique: BgYxd58rP-afRczTGfvxlA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Michael S. Tsirkin" , Markus Armbruster , Laurent Vivier , Liuxiangdong , Eric Blake , Paolo Bonzini , Cornelia Huck , Stefan Hajnoczi , Gautam Dawar , "Gonglei (Arei)" , Zhu Lingshan , Parav Pandit , Stefano Garzarella , Eli Cohen , Jason Wang Subject: [PATCH v2 4/5] vdpa: Add virtio-net mac address via CVQ at start Date: Mon, 18 Jul 2022 18:29:37 +0200 Message-Id: <20220718162938.2938783-5-eperezma@redhat.com> In-Reply-To: <20220718162938.2938783-1-eperezma@redhat.com> References: <20220718162938.2938783-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658162178357100001 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 | 64 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 71 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..84e90f067a 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,63 @@ 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; + + if (!v->shadow_vqs_enabled) { + return 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); + + svq =3D g_ptr_array_index(v->shadow_vqs, 0); + 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 Mon Feb 9 01:22:12 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=1658162394; cv=none; d=zohomail.com; s=zohoarc; b=C/sWsX+Aybt+oxtSD9tJcxPM9z2XAzMGw8NRcZ5CF1hfQWatUfbnnDLdLnMRStYtJ36RQkogVPW4f2vo1gU/VAL90WWdi9O4W5Vb7pNZyNmH002etRzXo6AkZyZGriyrWoHL9mzMbUMHFRoTz2hT/MKdOYJuggqfpIuOxXn3lG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658162394; 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=TSfUSYpQx8mBUnb1kseF1FZBnmV3Kz0Wr49ta7JUeWE=; b=DfGTTAWf/TZZYbkbE4yNSQB4vm0IN+H+paEEuOTBxMS/Qoh99GotrB4p2VGm3HbbR3MjsKdoN3nKu/fYG+8X/glPZYcP+j11cpYnMmLQTRXvjB8wrR4AVHttUZxJkO9nY/tJ29W1qN+bld6713SgM9mapkSYoTro7/YyKLm1zCY= 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 1658162393774691.675158695856; Mon, 18 Jul 2022 09:39:53 -0700 (PDT) Received: from localhost ([::1]:50220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDTmh-0003xT-PQ for importer@patchew.org; Mon, 18 Jul 2022 12:39:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTdQ-0001cT-1m for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDTdL-0001z9-BZ for qemu-devel@nongnu.org; Mon, 18 Jul 2022 12:30:14 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-310-0SA9xAdiMe2ZtBoYW90zbA-1; Mon, 18 Jul 2022 12:30:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 310233804523; Mon, 18 Jul 2022 16:30:05 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72EFE403D0CA; Mon, 18 Jul 2022 16:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658161810; 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=TSfUSYpQx8mBUnb1kseF1FZBnmV3Kz0Wr49ta7JUeWE=; b=cEfiMuMy4wNs697W+rEEI6A52CyI/nky3ck9p4PIfSzERhCPDPBy0nUqYDRZqzFPBI1yn8 fsxVyTrbwZpt8MK9pN2kt4ED0BZqgr6gFW3yW1TXALiykhEdxo5NmpofvXr+A3FLwt7CIH fwgycNMKQn+Wy6uu+sASwWNeGhzFb7M= X-MC-Unique: 0SA9xAdiMe2ZtBoYW90zbA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , "Michael S. Tsirkin" , Markus Armbruster , Laurent Vivier , Liuxiangdong , Eric Blake , Paolo Bonzini , Cornelia Huck , Stefan Hajnoczi , Gautam Dawar , "Gonglei (Arei)" , Zhu Lingshan , Parav Pandit , Stefano Garzarella , Eli Cohen , Jason Wang Subject: [PATCH v2 5/5] vdpa: Delete CVQ migration blocker Date: Mon, 18 Jul 2022 18:29:38 +0200 Message-Id: <20220718162938.2938783-6-eperezma@redhat.com> In-Reply-To: <20220718162938.2938783-1-eperezma@redhat.com> References: <20220718162938.2938783-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658162394629100001 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 84e90f067a..82c115bee4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -573,8 +573,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