From nobody Fri May 10 15:13:12 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=1685115168; cv=none; d=zohomail.com; s=zohoarc; b=FaxnSwLh6p5D7pHlhnOCWlfMaDiXUFvQlBCefC3pDtrheFi7toXPuPNlI+JQswgfRcLHjuz2fZA4urc3o60ii8Ikv/ePnWXw9Wdn4UbMVOsHd5anFNzEMX47uxCYSTeBNDTOxHTRlLwB104KYoGrcQmy+EEZZP6olJaivKm1OnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685115168; 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=25QPWRUap87P8qT0SKZ7bty4YrGO74WAbW2+RZPm14I=; b=f3RvK5NGrVogSXSnqES/3STXc/bT1Z60XSy7JBli5ZKToOTRBvLjGJbkrQW4CPDCCuxqybGQoU5ZitLjfUtoIb6rRD6DgGed/amAi+Rzk019fbasZ6JE+47cXjqDGBt7IzLyB1JO86/C1uI9Y6sdmOB/5sSeamCEsXF5WMsZulo= 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 1685115168252483.73617211203464; Fri, 26 May 2023 08:32:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2ZQE-0003pl-Kh; Fri, 26 May 2023 11:32:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2ZQD-0003pd-7Y for qemu-devel@nongnu.org; Fri, 26 May 2023 11:32:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2ZQ5-0003MZ-Ig for qemu-devel@nongnu.org; Fri, 26 May 2023 11:32:04 -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-630-Th7Wt7CFMB-pm8froIaVUw-1; Fri, 26 May 2023 11:31:51 -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 CD4EE8015D8; Fri, 26 May 2023 15:31:50 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27F3040D1B66; Fri, 26 May 2023 15:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685115116; 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=25QPWRUap87P8qT0SKZ7bty4YrGO74WAbW2+RZPm14I=; b=e/XlFzyenRepBv6z7Qd9PffAuADxS5RFzWxy4a240O+XIjvqmhO0mZ2KgpEQT1h5JnzmBr qpjvSC214HrLQxj4wSI+6qMm8xW3nIwwDW622undHXUCacn3FvJKlBZsv4Hdgt0ySYDyQT n1UWUk93IHnPpzF+0uiwEp7GNb4ei00= X-MC-Unique: Th7Wt7CFMB-pm8froIaVUw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Parav Pandit , "Gonglei (Arei)" , longpeng2@huawei.com, Shannon Nelson , Laurent Vivier , si-wei.liu@oracle.com, Cindy Lu , Lei Yang , Harpreet Singh Anand , Dragos Tatulea , Stefano Garzarella , Gautam Dawar , Jason Wang , Liuxiangdong , "Michael S. Tsirkin" , alvaro.karsz@solid-run.com, Zhu Lingshan Subject: [PATCH v4 1/2] vdpa: return errno in vhost_vdpa_get_vring_group error Date: Fri, 26 May 2023 17:31:42 +0200 Message-Id: <20230526153143.470745-2-eperezma@redhat.com> In-Reply-To: <20230526153143.470745-1-eperezma@redhat.com> References: <20230526153143.470745-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685115170157100005 We need to tell in the caller, as some errors are expected in a normal workflow. In particular, parent drivers in recent kernels with VHOST_BACKEND_F_IOTLB_ASID may not support vring groups. In that case, -ENOTSUP is returned. This is the case of vp_vdpa in Linux 6.2. Next patches in this series will use that information to know if it must abort or not. Also, next patches return properly an errp instead of printing with error_report. Reviewed-by: Stefano Garzarella Acked-by: Jason Wang Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- net/vhost-vdpa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 37cdc84562..3fb833fe76 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -362,6 +362,14 @@ static NetClientInfo net_vhost_vdpa_info =3D { .check_peer_type =3D vhost_vdpa_check_peer_type, }; =20 +/** + * Get vring virtqueue group + * + * @device_fd vdpa device fd + * @vq_index Virtqueue index + * + * Return -errno in case of error, or vq group if success. + */ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index) { struct vhost_vring_state state =3D { @@ -370,6 +378,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd= , unsigned vq_index) int r =3D ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, &state); =20 if (unlikely(r < 0)) { + r =3D -errno; error_report("Cannot get VQ %u group: %s", vq_index, g_strerror(errno)); return r; --=20 2.31.1 From nobody Fri May 10 15:13:12 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=1685115168; cv=none; d=zohomail.com; s=zohoarc; b=R/FYK5Lbq8aI3fNepRgxIEO9tHcTWaTqASbv1wWyliOeWoSZpHNTAN4tnhciwb9d6ohP56hnqTWkXbgLFKxzaI/PQdO6bixIA5rM1XkKlJVurFjoZOOnj1oqb+XHKXndiM4eC/fjJqHV+Bc30merrtbTo57bAVV35kxzvpH6SfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685115168; 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=jbnYQBiFK220eRkY8qup0icET08+1wIZ3Jse7v5+QIg=; b=K9qjJLKfZrsH+IU6N9qGd1oKIiH/PWhOgTrZ+BCWjKQRQspe3sxxh/ivOYqBALtEZ+bM+8/P0K1b+65wrwaa9Is+wkM/GEXjwd8PyJVf8kE2Ip0mdtyx0+T618yjIgSwAYqXehU9GkgTgP9fQf6m5CnBERE9MmPMk+DNcOAw9W0= 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 1685115168554254.51546930252584; Fri, 26 May 2023 08:32:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2ZQG-0003rD-7v; Fri, 26 May 2023 11:32:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2ZQF-0003qY-81 for qemu-devel@nongnu.org; Fri, 26 May 2023 11:32:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2ZQ8-0003Ml-D7 for qemu-devel@nongnu.org; Fri, 26 May 2023 11:32: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-184-6RYkU9viMWaV-xbN75tqcQ-1; Fri, 26 May 2023 11:31:54 -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 BEC51185A791; Fri, 26 May 2023 15:31:53 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19280400E117; Fri, 26 May 2023 15:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685115118; 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=jbnYQBiFK220eRkY8qup0icET08+1wIZ3Jse7v5+QIg=; b=MTEvps3hlDiut9Lg9wi8d0wSIzLZlfG5AmxiXSKav9ibYrSpjGj+R1lb9OuC7wC4arPK8y c9aQA1i2mXJCWBOUi4Tuj6ewIOQvuCgJObXfznIp77VXDG/A0TBiuTAqz2kXXFqS1/bqvS NyFs7UNe5RCooGo+PG1eKp4LIU3wtQg= X-MC-Unique: 6RYkU9viMWaV-xbN75tqcQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Parav Pandit , "Gonglei (Arei)" , longpeng2@huawei.com, Shannon Nelson , Laurent Vivier , si-wei.liu@oracle.com, Cindy Lu , Lei Yang , Harpreet Singh Anand , Dragos Tatulea , Stefano Garzarella , Gautam Dawar , Jason Wang , Liuxiangdong , "Michael S. Tsirkin" , alvaro.karsz@solid-run.com, Zhu Lingshan Subject: [PATCH v4 2/2] vdpa: move CVQ isolation check to net_init_vhost_vdpa Date: Fri, 26 May 2023 17:31:43 +0200 Message-Id: <20230526153143.470745-3-eperezma@redhat.com> In-Reply-To: <20230526153143.470745-1-eperezma@redhat.com> References: <20230526153143.470745-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685115170522100009 Evaluating it at start time instead of initialization time may make the guest capable of dynamically adding or removing migration blockers. Also, moving to initialization reduces the number of ioctls in the migration, reducing failure possibilities. As a drawback we need to check for CVQ isolation twice: one time with no MQ negotiated and another one acking it, as long as the device supports it. This is because Vring ASID / group management is based on vq indexes, but we don't know the index of CVQ before negotiating MQ. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- v2: Take out the reset of the device from vhost_vdpa_cvq_is_isolated v3: Only record cvq_isolated, true if the device have cvq isolated in both !MQ and MQ configurations. v4: Only probe one of MQ or !MQ. v4: Merge vhost_vdpa_cvq_is_isolated in vhost_vdpa_probe_cvq_isolation as there is only one call now. v4: Call ioctl directly instead of adding functions. --- net/vhost-vdpa.c | 154 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 111 insertions(+), 43 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3fb833fe76..0cafccd334 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -43,6 +43,10 @@ typedef struct VhostVDPAState { =20 /* The device always have SVQ enabled */ bool always_svq; + + /* The device can isolate CVQ in its own ASID */ + bool cvq_isolated; + bool started; } VhostVDPAState; =20 @@ -362,15 +366,8 @@ static NetClientInfo net_vhost_vdpa_info =3D { .check_peer_type =3D vhost_vdpa_check_peer_type, }; =20 -/** - * Get vring virtqueue group - * - * @device_fd vdpa device fd - * @vq_index Virtqueue index - * - * Return -errno in case of error, or vq group if success. - */ -static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index) +static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index, + Error **errp) { struct vhost_vring_state state =3D { .index =3D vq_index, @@ -379,8 +376,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd= , unsigned vq_index) =20 if (unlikely(r < 0)) { r =3D -errno; - error_report("Cannot get VQ %u group: %s", vq_index, - g_strerror(errno)); + error_setg_errno(errp, errno, "Cannot get VQ %u group", vq_index); return r; } =20 @@ -480,9 +476,9 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) { VhostVDPAState *s, *s0; struct vhost_vdpa *v; - uint64_t backend_features; int64_t cvq_group; - int cvq_index, r; + int r; + Error *err =3D NULL; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 @@ -502,41 +498,22 @@ static int vhost_vdpa_net_cvq_start(NetClientState *n= c) /* * If we early return in these cases SVQ will not be enabled. The migr= ation * will be blocked as long as vhost-vdpa backends will not offer _F_LO= G. - * - * Calling VHOST_GET_BACKEND_FEATURES as they are not available in v->= dev - * yet. */ - r =3D ioctl(v->device_fd, VHOST_GET_BACKEND_FEATURES, &backend_feature= s); - if (unlikely(r < 0)) { - error_report("Cannot get vdpa backend_features: %s(%d)", - g_strerror(errno), errno); - return -1; + if (!vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { + return 0; } - if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID)) || - !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { + + if (!s->cvq_isolated) { return 0; } =20 - /* - * Check if all the virtqueues of the virtio device are in a different= vq - * than the last vq. VQ group of last group passed in cvq_group. - */ - cvq_index =3D v->dev->vq_index_end - 1; - cvq_group =3D vhost_vdpa_get_vring_group(v->device_fd, cvq_index); + cvq_group =3D vhost_vdpa_get_vring_group(v->device_fd, + v->dev->vq_index_end - 1, + &err); if (unlikely(cvq_group < 0)) { + error_report_err(err); return cvq_group; } - for (int i =3D 0; i < cvq_index; ++i) { - int64_t group =3D vhost_vdpa_get_vring_group(v->device_fd, i); - - if (unlikely(group < 0)) { - return group; - } - - if (group =3D=3D cvq_group) { - return 0; - } - } =20 r =3D vhost_vdpa_set_address_space_id(v, cvq_group, VHOST_VDPA_NET_CVQ= _ASID); if (unlikely(r < 0)) { @@ -799,6 +776,87 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_sv= q_ops =3D { .avail_handler =3D vhost_vdpa_net_handle_ctrl_avail, }; =20 +/** + * Probe if CVQ is isolated + * + * @device_fd The vdpa device fd + * @features Features offered by the device. + * @cvq_index The control vq pair index + * + * Returns <0 in case of failure, 0 if false and 1 if true. + */ +static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features, + int cvq_index, Error **errp) +{ + uint64_t backend_features; + int64_t cvq_group; + uint8_t status =3D VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER | + VIRTIO_CONFIG_S_FEATURES_OK; + int r; + + ERRP_GUARD(); + + r =3D ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features); + if (unlikely(r < 0)) { + error_setg_errno(errp, errno, "Cannot get vdpa backend_features"); + return r; + } + + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID))) { + return 0; + } + + r =3D ioctl(device_fd, VHOST_SET_FEATURES, &features); + if (unlikely(r)) { + error_setg_errno(errp, errno, "Cannot set features"); + } + + r =3D ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); + if (unlikely(r)) { + error_setg_errno(errp, -r, "Cannot set device features"); + goto out; + } + + cvq_group =3D vhost_vdpa_get_vring_group(device_fd, cvq_index, errp); + if (unlikely(cvq_group < 0)) { + if (cvq_group !=3D -ENOTSUP) { + r =3D cvq_group; + goto out; + } + + /* + * The kernel report VHOST_BACKEND_F_IOTLB_ASID if the vdpa fronte= nd + * support ASID even if the parent driver does not. The CVQ canno= t be + * isolated in this case. + */ + error_free(*errp); + *errp =3D NULL; + r =3D 0; + goto out; + } + + for (int i =3D 0; i < cvq_index; ++i) { + int64_t group =3D vhost_vdpa_get_vring_group(device_fd, i, errp); + if (unlikely(group < 0)) { + r =3D group; + goto out; + } + + if (group =3D=3D (int64_t)cvq_group) { + r =3D 0; + goto out; + } + } + + r =3D 1; + +out: + status =3D 0; + ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); + return r; +} + static NetClientState *net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name, @@ -808,16 +866,25 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, bool is_datapath, bool svq, struct vhost_vdpa_iova_range iova_r= ange, - uint64_t features) + uint64_t features, + Error **errp) { NetClientState *nc =3D NULL; VhostVDPAState *s; int ret =3D 0; assert(name); + int cvq_isolated; + if (is_datapath) { nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); } else { + cvq_isolated =3D vhost_vdpa_probe_cvq_isolation(vdpa_device_fd, fe= atures, + queue_pair_index * 2= , errp); + if (unlikely(cvq_isolated < 0)) { + return NULL; + } + nc =3D qemu_new_net_control_client(&net_vhost_vdpa_cvq_info, peer, device, name); } @@ -844,6 +911,7 @@ 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; + s->cvq_isolated =3D cvq_isolated; =20 /* * TODO: We cannot migrate devices with CVQ as there is no way to = set @@ -972,7 +1040,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, 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, true, opts->x_s= vq, - iova_range, features); + iova_range, features, errp); if (!ncs[i]) goto err; } @@ -980,7 +1048,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, false, - opts->x_svq, iova_range, features); + opts->x_svq, iova_range, features, errp); if (!nc) goto err; } --=20 2.31.1