From nobody Fri Dec 19 02:48:15 2025 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=1652703474; cv=none; d=zohomail.com; s=zohoarc; b=OjpU0jloKXjVdK048l4oQ0Uv2vVtwMJ7VOwOIDCiBkWFvxdilPOHrMQvzV+GW4ntXVnEFltbsNpX06HySaYeQKww0m2HOr9Lopv2C1N7mDDWxDb2KAc9+SUtfrahNPzTghikPXTiE62vTTcCbb0wrY4Z6qXsv/CHAhlReP73+OQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652703474; h=Content-Type: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=05bBIi63juyp7TE0qSn2TB6p9HVIagy23aAAjlVPBNA=; b=Hxpv/dYNw+UAlhFjzNHh2cIApQfR6aWQxWG3xIHxpPAa0b1arWqwyE04eMJHNihiS1Hg5iP/eO7Gh3dOOf+D1yn1eb7rnU/2+WKPJ8FVsNaq1dvrCU5jw3HaXnm/7/jIXtLUyeCSYxwNhZ6LZSt2sX33+Y+tRQSUxOJUmFf2w5U= 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 1652703474117585.5445246014979; Mon, 16 May 2022 05:17:54 -0700 (PDT) Received: from localhost ([::1]:36512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqZfd-0001cZ-1k for importer@patchew.org; Mon, 16 May 2022 08:17:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY9a-0002rd-1R for qemu-devel@nongnu.org; Mon, 16 May 2022 06:40:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY9Y-0005oh-5j for qemu-devel@nongnu.org; Mon, 16 May 2022 06:40:41 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-487-XL1gEYiZNJqw9gJVbfy4QA-1; Mon, 16 May 2022 06:40:38 -0400 Received: by mail-wm1-f70.google.com with SMTP id i131-20020a1c3b89000000b00393fbb0718bso10166425wma.0 for ; Mon, 16 May 2022 03:40:38 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id 18-20020a05600c229200b00394867d66ddsm9725523wmf.35.2022.05.16.03.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697639; 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: in-reply-to:in-reply-to:references:references; bh=05bBIi63juyp7TE0qSn2TB6p9HVIagy23aAAjlVPBNA=; b=UBSxqWJPOecx5boqxZdCIvMmbBNvANpcqm4VqHlSSlIFD4dVP6krMfLTC6fIlrpy4A8x5n kDH9M5lZ9YmOoORtNP0ZAxrLTVu0vXltfrIdodjcJ6MTYgna51ryJ91NwXIjeFQr28YdFX G/J6ZBPI5tfNh4bxKJGxCti1wS7Hl84= X-MC-Unique: XL1gEYiZNJqw9gJVbfy4QA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=05bBIi63juyp7TE0qSn2TB6p9HVIagy23aAAjlVPBNA=; b=PXyx+yBS6VFo7cKpY1yhU/UxC2mtFXrN9Ru9cTyFIjtidgWGKWQpeEc4r3Nl699y3m b5DVeW0vSeI6DoxoeJma/mzWP/K8h4oPha6IzvWp+r7+HJ51NnqB8viRJ276epzaoMuK 28uXktf9MyOaFoze+1T/0T48hE8mkWIB1l3R+dwv7Ik+1wC9Sqhim0aBZEw2Yiw38CSb AIDuxd1ozhR7y5q2PTf/oq9BzVq8yCPpl3NcY5oKlMHdb6R6uIV3r9r7PGJQ2tVZ7CJs PMKulu1PHjfTh9gC/O8Qu4KJxhx+EGm4spNfOoLDMhwBKF8zw18e9IOmDuDRCHoCIEzz ocxA== X-Gm-Message-State: AOAM53093oyRMIJLgxIs37MQMUipNweEv3Bin/mSCDI2aWx/t0Kfkdax 8yp3BdSbRoyHgtz3eohg9kfo+BLbHyel4gDVMr9XYgGtvASft1IjdmGyoFd9PVlk8yjMB/Uf4Nc 5paz+Q6L9geKaN3Kqdf8D28X01Js4VJeP+FVXJ6mijUSz7dgHpE9X0nqsrOwt X-Received: by 2002:a5d:42c7:0:b0:20c:ff89:8af8 with SMTP id t7-20020a5d42c7000000b0020cff898af8mr7766415wrr.618.1652697637251; Mon, 16 May 2022 03:40:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0i7EF6PFRbzc85q9KBO5/0QQKiZcRuPS78l7DFNZFO+DIxn1Nn1hgGNBYR7H+ewG6DauRlg== X-Received: by 2002:a5d:42c7:0:b0:20c:ff89:8af8 with SMTP id t7-20020a5d42c7000000b0020cff898af8mr7766396wrr.618.1652697636999; Mon, 16 May 2022 03:40:36 -0700 (PDT) Date: Mon, 16 May 2022 06:40:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu , Jason Wang Subject: [PULL 85/91] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated Message-ID: <20220516095448.507876-86-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220516095448.507876-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=mst@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: 1652703475328100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Si-Wei Liu When the control virtqueue feature is absent or not negotiated, vhost_net_start() still tries to set up vhost_dev and install vhost notifiers for the control virtqueue, which results in erroneous ioctl calls with incorrect queue index sending down to driver. Do that only when needed. Fixes: 22288fe ("virtio-net: vhost control virtqueue support") Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Message-Id: <1651890498-24478-2-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9ad466f556..f9dd012021 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -292,7 +292,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) VirtIODevice *vdev =3D VIRTIO_DEVICE(n); NetClientState *nc =3D qemu_get_queue(n->nic); int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; - int cvq =3D n->max_ncs - n->max_queue_pairs; + int cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? + n->max_ncs - n->max_queue_pairs : 0; =20 if (!get_vhost_net(nc->peer)) { return; --=20 MST