From nobody Mon Feb 9 00:42:01 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=1660157946; cv=none; d=zohomail.com; s=zohoarc; b=WIznnJUEF8CFdCMYBis8PoSgfV8Xlcw55YcLbhESRnEbU99dguqkXxJewai10cMo2q6ORjxmCPPWbm04Lejra64fvYnbXGWChAjKmmitHgu98Cu/EdKXO1cAR9ZEQhby1U2lJn7Gw5bZClYKIyLNCB2eTwgEqR9vrybnFBiF9PM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157946; 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=oeyBAG6aT1XeG4X0sacNDdNhmDyM8S/qNFDxSwuCWuI=; b=TWFlPr8yZkt0P9eyjZQ7fLVCmVsjNULLvl1Ror9RqP4K8J79r2/rwIp+xGJbK932GspQlkyADjYLCVsZhrKwfmwksw7uaNlZbkLeB6a9y+G3uWXEXoeAYZRyPqdQC3K4Y3VWTImOiqbofcsGU56wt16bTDeH89glPUu0xNJZjZg= 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 1660157946364243.9784837924193; Wed, 10 Aug 2022 11:59:06 -0700 (PDT) Received: from localhost ([::1]:36954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqv1-0007jV-QV for importer@patchew.org; Wed, 10 Aug 2022 14:59:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfO-0002AR-BI for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfM-0006nk-Pw for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42: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-675-tgNjXTU-P-qyKAFHqDjcZQ-1; Wed, 10 Aug 2022 14:42:49 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FA498039A1; Wed, 10 Aug 2022 18:42:48 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDC52C15BA4; Wed, 10 Aug 2022 18:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156972; 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=oeyBAG6aT1XeG4X0sacNDdNhmDyM8S/qNFDxSwuCWuI=; b=GhKqYMgFODaIliJHlemk+eMKuZeDNsHhDMqRY+Z5AFIL54myc8Pa6vSlBnmsgkL1owxi+K lJjuf2BdbUbWmFph5yAMWdyM52RQcQkiVZwkqAkcum4cXM3eETs87SZyqyke7AhvbGe1xs 1L7muRWXC+m4M0VJur6vvcCxC3cQqrg= X-MC-Unique: tgNjXTU-P-qyKAFHqDjcZQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 8/8] vdpa: Conditionally expose _F_LOG in vhost_net devices Date: Wed, 10 Aug 2022 20:42:20 +0200 Message-Id: <20220810184220.2362292-9-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-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.8 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: 1660157947657100003 Vhost-vdpa networking devices need to met a few conditions to be migratable. If SVQ is not enabled from the beginnig, to suspend the device to retrieve the vq state is the first requirement. However, qemu also needs to be able to intercept SVQ from the beginning. To be able to do so, the vdpa device needs to expose certains features. Expose _F_LOG only if all of these are met. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 4c6947feb8..73c27cd315 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -49,6 +49,9 @@ typedef struct VhostVDPAState { /* Device log enabled */ bool log_enabled; =20 + /* Device can suspend */ + bool feature_suspend; + bool started; } VhostVDPAState; =20 @@ -431,6 +434,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) /* Default values */ v->listener_shadow_vq =3D s->always_svq || s->log_enabled; v->shadow_vqs_enabled =3D s->always_svq || s->log_enabled; + v->feature_log =3D s->always_svq || s->log_enabled; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_PASSTHROUGH; =20 if (s->address_space_num < 2) { @@ -455,6 +459,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) if (unlikely(vq_group.num =3D=3D cvq_group.num)) { warn_report("CVQ %u group is the same as VQ %u one (%u)", cvq_group.index, vq_group.index, cvq_group.num); + v->feature_log =3D false; return 0; } } @@ -464,6 +469,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) if (r =3D=3D 0) { v->shadow_vqs_enabled =3D true; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_ASID; + v->feature_log =3D s->feature_suspend; } =20 out: @@ -728,6 +734,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, unsigned nas, bool is_datapath, bool svq, + bool feature_suspend, VhostIOVATree *iova_tree) { NetClientState *nc =3D NULL; @@ -748,9 +755,11 @@ static NetClientState *net_vhost_vdpa_init(NetClientSt= ate *peer, s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; s->always_svq =3D svq; + s->feature_suspend =3D feature_suspend; s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.listener_shadow_vq =3D svq; s->vhost_vdpa.iova_tree =3D iova_tree; + s->vhost_vdpa.feature_log =3D feature_suspend; if (queue_pair_index =3D=3D 0) { s->memory_listener =3D (MemoryListener) { .log_global_start =3D vhost_vdpa_net_log_global_start, @@ -839,7 +848,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *nc; int queue_pairs, r, i =3D 0, has_cvq =3D 0; unsigned num_as =3D 1; - bool svq_cvq; + bool svq_cvq, feature_suspend; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -892,10 +901,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, =20 ncs =3D g_malloc0(sizeof(*ncs) * queue_pairs); =20 + feature_suspend =3D backend_features & BIT_ULL(VHOST_BACKEND_F_SUSPEND= ); for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, num_as, true, - opts->x_svq, iova_tree); + opts->x_svq, feature_suspend, iova_tr= ee); if (!ncs[i]) goto err; } @@ -903,7 +913,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, num_as, false, - opts->x_svq, iova_tree); + opts->x_svq, feature_suspend, iova_tree); if (!nc) goto err; } --=20 2.31.1